From 166f09d23f53cda5b63b60a9a785bc9e2e430fb7 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:04:43 +0000 Subject: [PATCH 01/33] chore: sync repo --- .devcontainer/Dockerfile | 23 + .devcontainer/devcontainer.json | 20 + .fernignore | 4 - .gitattributes | 5 + .github/workflows/ci.yml | 110 +- .gitignore | 29 +- .publish/prepare.sh | 8 - .stats.yml | 4 + LICENSE | 222 +- README.md | 698 +- SECURITY.md | 23 + build.gradle | 88 - build.gradle.kts | 49 + buildSrc/build.gradle.kts | 12 + .../src/main/kotlin/courier.java.gradle.kts | 136 + .../src/main/kotlin/courier.kotlin.gradle.kts | 106 + .../main/kotlin/courier.publish.gradle.kts | 60 + courier-java-client-okhttp/build.gradle.kts | 14 + .../api/client/okhttp/CourierOkHttpClient.kt | 307 + .../client/okhttp/CourierOkHttpClientAsync.kt | 307 + .../courier/api/client/okhttp/OkHttpClient.kt | 246 + courier-java-core/build.gradle.kts | 41 + .../com/courier/api/client/CourierClient.kt | 147 + .../courier/api/client/CourierClientAsync.kt | 151 + .../api/client/CourierClientAsyncImpl.kt | 259 + .../courier/api/client/CourierClientImpl.kt | 247 + .../com/courier/api/core/BaseDeserializer.kt | 44 + .../com/courier/api/core/BaseSerializer.kt | 6 + .../main/kotlin/com/courier/api/core/Check.kt | 96 + .../com/courier/api/core/ClientOptions.kt | 450 + .../com/courier/api/core/DefaultSleeper.kt | 28 + .../com/courier/api/core/ObjectMappers.kt | 167 + .../kotlin/com/courier/api/core/Params.kt | 16 + .../com/courier/api/core/PhantomReachable.kt | 56 + .../core/PhantomReachableExecutorService.kt | 58 + .../api/core/PhantomReachableSleeper.kt | 23 + .../com/courier/api/core/PrepareRequest.kt | 24 + .../kotlin/com/courier/api/core/Properties.kt | 42 + .../com/courier/api/core/RequestOptions.kt | 46 + .../kotlin/com/courier/api/core/Sleeper.kt | 21 + .../kotlin/com/courier/api/core/Timeout.kt | 171 + .../main/kotlin/com/courier/api/core/Utils.kt | 115 + .../kotlin/com/courier/api/core/Values.kt | 723 ++ .../courier/api/core/handlers/EmptyHandler.kt | 12 + .../courier/api/core/handlers/ErrorHandler.kt | 84 + .../courier/api/core/handlers/JsonHandler.kt | 20 + .../api/core/handlers/StringHandler.kt | 13 + .../api/core/http/AsyncStreamResponse.kt | 157 + .../com/courier/api/core/http/Headers.kt | 115 + .../com/courier/api/core/http/HttpClient.kt | 26 + .../com/courier/api/core/http/HttpMethod.kt | 13 + .../com/courier/api/core/http/HttpRequest.kt | 146 + .../api/core/http/HttpRequestBodies.kt | 128 + .../courier/api/core/http/HttpRequestBody.kt | 25 + .../com/courier/api/core/http/HttpResponse.kt | 22 + .../courier/api/core/http/HttpResponseFor.kt | 25 + ...ntomReachableClosingAsyncStreamResponse.kt | 56 + .../http/PhantomReachableClosingHttpClient.kt | 26 + .../PhantomReachableClosingStreamResponse.kt | 21 + .../com/courier/api/core/http/QueryParams.kt | 129 + .../api/core/http/RetryingHttpClient.kt | 265 + .../courier/api/core/http/StreamResponse.kt | 19 + .../courier/api/errors/BadRequestException.kt | 80 + .../courier/api/errors/CourierException.kt | 5 + .../api/errors/CourierInvalidDataException.kt | 5 + .../courier/api/errors/CourierIoException.kt | 5 + .../api/errors/CourierRetryableException.kt | 14 + .../api/errors/CourierServiceException.kt | 17 + .../api/errors/InternalServerException.kt | 91 + .../courier/api/errors/NotFoundException.kt | 76 + .../api/errors/PermissionDeniedException.kt | 80 + .../courier/api/errors/RateLimitException.kt | 80 + .../api/errors/UnauthorizedException.kt | 80 + .../errors/UnexpectedStatusCodeException.kt | 92 + .../errors/UnprocessableEntityException.kt | 80 + .../courier/api/models/audiences/Audience.kt | 364 + .../models/audiences/AudienceDeleteParams.kt | 229 + .../audiences/AudienceListMembersParams.kt | 216 + .../audiences/AudienceListMembersResponse.kt | 538 + .../models/audiences/AudienceListParams.kt | 191 + .../models/audiences/AudienceListResponse.kt | 221 + .../audiences/AudienceRetrieveParams.kt | 194 + .../models/audiences/AudienceUpdateParams.kt | 577 + .../audiences/AudienceUpdateResponse.kt | 172 + .../courier/api/models/audiences/Filter.kt | 660 ++ .../api/models/audiences/FilterConfig.kt | 656 ++ .../models/audiences/NestedFilterConfig.kt | 439 + .../courier/api/models/audiences/Paging.kt | 203 + .../api/models/auditevents/AuditEvent.kt | 703 ++ .../auditevents/AuditEventListParams.kt | 191 + .../auditevents/AuditEventListResponse.kt | 226 + .../auditevents/AuditEventRetrieveParams.kt | 194 + .../api/models/auth/AuthIssueTokenParams.kt | 676 ++ .../api/models/auth/AuthIssueTokenResponse.kt | 157 + .../AutomationInvokeAdHocParams.kt | 9460 +++++++++++++++++ .../AutomationInvokeByTemplateParams.kt | 228 + .../invoke/AutomationInvokeParams.kt | 377 + .../invoke/AutomationInvokeResponse.kt | 170 + .../automations/invoke/AutomationStep.kt | 190 + .../automations/invoke/MergeAlgorithm.kt | 144 + .../com/courier/api/models/brands/Brand.kt | 452 + .../api/models/brands/BrandCreateParams.kt | 618 ++ .../api/models/brands/BrandDeleteParams.kt | 229 + .../api/models/brands/BrandListParams.kt | 191 + .../api/models/brands/BrandListResponse.kt | 224 + .../api/models/brands/BrandRetrieveParams.kt | 189 + .../api/models/brands/BrandSettings.kt | 565 + .../api/models/brands/BrandSnippets.kt | 540 + .../api/models/brands/BrandUpdateParams.kt | 577 + .../api/models/bulk/BulkAddUsersParams.kt | 462 + .../api/models/bulk/BulkCreateJobParams.kt | 416 + .../api/models/bulk/BulkCreateJobResponse.kt | 170 + .../api/models/bulk/BulkListUsersParams.kt | 216 + .../api/models/bulk/BulkListUsersResponse.kt | 710 ++ .../api/models/bulk/BulkRetrieveJobParams.kt | 189 + .../models/bulk/BulkRetrieveJobResponse.kt | 612 ++ .../api/models/bulk/BulkRunJobParams.kt | 229 + .../api/models/bulk/InboundBulkMessage.kt | 2294 ++++ .../api/models/bulk/InboundBulkMessageUser.kt | 264 + .../courier/api/models/bulk/UserRecipient.kt | 1046 ++ .../models/inbound/InboundTrackEventParams.kt | 925 ++ .../inbound/InboundTrackEventResponse.kt | 177 + .../com/courier/api/models/lists/List.kt | 291 + .../api/models/lists/ListDeleteParams.kt | 229 + .../api/models/lists/ListListParams.kt | 220 + .../api/models/lists/ListListResponse.kt | 222 + .../api/models/lists/ListRestoreParams.kt | 229 + .../api/models/lists/ListRetrieveParams.kt | 189 + .../api/models/lists/ListUpdateParams.kt | 508 + .../PutSubscriptionsRecipient.kt | 222 + .../subscriptions/RecipientPreferences.kt | 407 + .../subscriptions/SubscriptionAddParams.kt | 473 + .../subscriptions/SubscriptionListParams.kt | 214 + .../subscriptions/SubscriptionListResponse.kt | 467 + .../SubscriptionSubscribeParams.kt | 473 + .../SubscriptionSubscribeUserParams.kt | 452 + .../SubscriptionUnsubscribeUserParams.kt | 262 + .../models/messages/MessageCancelParams.kt | 234 + .../api/models/messages/MessageDetails.kt | 991 ++ .../messages/MessageGetContentParams.kt | 193 + .../messages/MessageGetContentResponse.kt | 1015 ++ .../models/messages/MessageHistoryParams.kt | 214 + .../models/messages/MessageHistoryResponse.kt | 289 + .../api/models/messages/MessageListParams.kt | 475 + .../models/messages/MessageListResponse.kt | 234 + .../models/messages/MessageRetrieveParams.kt | 193 + .../messages/MessageRetrieveResponse.kt | 814 ++ .../models/notifications/MessageRouting.kt | 363 + .../notifications/MessageRoutingChannel.kt | 196 + .../notifications/NotificationGetContent.kt | 1906 ++++ .../notifications/NotificationListParams.kt | 215 + .../notifications/NotificationListResponse.kt | 1014 ++ .../NotificationRetrieveContentParams.kt | 197 + .../models/notifications/checks/BaseCheck.kt | 490 + .../api/models/notifications/checks/Check.kt | 280 + .../notifications/checks/CheckDeleteParams.kt | 257 + .../notifications/checks/CheckListParams.kt | 216 + .../notifications/checks/CheckListResponse.kt | 190 + .../notifications/checks/CheckUpdateParams.kt | 471 + .../checks/CheckUpdateResponse.kt | 190 + .../draft/DraftRetrieveContentParams.kt | 190 + .../models/profiles/ProfileCreateParams.kt | 534 + .../models/profiles/ProfileCreateResponse.kt | 291 + .../models/profiles/ProfileDeleteParams.kt | 229 + .../models/profiles/ProfileReplaceParams.kt | 536 + .../models/profiles/ProfileReplaceResponse.kt | 291 + .../models/profiles/ProfileRetrieveParams.kt | 189 + .../profiles/ProfileRetrieveResponse.kt | 318 + .../models/profiles/ProfileUpdateParams.kt | 699 ++ .../models/profiles/lists/ListDeleteParams.kt | 229 + .../profiles/lists/ListDeleteResponse.kt | 288 + .../profiles/lists/ListRetrieveParams.kt | 214 + .../profiles/lists/ListRetrieveResponse.kt | 547 + .../profiles/lists/ListSubscribeParams.kt | 664 ++ .../profiles/lists/ListSubscribeResponse.kt | 291 + .../models/requests/RequestArchiveParams.kt | 229 + .../courier/api/models/send/BaseMessage.kt | 4181 ++++++++ .../api/models/send/BaseMessageSendTo.kt | 7483 +++++++++++++ .../com/courier/api/models/send/Content.kt | 671 ++ .../api/models/send/ElementalChannelNode.kt | 572 + .../api/models/send/ElementalGroupNode.kt | 385 + .../courier/api/models/send/ElementalNode.kt | 4182 ++++++++ .../com/courier/api/models/send/Message.kt | 1873 ++++ .../courier/api/models/send/MessageContext.kt | 165 + .../api/models/send/MsTeamsBaseProperties.kt | 208 + .../com/courier/api/models/send/Recipient.kt | 7064 ++++++++++++ .../courier/api/models/send/RoutingMethod.kt | 132 + .../api/models/send/SendSendMessageParams.kt | 429 + .../models/send/SendSendMessageResponse.kt | 194 + .../api/models/send/SlackBaseProperties.kt | 175 + .../kotlin/com/courier/api/models/send/Utm.kt | 293 + .../api/models/tenants/DefaultPreferences.kt | 512 + .../com/courier/api/models/tenants/Tenant.kt | 655 ++ .../api/models/tenants/TenantDeleteParams.kt | 229 + .../api/models/tenants/TenantListParams.kt | 234 + .../api/models/tenants/TenantListResponse.kt | 501 + .../models/tenants/TenantListUsersParams.kt | 236 + .../models/tenants/TenantListUsersResponse.kt | 502 + .../models/tenants/TenantRetrieveParams.kt | 189 + .../api/models/tenants/TenantUpdateParams.kt | 1055 ++ .../items/ChannelClassification.kt | 158 + .../items/ItemDeleteParams.kt | 258 + .../items/ItemUpdateParams.kt | 242 + .../items/SubscriptionTopicNew.kt | 428 + .../translations/TranslationRetrieveParams.kt | 217 + .../translations/TranslationUpdateParams.kt | 230 + .../preferences/PreferenceRetrieveParams.kt | 214 + .../preferences/PreferenceRetrieveResponse.kt | 230 + .../PreferenceRetrieveTopicParams.kt | 238 + .../PreferenceRetrieveTopicResponse.kt | 175 + .../users/preferences/PreferenceStatus.kt | 139 + .../PreferenceUpdateOrCreateTopicParams.kt | 745 ++ .../PreferenceUpdateOrCreateTopicResponse.kt | 174 + .../users/preferences/TopicPreference.kt | 417 + .../users/tenants/TenantAddMultipleParams.kt | 467 + .../users/tenants/TenantAddSingleParams.kt | 537 + .../models/users/tenants/TenantAssociation.kt | 508 + .../models/users/tenants/TenantListParams.kt | 236 + .../users/tenants/TenantListResponse.kt | 501 + .../users/tenants/TenantRemoveAllParams.kt | 229 + .../users/tenants/TenantRemoveSingleParams.kt | 259 + .../users/tokens/TokenAddMultipleParams.kt | 230 + .../users/tokens/TokenAddSingleParams.kt | 233 + .../models/users/tokens/TokenDeleteParams.kt | 258 + .../models/users/tokens/TokenListParams.kt | 189 + .../users/tokens/TokenRetrieveSingleParams.kt | 217 + .../tokens/TokenRetrieveSingleResponse.kt | 616 ++ .../models/users/tokens/TokenUpdateParams.kt | 706 ++ .../api/models/users/tokens/UserToken.kt | 1309 +++ .../services/async/AudienceServiceAsync.kt | 389 + .../async/AudienceServiceAsyncImpl.kt | 250 + .../services/async/AuditEventServiceAsync.kt | 162 + .../async/AuditEventServiceAsyncImpl.kt | 128 + .../api/services/async/AuthServiceAsync.kt | 62 + .../services/async/AuthServiceAsyncImpl.kt | 86 + .../services/async/AutomationServiceAsync.kt | 134 + .../async/AutomationServiceAsyncImpl.kt | 142 + .../api/services/async/BrandServiceAsync.kt | 302 + .../services/async/BrandServiceAsyncImpl.kt | 243 + .../api/services/async/BulkServiceAsync.kt | 335 + .../services/async/BulkServiceAsyncImpl.kt | 243 + .../api/services/async/InboundServiceAsync.kt | 66 + .../services/async/InboundServiceAsyncImpl.kt | 86 + .../api/services/async/ListServiceAsync.kt | 344 + .../services/async/ListServiceAsyncImpl.kt | 254 + .../api/services/async/MessageServiceAsync.kt | 407 + .../services/async/MessageServiceAsyncImpl.kt | 256 + .../async/NotificationServiceAsync.kt | 175 + .../async/NotificationServiceAsyncImpl.kt | 152 + .../api/services/async/ProfileServiceAsync.kt | 361 + .../services/async/ProfileServiceAsyncImpl.kt | 259 + .../api/services/async/RequestServiceAsync.kt | 110 + .../services/async/RequestServiceAsyncImpl.kt | 82 + .../api/services/async/SendServiceAsync.kt | 62 + .../services/async/SendServiceAsyncImpl.kt | 86 + .../api/services/async/TenantServiceAsync.kt | 366 + .../services/async/TenantServiceAsyncImpl.kt | 262 + .../services/async/TranslationServiceAsync.kt | 142 + .../async/TranslationServiceAsyncImpl.kt | 118 + .../api/services/async/UserServiceAsync.kt | 47 + .../services/async/UserServiceAsyncImpl.kt | 68 + .../async/automations/InvokeServiceAsync.kt | 36 + .../automations/InvokeServiceAsyncImpl.kt | 30 + .../async/lists/SubscriptionServiceAsync.kt | 331 + .../lists/SubscriptionServiceAsyncImpl.kt | 241 + .../async/notifications/CheckServiceAsync.kt | 193 + .../notifications/CheckServiceAsyncImpl.kt | 184 + .../async/notifications/DraftServiceAsync.kt | 118 + .../notifications/DraftServiceAsyncImpl.kt | 89 + .../async/profiles/ListServiceAsync.kt | 250 + .../async/profiles/ListServiceAsyncImpl.kt | 176 + .../tenants/DefaultPreferenceServiceAsync.kt | 42 + .../DefaultPreferenceServiceAsyncImpl.kt | 44 + .../defaultpreferences/ItemServiceAsync.kt | 133 + .../ItemServiceAsyncImpl.kt | 129 + .../async/users/PreferenceServiceAsync.kt | 239 + .../async/users/PreferenceServiceAsyncImpl.kt | 185 + .../async/users/TenantServiceAsync.kt | 345 + .../async/users/TenantServiceAsyncImpl.kt | 231 + .../services/async/users/TokenServiceAsync.kt | 385 + .../async/users/TokenServiceAsyncImpl.kt | 273 + .../api/services/blocking/AudienceService.kt | 382 + .../services/blocking/AudienceServiceImpl.kt | 232 + .../services/blocking/AuditEventService.kt | 158 + .../blocking/AuditEventServiceImpl.kt | 121 + .../api/services/blocking/AuthService.kt | 62 + .../api/services/blocking/AuthServiceImpl.kt | 81 + .../services/blocking/AutomationService.kt | 133 + .../blocking/AutomationServiceImpl.kt | 135 + .../api/services/blocking/BrandService.kt | 287 + .../api/services/blocking/BrandServiceImpl.kt | 213 + .../api/services/blocking/BulkService.kt | 328 + .../api/services/blocking/BulkServiceImpl.kt | 222 + .../api/services/blocking/InboundService.kt | 63 + .../services/blocking/InboundServiceImpl.kt | 82 + .../api/services/blocking/ListService.kt | 330 + .../api/services/blocking/ListServiceImpl.kt | 224 + .../api/services/blocking/MessageService.kt | 397 + .../services/blocking/MessageServiceImpl.kt | 240 + .../services/blocking/NotificationService.kt | 171 + .../blocking/NotificationServiceImpl.kt | 145 + .../api/services/blocking/ProfileService.kt | 346 + .../services/blocking/ProfileServiceImpl.kt | 239 + .../api/services/blocking/RequestService.kt | 103 + .../services/blocking/RequestServiceImpl.kt | 76 + .../api/services/blocking/SendService.kt | 62 + .../api/services/blocking/SendServiceImpl.kt | 81 + .../api/services/blocking/TenantService.kt | 349 + .../services/blocking/TenantServiceImpl.kt | 238 + .../services/blocking/TranslationService.kt | 140 + .../blocking/TranslationServiceImpl.kt | 109 + .../api/services/blocking/UserService.kt | 47 + .../api/services/blocking/UserServiceImpl.kt | 65 + .../blocking/automations/InvokeService.kt | 32 + .../blocking/automations/InvokeServiceImpl.kt | 30 + .../blocking/lists/SubscriptionService.kt | 321 + .../blocking/lists/SubscriptionServiceImpl.kt | 223 + .../blocking/notifications/CheckService.kt | 189 + .../notifications/CheckServiceImpl.kt | 169 + .../blocking/notifications/DraftService.kt | 113 + .../notifications/DraftServiceImpl.kt | 85 + .../services/blocking/profiles/ListService.kt | 243 + .../blocking/profiles/ListServiceImpl.kt | 165 + .../tenants/DefaultPreferenceService.kt | 42 + .../tenants/DefaultPreferenceServiceImpl.kt | 42 + .../tenants/defaultpreferences/ItemService.kt | 127 + .../defaultpreferences/ItemServiceImpl.kt | 117 + .../blocking/users/PreferenceService.kt | 239 + .../blocking/users/PreferenceServiceImpl.kt | 175 + .../services/blocking/users/TenantService.kt | 336 + .../blocking/users/TenantServiceImpl.kt | 207 + .../services/blocking/users/TokenService.kt | 375 + .../blocking/users/TokenServiceImpl.kt | 243 + .../META-INF/proguard/courier-java-core.pro | 32 + .../com/courier/api/TestServerExtension.kt | 62 + .../com/courier/api/core/ClientOptionsTest.kt | 34 + .../com/courier/api/core/ObjectMappersTest.kt | 102 + .../courier/api/core/PhantomReachableTest.kt | 27 + .../kotlin/com/courier/api/core/UtilsTest.kt | 33 + .../kotlin/com/courier/api/core/ValuesTest.kt | 144 + .../api/core/http/AsyncStreamResponseTest.kt | 268 + .../com/courier/api/core/http/HeadersTest.kt | 242 + .../courier/api/core/http/QueryParamsTest.kt | 180 + .../api/core/http/RetryingHttpClientTest.kt | 356 + .../audiences/AudienceDeleteParamsTest.kt | 23 + .../AudienceListMembersParamsTest.kt | 43 + .../AudienceListMembersResponseTest.kt | 67 + .../audiences/AudienceListParamsTest.kt | 33 + .../audiences/AudienceListResponseTest.kt | 88 + .../audiences/AudienceRetrieveParamsTest.kt | 23 + .../api/models/audiences/AudienceTest.kt | 74 + .../audiences/AudienceUpdateParamsTest.kt | 73 + .../audiences/AudienceUpdateResponseTest.kt | 84 + .../api/models/audiences/FilterConfigTest.kt | 115 + .../api/models/audiences/FilterTest.kt | 109 + .../audiences/NestedFilterConfigTest.kt | 62 + .../api/models/audiences/PagingTest.kt | 30 + .../auditevents/AuditEventListParamsTest.kt | 33 + .../auditevents/AuditEventListResponseTest.kt | 71 + .../AuditEventRetrieveParamsTest.kt | 23 + .../api/models/auditevents/AuditEventTest.kt | 55 + .../models/auth/AuthIssueTokenParamsTest.kt | 31 + .../models/auth/AuthIssueTokenResponseTest.kt | 32 + .../AutomationInvokeAdHocParamsTest.kt | 156 + .../AutomationInvokeByTemplateParamsTest.kt | 95 + .../invoke/AutomationInvokeParamsTest.kt | 65 + .../invoke/AutomationInvokeResponseTest.kt | 35 + .../automations/invoke/AutomationStepTest.kt | 33 + .../models/brands/BrandCreateParamsTest.kt | 135 + .../models/brands/BrandDeleteParamsTest.kt | 23 + .../api/models/brands/BrandListParamsTest.kt | 33 + .../models/brands/BrandListResponseTest.kt | 159 + .../models/brands/BrandRetrieveParamsTest.kt | 23 + .../api/models/brands/BrandSettingsTest.kt | 80 + .../api/models/brands/BrandSnippetsTest.kt | 57 + .../courier/api/models/brands/BrandTest.kt | 140 + .../models/brands/BrandUpdateParamsTest.kt | 138 + .../api/models/bulk/BulkAddUsersParamsTest.kt | 433 + .../models/bulk/BulkCreateJobParamsTest.kt | 588 + .../models/bulk/BulkCreateJobResponseTest.kt | 32 + .../models/bulk/BulkListUsersParamsTest.kt | 42 + .../models/bulk/BulkListUsersResponseTest.kt | 436 + .../models/bulk/BulkRetrieveJobParamsTest.kt | 23 + .../bulk/BulkRetrieveJobResponseTest.kt | 674 ++ .../api/models/bulk/BulkRunJobParamsTest.kt | 23 + .../api/models/bulk/InboundBulkMessageTest.kt | 555 + .../models/bulk/InboundBulkMessageUserTest.kt | 369 + .../api/models/bulk/UserRecipientTest.kt | 201 + .../inbound/InboundTrackEventParamsTest.kt | 91 + .../inbound/InboundTrackEventResponseTest.kt | 39 + .../api/models/lists/ListDeleteParamsTest.kt | 23 + .../api/models/lists/ListListParamsTest.kt | 36 + .../api/models/lists/ListListResponseTest.kt | 44 + .../api/models/lists/ListRestoreParamsTest.kt | 23 + .../models/lists/ListRetrieveParamsTest.kt | 23 + .../com/courier/api/models/lists/ListTest.kt | 32 + .../api/models/lists/ListUpdateParamsTest.kt | 163 + .../PutSubscriptionsRecipientTest.kt | 156 + .../subscriptions/RecipientPreferencesTest.kt | 128 + .../SubscriptionAddParamsTest.kt | 217 + .../SubscriptionListParamsTest.kt | 42 + .../SubscriptionListResponseTest.kt | 206 + .../SubscriptionSubscribeParamsTest.kt | 217 + .../SubscriptionSubscribeUserParamsTest.kt | 162 + .../SubscriptionUnsubscribeUserParamsTest.kt | 25 + .../messages/MessageCancelParamsTest.kt | 23 + .../api/models/messages/MessageDetailsTest.kt | 71 + .../messages/MessageGetContentParamsTest.kt | 23 + .../messages/MessageGetContentResponseTest.kt | 99 + .../messages/MessageHistoryParamsTest.kt | 42 + .../messages/MessageHistoryResponseTest.kt | 52 + .../models/messages/MessageListParamsTest.kt | 82 + .../messages/MessageListResponseTest.kt | 89 + .../messages/MessageRetrieveParamsTest.kt | 23 + .../messages/MessageRetrieveResponseTest.kt | 89 + .../MessageRoutingChannelTest.kt | 79 + .../notifications/MessageRoutingTest.kt | 36 + .../NotificationGetContentTest.kt | 154 + .../NotificationListParamsTest.kt | 34 + .../NotificationListResponseTest.kt | 119 + .../NotificationRetrieveContentParamsTest.kt | 23 + .../notifications/checks/BaseCheckTest.kt | 44 + .../checks/CheckDeleteParamsTest.kt | 24 + .../checks/CheckListParamsTest.kt | 24 + .../checks/CheckListResponseTest.kt | 60 + .../models/notifications/checks/CheckTest.kt | 44 + .../checks/CheckUpdateParamsTest.kt | 72 + .../checks/CheckUpdateResponseTest.kt | 60 + .../draft/DraftRetrieveContentParamsTest.kt | 23 + .../profiles/ProfileCreateParamsTest.kt | 61 + .../profiles/ProfileCreateResponseTest.kt | 34 + .../profiles/ProfileDeleteParamsTest.kt | 23 + .../profiles/ProfileReplaceParamsTest.kt | 61 + .../profiles/ProfileReplaceResponseTest.kt | 34 + .../profiles/ProfileRetrieveParamsTest.kt | 23 + .../profiles/ProfileRetrieveResponseTest.kt | 170 + .../profiles/ProfileUpdateParamsTest.kt | 52 + .../profiles/lists/ListDeleteParamsTest.kt | 23 + .../profiles/lists/ListDeleteResponseTest.kt | 34 + .../profiles/lists/ListRetrieveParamsTest.kt | 42 + .../lists/ListRetrieveResponseTest.kt | 213 + .../profiles/lists/ListSubscribeParamsTest.kt | 214 + .../lists/ListSubscribeResponseTest.kt | 34 + .../requests/RequestArchiveParamsTest.kt | 23 + .../api/models/send/BaseMessageSendToTest.kt | 96 + .../api/models/send/BaseMessageTest.kt | 483 + .../courier/api/models/send/ContentTest.kt | 107 + .../models/send/ElementalChannelNodeTest.kt | 98 + .../api/models/send/ElementalGroupNodeTest.kt | 78 + .../api/models/send/ElementalNodeTest.kt | 450 + .../api/models/send/MessageContextTest.kt | 32 + .../courier/api/models/send/MessageTest.kt | 793 ++ .../models/send/MsTeamsBasePropertiesTest.kt | 35 + .../courier/api/models/send/RecipientTest.kt | 633 ++ .../models/send/SendSendMessageParamsTest.kt | 641 ++ .../send/SendSendMessageResponseTest.kt | 34 + .../models/send/SlackBasePropertiesTest.kt | 32 + .../com/courier/api/models/send/UtmTest.kt | 47 + .../models/tenants/DefaultPreferencesTest.kt | 63 + .../models/tenants/TenantDeleteParamsTest.kt | 23 + .../models/tenants/TenantListParamsTest.kt | 49 + .../models/tenants/TenantListResponseTest.kt | 144 + .../tenants/TenantListUsersParamsTest.kt | 44 + .../tenants/TenantListUsersResponseTest.kt | 90 + .../tenants/TenantRetrieveParamsTest.kt | 23 + .../courier/api/models/tenants/TenantTest.kt | 116 + .../models/tenants/TenantUpdateParamsTest.kt | 126 + .../items/ItemDeleteParamsTest.kt | 24 + .../items/ItemUpdateParamsTest.kt | 91 + .../items/SubscriptionTopicNewTest.kt | 46 + .../TranslationRetrieveParamsTest.kt | 24 + .../TranslationUpdateParamsTest.kt | 35 + .../PreferenceRetrieveParamsTest.kt | 44 + .../PreferenceRetrieveResponseTest.kt | 72 + .../PreferenceRetrieveTopicParamsTest.kt | 55 + .../PreferenceRetrieveTopicResponseTest.kt | 68 + ...PreferenceUpdateOrCreateTopicParamsTest.kt | 141 + ...eferenceUpdateOrCreateTopicResponseTest.kt | 35 + .../users/preferences/TopicPreferenceTest.kt | 56 + .../tenants/TenantAddMultipleParamsTest.kt | 92 + .../tenants/TenantAddSingleParamsTest.kt | 63 + .../users/tenants/TenantAssociationTest.kt | 61 + .../users/tenants/TenantListParamsTest.kt | 43 + .../users/tenants/TenantListResponseTest.kt | 89 + .../tenants/TenantRemoveAllParamsTest.kt | 23 + .../tenants/TenantRemoveSingleParamsTest.kt | 25 + .../tokens/TokenAddMultipleParamsTest.kt | 23 + .../users/tokens/TokenAddSingleParamsTest.kt | 143 + .../users/tokens/TokenDeleteParamsTest.kt | 24 + .../users/tokens/TokenListParamsTest.kt | 23 + .../tokens/TokenRetrieveSingleParamsTest.kt | 24 + .../tokens/TokenRetrieveSingleResponseTest.kt | 114 + .../users/tokens/TokenUpdateParamsTest.kt | 69 + .../api/models/users/tokens/UserTokenTest.kt | 104 + .../courier/api/services/ErrorHandlingTest.kt | 4013 +++++++ .../courier/api/services/ServiceParamsTest.kt | 262 + .../async/AudienceServiceAsyncTest.kt | 117 + .../async/AuditEventServiceAsyncTest.kt | 47 + .../services/async/AuthServiceAsyncTest.kt | 36 + .../async/AutomationServiceAsyncTest.kt | 100 + .../services/async/BrandServiceAsyncTest.kt | 169 + .../services/async/BulkServiceAsyncTest.kt | 438 + .../services/async/InboundServiceAsyncTest.kt | 46 + .../services/async/ListServiceAsyncTest.kt | 150 + .../services/async/MessageServiceAsyncTest.kt | 116 + .../async/NotificationServiceAsyncTest.kt | 49 + .../services/async/ProfileServiceAsyncTest.kt | 127 + .../services/async/RequestServiceAsyncTest.kt | 28 + .../services/async/SendServiceAsyncTest.kt | 244 + .../services/async/TenantServiceAsyncTest.kt | 143 + .../async/TranslationServiceAsyncTest.kt | 55 + .../lists/SubscriptionServiceAsyncTest.kt | 278 + .../notifications/CheckServiceAsyncTest.kt | 83 + .../notifications/DraftServiceAsyncTest.kt | 29 + .../async/profiles/ListServiceAsyncTest.kt | 128 + .../ItemServiceAsyncTest.kt | 63 + .../async/users/PreferenceServiceAsyncTest.kt | 91 + .../async/users/TenantServiceAsyncTest.kt | 129 + .../async/users/TokenServiceAsyncTest.kt | 162 + .../services/blocking/AudienceServiceTest.kt | 110 + .../blocking/AuditEventServiceTest.kt | 45 + .../api/services/blocking/AuthServiceTest.kt | 35 + .../blocking/AutomationServiceTest.kt | 98 + .../api/services/blocking/BrandServiceTest.kt | 162 + .../api/services/blocking/BulkServiceTest.kt | 430 + .../services/blocking/InboundServiceTest.kt | 45 + .../api/services/blocking/ListServiceTest.kt | 141 + .../services/blocking/MessageServiceTest.kt | 111 + .../blocking/NotificationServiceTest.kt | 47 + .../services/blocking/ProfileServiceTest.kt | 115 + .../services/blocking/RequestServiceTest.kt | 26 + .../api/services/blocking/SendServiceTest.kt | 243 + .../services/blocking/TenantServiceTest.kt | 137 + .../blocking/TranslationServiceTest.kt | 45 + .../blocking/lists/SubscriptionServiceTest.kt | 256 + .../notifications/CheckServiceTest.kt | 78 + .../notifications/DraftServiceTest.kt | 28 + .../blocking/profiles/ListServiceTest.kt | 125 + .../defaultpreferences/ItemServiceTest.kt | 57 + .../blocking/users/PreferenceServiceTest.kt | 88 + .../blocking/users/TenantServiceTest.kt | 117 + .../blocking/users/TokenServiceTest.kt | 143 + courier-java-example/build.gradle.kts | 28 + courier-java-lib/.keep | 4 + courier-java-proguard-test/build.gradle.kts | 101 + .../api/proguard/ProGuardCompatibilityTest.kt | 275 + courier-java-proguard-test/test.pro | 9 + courier-java/build.gradle.kts | 29 + gradle.properties | 18 + gradle/wrapper/gradle-wrapper.jar | Bin 43453 -> 43583 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 4 +- gradlew.bat | 186 +- sample-app/build.gradle | 19 - sample-app/src/main/java/sample/App.java | 13 - scripts/build | 8 + scripts/fast-format | 46 + scripts/format | 21 + scripts/java-format | 7 + scripts/kotlin-format | 7 + scripts/lint | 23 + scripts/mock | 41 + scripts/test | 56 + settings.gradle | 1 - settings.gradle.kts | 14 + src/main/java/com/courier/api/Courier.java | 203 - .../java/com/courier/api/CourierBuilder.java | 44 - .../com/courier/api/core/ClientOptions.java | 129 - .../courier/api/core/CourierApiApiError.java | 45 - .../com/courier/api/core/CourierApiError.java | 17 - .../api/core/DateTimeDeserializer.java | 55 - .../com/courier/api/core/Environment.java | 22 - .../api/core/IdempotentRequestOptions.java | 103 - .../java/com/courier/api/core/MediaTypes.java | 13 - .../com/courier/api/core/ObjectMappers.java | 36 - .../com/courier/api/core/RequestOptions.java | 71 - .../courier/api/core/RetryInterceptor.java | 78 - .../java/com/courier/api/core/Stream.java | 97 - .../java/com/courier/api/core/Suppliers.java | 23 - .../api/requests/SendMessageRequest.java | 109 - .../resources/audiences/AudiencesClient.java | 291 - .../requests/AudienceMembersListParams.java | 98 - .../requests/AudienceUpdateParams.java | 150 - .../requests/AudiencesListParams.java | 98 - .../resources/audiences/types/Audience.java | 245 - .../audiences/types/AudienceListResponse.java | 142 - .../audiences/types/AudienceMember.java | 200 - .../types/AudienceMemberGetResponse.java | 101 - .../types/AudienceMemberListResponse.java | 143 - .../types/AudienceUpdateResponse.java | 101 - .../audiences/types/BaseFilterConfig.java | 109 - .../audiences/types/ComparisonOperator.java | 46 - .../api/resources/audiences/types/Filter.java | 94 - .../audiences/types/FilterConfig.java | 94 - .../audiences/types/IBaseFilterConfig.java | 8 - .../audiences/types/LogicalOperator.java | 24 - .../audiences/types/NestedFilterConfig.java | 149 - .../resources/audiences/types/Operator.java | 94 - .../audiences/types/SingleFilterConfig.java | 167 - .../auditevents/AuditEventsClient.java | 118 - .../requests/ListAuditEventsRequest.java | 98 - .../resources/auditevents/types/Actor.java | 117 - .../auditevents/types/AuditEvent.java | 238 - .../types/GetAuditEventParams.java | 101 - .../types/ListAuditEventsParams.java | 95 - .../types/ListAuditEventsResponse.java | 142 - .../resources/auditevents/types/Target.java | 117 - .../authtokens/AuthTokensClient.java | 78 - .../authtokens/requests/IssueTokenParams.java | 123 - .../authtokens/types/IssueTokenResponse.java | 95 - .../automations/AutomationsClient.java | 138 - .../automations/types/AccessorType.java | 101 - .../automations/types/Automation.java | 128 - .../types/AutomationAdHocInvokeParams.java | 261 - .../AutomationAddToBatchMaxItemsType.java | 94 - .../types/AutomationAddToBatchRetain.java | 182 - .../types/AutomationAddToBatchRetainType.java | 28 - .../types/AutomationAddToBatchScope.java | 26 - .../types/AutomationAddToBatchStep.java | 435 - .../types/AutomationAddToDigestStep.java | 177 - .../types/AutomationCancelStep.java | 150 - .../types/AutomationDelayStep.java | 182 - .../types/AutomationFetchDataStep.java | 258 - .../types/AutomationFetchDataWebhook.java | 219 - .../AutomationFetchDataWebhookMethod.java | 24 - .../types/AutomationInvokeParams.java | 198 - .../types/AutomationInvokeResponse.java | 101 - .../types/AutomationInvokeStep.java | 167 - .../types/AutomationInvokeTemplateParams.java | 261 - .../types/AutomationRunContext.java | 193 - .../types/AutomationSendListStep.java | 292 - .../automations/types/AutomationSendStep.java | 274 - .../automations/types/AutomationStep.java | 119 - .../types/AutomationStepOption.java | 202 - .../types/AutomationThrottleOnThrottle.java | 108 - .../types/AutomationThrottleScope.java | 26 - .../types/AutomationThrottleStep.java | 306 - .../types/AutomationUpdateProfileStep.java | 151 - .../types/AutomationV2SendStep.java | 168 - .../types/IAutomationInvokeParams.java | 19 - .../automations/types/IAutomationStep.java | 12 - .../automations/types/MergeAlgorithm.java | 28 - .../api/resources/brands/BrandsClient.java | 284 - .../requests/BrandUpdateParameters.java | 172 - .../brands/requests/ListBrandsRequest.java | 98 - .../api/resources/brands/types/Brand.java | 336 - .../resources/brands/types/BrandColors.java | 143 - .../brands/types/BrandGetAllResponse.java | 142 - .../brands/types/BrandParameters.java | 196 - .../resources/brands/types/BrandSettings.java | 144 - .../resources/brands/types/BrandSnippet.java | 128 - .../resources/brands/types/BrandSnippets.java | 102 - .../brands/types/BrandsResponse.java | 142 - .../api/resources/bulk/BulkClient.java | 291 - .../bulk/requests/BulkCreateJobParams.java | 102 - .../bulk/requests/BulkGetUsersParams.java | 98 - .../bulk/types/BulkCreateJobResponse.java | 101 - .../bulk/types/BulkGetJobParams.java | 101 - .../bulk/types/BulkGetJobResponse.java | 101 - .../bulk/types/BulkGetJobUsersParams.java | 131 - .../bulk/types/BulkGetJobUsersResponse.java | 143 - .../resources/bulk/types/BulkIngestError.java | 123 - .../bulk/types/BulkIngestUsersParams.java | 102 - .../bulk/types/BulkIngestUsersResponse.java | 133 - .../resources/bulk/types/BulkJobStatus.java | 28 - .../bulk/types/BulkJobUserStatus.java | 26 - .../bulk/types/BulkMessageUserResponse.java | 294 - .../bulk/types/IInboundBulkMessageUser.java | 20 - .../bulk/types/IInboundBulkMessageV1.java | 19 - .../bulk/types/InboundBulkContentMessage.java | 551 - .../bulk/types/InboundBulkMessage.java | 235 - .../bulk/types/InboundBulkMessageUser.java | 200 - .../bulk/types/InboundBulkMessageV1.java | 211 - .../bulk/types/InboundBulkMessageV2.java | 94 - .../types/InboundBulkTemplateMessage.java | 550 - .../api/resources/bulk/types/JobDetails.java | 200 - .../errors/CourierApiAlreadyExistsError.java | 27 - .../errors/CourierApiBadRequestError.java | 27 - .../errors/CourierApiConflictError.java | 27 - .../CourierApiMessageNotFoundError.java | 27 - .../errors/CourierApiNotFoundError.java | 27 - .../CourierApiPaymentRequiredError.java | 27 - .../commons/types/AlreadyExists.java | 114 - .../resources/commons/types/BadRequest.java | 114 - .../resources/commons/types/BaseError.java | 109 - .../types/BaseTemplateTenantAssociation.java | 241 - .../commons/types/ChannelClassification.java | 32 - .../commons/types/ChannelPreference.java | 101 - .../api/resources/commons/types/Conflict.java | 114 - .../api/resources/commons/types/Email.java | 123 - .../resources/commons/types/IBaseError.java | 8 - .../types/IBaseTemplateTenantAssociation.java | 16 - .../ISingleTemplateTenantAssociation.java | 8 - .../types/ListTemplateTenantAssociation.java | 265 - .../commons/types/MessageNotFound.java | 114 - .../api/resources/commons/types/NotFound.java | 114 - .../types/NotificationPreferenceDetails.java | 166 - .../api/resources/commons/types/Paging.java | 131 - .../commons/types/PaymentRequired.java | 114 - .../commons/types/PreferenceStatus.java | 26 - .../commons/types/RecipientPreferences.java | 120 - .../api/resources/commons/types/Rule.java | 131 - .../SingleTemplateTenantAssociation.java | 267 - .../commons/types/TenantTemplateData.java | 126 - .../types/TenantTemplateDataNoContent.java | 102 - .../commons/types/UserTenantAssociation.java | 216 - .../api/resources/inbound/InboundClient.java | 88 - .../inbound/types/InboundTrackEvent.java | 225 - .../inbound/types/TrackAcceptedResponse.java | 108 - .../api/resources/lists/ListsClient.java | 578 - .../lists/requests/AddSubscribersToList.java | 103 - .../lists/requests/GetAllListsRequest.java | 124 - .../GetSubscriptionForListRequest.java | 98 - .../lists/requests/RestoreListRequest.java | 59 - .../requests/SubscribeUserToListRequest.java | 97 - .../requests/SubscribeUsersToListRequest.java | 104 - .../api/resources/lists/types/List.java | 189 - .../lists/types/ListGetAllResponse.java | 141 - .../types/ListGetSubscriptionsResponse.java | 143 - .../resources/lists/types/ListPutParams.java | 133 - .../types/ListSubscriptionRecipient.java | 166 - .../types/PutSubscriptionsRecipient.java | 133 - .../resources/messages/MessagesClient.java | 370 - .../requests/GetMessageHistoryRequest.java | 98 - .../requests/ListMessagesRequest.java | 480 - .../messages/types/IMessageDetails.java | 32 - .../messages/types/ListMessagesResponse.java | 161 - .../messages/types/MessageDetails.java | 513 - .../types/MessageDetailsExtended.java | 546 - .../types/MessageHistoryResponse.java | 102 - .../messages/types/MessageStatus.java | 50 - .../api/resources/messages/types/Reason.java | 38 - .../messages/types/RenderOutput.java | 170 - .../messages/types/RenderOutputResponse.java | 105 - .../messages/types/RenderedMessageBlock.java | 137 - .../types/RenderedMessageContent.java | 288 - .../notifications/NotificationsClient.java | 270 - .../requests/NotificationListParams.java | 121 - .../SubmissionChecksReplaceParams.java | 103 - .../notifications/types/BaseCheck.java | 131 - .../notifications/types/BlockType.java | 38 - .../resources/notifications/types/Check.java | 153 - .../notifications/types/CheckStatus.java | 26 - .../notifications/types/IBaseCheck.java | 12 - .../notifications/types/MessageRouting.java | 144 - .../types/MessageRoutingChannel.java | 94 - .../types/MessageRoutingMethod.java | 24 - .../notifications/types/Notification.java | 288 - .../types/NotificationBlock.java | 279 - .../types/NotificationChannel.java | 225 - .../types/NotificationChannelContent.java | 118 - .../types/NotificationContent.java | 94 - .../types/NotificationContentHierarchy.java | 118 - .../types/NotificationGetContentResponse.java | 144 - .../types/NotificationListResponse.java | 143 - .../notifications/types/NotificationTag.java | 102 - .../types/NotificationTagData.java | 123 - .../types/SubmissionChecksGetResponse.java | 102 - .../SubmissionChecksReplaceResponse.java | 102 - .../resources/profiles/ProfilesClient.java | 469 - .../requests/GetListSubscriptionsRequest.java | 98 - .../requests/MergeProfileRequest.java | 101 - .../requests/ReplaceProfileRequest.java | 101 - .../api/resources/profiles/types/Address.java | 231 - .../profiles/types/AirshipProfile.java | 142 - .../types/AirshipProfileAudience.java | 101 - .../types/DeleteListSubscriptionResponse.java | 65 - .../api/resources/profiles/types/Discord.java | 94 - .../api/resources/profiles/types/Expo.java | 94 - .../types/GetListSubscriptionsList.java | 229 - .../types/GetListSubscriptionsResponse.java | 154 - .../types/IMsTeamsBaseProperties.java | 10 - .../profiles/types/ISlackBaseProperties.java | 8 - .../resources/profiles/types/Intercom.java | 123 - .../profiles/types/IntercomRecipient.java | 101 - .../profiles/types/MergeProfileResponse.java | 65 - .../api/resources/profiles/types/MsTeams.java | 130 - .../profiles/types/MsTeamsBaseProperties.java | 125 - .../profiles/types/MultipleTokens.java | 102 - .../resources/profiles/types/Pagerduty.java | 169 - .../profiles/types/ProfileGetParameters.java | 101 - .../profiles/types/ProfileGetResponse.java | 128 - .../profiles/types/ProfileUpdateRequest.java | 105 - .../types/ReplaceProfileResponse.java | 65 - .../profiles/types/SendDirectMessage.java | 101 - .../profiles/types/SendToChannel.java | 101 - .../types/SendToMsTeamsChannelId.java | 150 - .../types/SendToMsTeamsChannelName.java | 178 - .../types/SendToMsTeamsConversationId.java | 150 - .../profiles/types/SendToMsTeamsEmail.java | 148 - .../profiles/types/SendToMsTeamsUserId.java | 148 - .../profiles/types/SendToSlackChannel.java | 124 - .../profiles/types/SendToSlackEmail.java | 124 - .../profiles/types/SendToSlackUserId.java | 124 - .../api/resources/profiles/types/Slack.java | 106 - .../profiles/types/SlackBaseProperties.java | 102 - .../resources/profiles/types/SnoozeRule.java | 145 - .../profiles/types/SnoozeRuleType.java | 22 - .../types/SubscribeToListsRequest.java | 103 - .../SubscribeToListsRequestListObject.java | 133 - .../types/SubscribeToListsResponse.java | 65 - .../api/resources/profiles/types/Token.java | 101 - .../resources/profiles/types/UserProfile.java | 925 -- .../types/UserProfileFirebaseToken.java | 96 - .../profiles/types/UserProfilePatch.java | 166 - .../profiles/types/WebhookAuthMode.java | 26 - .../profiles/types/WebhookAuthentication.java | 223 - .../profiles/types/WebhookMethod.java | 24 - .../profiles/types/WebhookProfile.java | 260 - .../profiles/types/WebhookProfileType.java | 24 - .../resources/send/types/AudienceFilter.java | 114 - .../send/types/AudienceRecipient.java | 171 - .../api/resources/send/types/BaseMessage.java | 397 - .../send/types/BaseMessageSendTo.java | 99 - .../send/types/BaseSocialPresence.java | 101 - .../send/types/BrandSettingsEmail.java | 169 - .../send/types/BrandSettingsInApp.java | 316 - .../types/BrandSettingsSocialPresence.java | 219 - .../resources/send/types/BrandTemplate.java | 300 - .../send/types/BrandTemplateOverride.java | 397 - .../api/resources/send/types/Channel.java | 272 - .../resources/send/types/ChannelMetadata.java | 95 - .../resources/send/types/ChannelSource.java | 26 - .../api/resources/send/types/Content.java | 94 - .../resources/send/types/ContentMessage.java | 580 - .../api/resources/send/types/Criteria.java | 28 - .../api/resources/send/types/Delay.java | 123 - .../send/types/ElementalActionNode.java | 476 - .../send/types/ElementalBaseNode.java | 174 - .../send/types/ElementalChannelNode.java | 317 - .../send/types/ElementalContent.java | 181 - .../send/types/ElementalContentSugar.java | 137 - .../send/types/ElementalDividerNode.java | 201 - .../send/types/ElementalGroupNode.java | 208 - .../send/types/ElementalImageNode.java | 395 - .../send/types/ElementalMetaNode.java | 201 - .../resources/send/types/ElementalNode.java | 539 - .../send/types/ElementalQuoteNode.java | 382 - .../send/types/ElementalTextNode.java | 588 - .../api/resources/send/types/EmailFooter.java | 118 - .../api/resources/send/types/EmailHead.java | 131 - .../api/resources/send/types/EmailHeader.java | 165 - .../resources/send/types/ExpiresInType.java | 93 - .../api/resources/send/types/Expiry.java | 145 - .../send/types/IActionButtonStyle.java | 24 - .../api/resources/send/types/IAlignment.java | 28 - .../resources/send/types/IBaseMessage.java | 31 - .../send/types/IBaseMessageSendTo.java | 10 - .../resources/send/types/IBrandTemplate.java | 22 - .../send/types/IElementalBaseNode.java | 17 - .../send/types/IListPatternRecipientType.java | 6 - .../send/types/IListRecipientType.java | 6 - .../send/types/IProfilePreferences.java | 152 - .../send/types/IUserRecipientType.java | 6 - .../api/resources/send/types/Icons.java | 117 - .../resources/send/types/InAppPlacement.java | 28 - .../types/InvalidListPatternRecipient.java | 123 - .../send/types/InvalidListRecipient.java | 123 - .../send/types/InvalidUserRecipient.java | 123 - .../api/resources/send/types/ListFilter.java | 114 - .../send/types/ListPatternRecipient.java | 120 - .../send/types/ListPatternRecipientType.java | 59 - .../resources/send/types/ListRecipient.java | 144 - .../send/types/ListRecipientType.java | 59 - .../api/resources/send/types/Locale.java | 101 - .../api/resources/send/types/Logo.java | 117 - .../api/resources/send/types/Message.java | 94 - .../resources/send/types/MessageContext.java | 99 - .../resources/send/types/MessageMetadata.java | 182 - .../send/types/MessagePreferences.java | 108 - .../send/types/MessageProvidersType.java | 178 - .../send/types/MessageRecipient.java | 96 - .../api/resources/send/types/Metadata.java | 95 - .../send/types/MsTeamsRecipient.java | 102 - .../send/types/PagerdutyRecipient.java | 102 - .../api/resources/send/types/Preference.java | 199 - .../api/resources/send/types/Preferences.java | 102 - .../api/resources/send/types/Recipient.java | 180 - .../api/resources/send/types/Routing.java | 160 - .../resources/send/types/RoutingMethod.java | 24 - .../api/resources/send/types/RuleType.java | 26 - .../resources/send/types/SlackRecipient.java | 102 - .../resources/send/types/TemplateMessage.java | 580 - .../api/resources/send/types/TextAlign.java | 26 - .../api/resources/send/types/TextStyle.java | 28 - .../api/resources/send/types/Timeout.java | 193 - .../api/resources/send/types/Timeouts.java | 117 - .../send/types/TrackingOverride.java | 101 - .../resources/send/types/UserRecipient.java | 321 - .../send/types/UserRecipientType.java | 59 - .../courier/api/resources/send/types/Utm.java | 193 - .../send/types/WebhookRecipient.java | 102 - .../send/types/WidgetBackground.java | 118 - .../resources/templates/TemplatesClient.java | 76 - .../requests/ListTemplatesRequest.java | 98 - .../types/ListTemplatesResponse.java | 154 - .../types/NotificationTemplates.java | 288 - .../templates/types/RoutingStrategy.java | 160 - .../types/RoutingStrategyMethod.java | 24 - .../api/resources/templates/types/Tag.java | 102 - .../resources/templates/types/TagData.java | 137 - .../api/resources/tenants/TenantsClient.java | 452 - .../GetTemplateListByTenantParams.java | 124 - .../tenants/requests/ListTenantParams.java | 153 - .../requests/ListUsersForTenantParams.java | 125 - .../requests/TenantCreateOrReplaceParams.java | 305 - .../tenants/types/DefaultPreferences.java | 96 - .../types/GetTemplateByTenantResponse.java | 268 - .../tenants/types/ISubscriptionTopicNew.java | 16 - .../types/ListTemplatesByTenantResponse.java | 261 - .../types/ListUsersForTenantResponse.java | 261 - .../tenants/types/SubscriptionTopic.java | 215 - .../tenants/types/SubscriptionTopicNew.java | 184 - .../types/SubscriptionTopicStatus.java | 26 - .../api/resources/tenants/types/Tenant.java | 343 - .../tenants/types/TenantListResponse.java | 279 - .../translations/TranslationsClient.java | 137 - .../api/resources/users/UsersClient.java | 40 - .../users/preferences/PreferencesClient.java | 224 - .../requests/UserPreferencesParams.java | 98 - .../requests/UserPreferencesTopicParams.java | 98 - .../requests/UserPreferencesUpdateParams.java | 140 - .../preferences/types/TopicPreference.java | 255 - .../types/TopicPreferenceUpdate.java | 175 - .../types/UserPreferencesGetResponse.java | 101 - .../types/UserPreferencesListResponse.java | 161 - .../types/UserPreferencesUpdateResponse.java | 101 - .../users/tenants/TenantsClient.java | 294 - .../AddUserToMultipleTenantsParams.java | 104 - .../AddUserToSingleTenantsParams.java | 96 - .../requests/ListTenantsForUserParams.java | 125 - .../AddUserToSingleTenantsParamsProfile.java | 250 - .../types/ListTenantsForUserResponse.java | 261 - .../resources/users/tokens/TokensClient.java | 338 - .../tokens/types/DeleteUserTokenOpts.java | 123 - .../resources/users/tokens/types/Device.java | 235 - .../users/tokens/types/ExpiryDate.java | 93 - .../users/tokens/types/GetUserTokenOpts.java | 123 - .../tokens/types/GetUserTokenResponse.java | 380 - .../users/tokens/types/GetUserTokensOpts.java | 101 - .../users/tokens/types/IUserToken.java | 20 - .../resources/users/tokens/types/PatchOp.java | 32 - .../users/tokens/types/PatchOperation.java | 174 - .../tokens/types/PatchUserTokenOpts.java | 102 - .../users/tokens/types/ProviderKey.java | 28 - .../users/tokens/types/PutUserTokenOpts.java | 123 - .../users/tokens/types/PutUserTokensOpts.java | 141 - .../users/tokens/types/TokenStatus.java | 28 - .../users/tokens/types/Tracking.java | 181 - .../users/tokens/types/UserToken.java | 296 - .../api/types/SendMessageResponse.java | 112 - src/test/java/com/courier/api/TestClient.java | 11 - 952 files changed, 146247 insertions(+), 57067 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json delete mode 100644 .fernignore create mode 100644 .gitattributes delete mode 100755 .publish/prepare.sh create mode 100644 .stats.yml create mode 100644 SECURITY.md delete mode 100644 build.gradle create mode 100644 build.gradle.kts create mode 100644 buildSrc/build.gradle.kts create mode 100644 buildSrc/src/main/kotlin/courier.java.gradle.kts create mode 100644 buildSrc/src/main/kotlin/courier.kotlin.gradle.kts create mode 100644 buildSrc/src/main/kotlin/courier.publish.gradle.kts create mode 100644 courier-java-client-okhttp/build.gradle.kts create mode 100644 courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt create mode 100644 courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt create mode 100644 courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/OkHttpClient.kt create mode 100644 courier-java-core/build.gradle.kts create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/BaseDeserializer.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/BaseSerializer.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/ClientOptions.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/DefaultSleeper.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/ObjectMappers.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Params.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachable.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableExecutorService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableSleeper.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/PrepareRequest.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Properties.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/RequestOptions.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Sleeper.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Timeout.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Utils.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/handlers/ErrorHandler.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/handlers/JsonHandler.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/handlers/StringHandler.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/AsyncStreamResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/Headers.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpClient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpMethod.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequest.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBodies.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBody.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponseFor.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingHttpClient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingStreamResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/QueryParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/RetryingHttpClient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/http/StreamResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/BadRequestException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/CourierException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/CourierInvalidDataException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/CourierIoException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/CourierRetryableException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/CourierServiceException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/InternalServerException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/NotFoundException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/PermissionDeniedException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/RateLimitException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/UnauthorizedException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/UnexpectedStatusCodeException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/errors/UnprocessableEntityException.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt create mode 100644 courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/TestServerExtension.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/ClientOptionsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/ObjectMappersTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/PhantomReachableTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/UtilsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/ValuesTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/http/AsyncStreamResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/http/HeadersTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/http/QueryParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/core/http/RetryingHttpClientTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageContextTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt create mode 100644 courier-java-example/build.gradle.kts create mode 100644 courier-java-lib/.keep create mode 100644 courier-java-proguard-test/build.gradle.kts create mode 100644 courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt create mode 100644 courier-java-proguard-test/test.pro create mode 100644 courier-java/build.gradle.kts delete mode 100644 sample-app/build.gradle delete mode 100644 sample-app/src/main/java/sample/App.java create mode 100755 scripts/build create mode 100755 scripts/fast-format create mode 100755 scripts/format create mode 100755 scripts/java-format create mode 100755 scripts/kotlin-format create mode 100755 scripts/lint create mode 100755 scripts/mock create mode 100755 scripts/test delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts delete mode 100644 src/main/java/com/courier/api/Courier.java delete mode 100644 src/main/java/com/courier/api/CourierBuilder.java delete mode 100644 src/main/java/com/courier/api/core/ClientOptions.java delete mode 100644 src/main/java/com/courier/api/core/CourierApiApiError.java delete mode 100644 src/main/java/com/courier/api/core/CourierApiError.java delete mode 100644 src/main/java/com/courier/api/core/DateTimeDeserializer.java delete mode 100644 src/main/java/com/courier/api/core/Environment.java delete mode 100644 src/main/java/com/courier/api/core/IdempotentRequestOptions.java delete mode 100644 src/main/java/com/courier/api/core/MediaTypes.java delete mode 100644 src/main/java/com/courier/api/core/ObjectMappers.java delete mode 100644 src/main/java/com/courier/api/core/RequestOptions.java delete mode 100644 src/main/java/com/courier/api/core/RetryInterceptor.java delete mode 100644 src/main/java/com/courier/api/core/Stream.java delete mode 100644 src/main/java/com/courier/api/core/Suppliers.java delete mode 100644 src/main/java/com/courier/api/requests/SendMessageRequest.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/AudiencesClient.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/requests/AudienceMembersListParams.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/requests/AudienceUpdateParams.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/requests/AudiencesListParams.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/Audience.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/AudienceListResponse.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/AudienceMember.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/AudienceMemberGetResponse.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/AudienceMemberListResponse.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/AudienceUpdateResponse.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/BaseFilterConfig.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/ComparisonOperator.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/Filter.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/FilterConfig.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/IBaseFilterConfig.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/LogicalOperator.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/NestedFilterConfig.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/Operator.java delete mode 100644 src/main/java/com/courier/api/resources/audiences/types/SingleFilterConfig.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/AuditEventsClient.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/requests/ListAuditEventsRequest.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/types/Actor.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/types/AuditEvent.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/types/GetAuditEventParams.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsParams.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsResponse.java delete mode 100644 src/main/java/com/courier/api/resources/auditevents/types/Target.java delete mode 100644 src/main/java/com/courier/api/resources/authtokens/AuthTokensClient.java delete mode 100644 src/main/java/com/courier/api/resources/authtokens/requests/IssueTokenParams.java delete mode 100644 src/main/java/com/courier/api/resources/authtokens/types/IssueTokenResponse.java delete mode 100644 src/main/java/com/courier/api/resources/automations/AutomationsClient.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AccessorType.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/Automation.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAdHocInvokeParams.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchMaxItemsType.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetain.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetainType.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchScope.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationAddToDigestStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationCancelStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationDelayStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhook.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhookMethod.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationInvokeParams.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationInvokeResponse.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationInvokeStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationInvokeTemplateParams.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationRunContext.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationSendListStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationSendStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationStepOption.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationThrottleOnThrottle.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationThrottleScope.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationThrottleStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationUpdateProfileStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/AutomationV2SendStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/IAutomationInvokeParams.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/IAutomationStep.java delete mode 100644 src/main/java/com/courier/api/resources/automations/types/MergeAlgorithm.java delete mode 100644 src/main/java/com/courier/api/resources/brands/BrandsClient.java delete mode 100644 src/main/java/com/courier/api/resources/brands/requests/BrandUpdateParameters.java delete mode 100644 src/main/java/com/courier/api/resources/brands/requests/ListBrandsRequest.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/Brand.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandColors.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandGetAllResponse.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandParameters.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandSettings.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandSnippet.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandSnippets.java delete mode 100644 src/main/java/com/courier/api/resources/brands/types/BrandsResponse.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/BulkClient.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/requests/BulkCreateJobParams.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/requests/BulkGetUsersParams.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkCreateJobResponse.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkGetJobParams.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkGetJobResponse.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersParams.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersResponse.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkIngestError.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersParams.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersResponse.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkJobStatus.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkJobUserStatus.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/BulkMessageUserResponse.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageUser.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageV1.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/InboundBulkContentMessage.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessage.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageUser.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV1.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV2.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/InboundBulkTemplateMessage.java delete mode 100644 src/main/java/com/courier/api/resources/bulk/types/JobDetails.java delete mode 100644 src/main/java/com/courier/api/resources/commons/errors/CourierApiAlreadyExistsError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/errors/CourierApiBadRequestError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/errors/CourierApiConflictError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/errors/CourierApiMessageNotFoundError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/errors/CourierApiNotFoundError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/errors/CourierApiPaymentRequiredError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/AlreadyExists.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/BadRequest.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/BaseError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/BaseTemplateTenantAssociation.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/ChannelClassification.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/ChannelPreference.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/Conflict.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/Email.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/IBaseError.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/IBaseTemplateTenantAssociation.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/ISingleTemplateTenantAssociation.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/ListTemplateTenantAssociation.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/MessageNotFound.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/NotFound.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/NotificationPreferenceDetails.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/Paging.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/PaymentRequired.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/PreferenceStatus.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/RecipientPreferences.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/Rule.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/SingleTemplateTenantAssociation.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/TenantTemplateData.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/TenantTemplateDataNoContent.java delete mode 100644 src/main/java/com/courier/api/resources/commons/types/UserTenantAssociation.java delete mode 100644 src/main/java/com/courier/api/resources/inbound/InboundClient.java delete mode 100644 src/main/java/com/courier/api/resources/inbound/types/InboundTrackEvent.java delete mode 100644 src/main/java/com/courier/api/resources/inbound/types/TrackAcceptedResponse.java delete mode 100644 src/main/java/com/courier/api/resources/lists/ListsClient.java delete mode 100644 src/main/java/com/courier/api/resources/lists/requests/AddSubscribersToList.java delete mode 100644 src/main/java/com/courier/api/resources/lists/requests/GetAllListsRequest.java delete mode 100644 src/main/java/com/courier/api/resources/lists/requests/GetSubscriptionForListRequest.java delete mode 100644 src/main/java/com/courier/api/resources/lists/requests/RestoreListRequest.java delete mode 100644 src/main/java/com/courier/api/resources/lists/requests/SubscribeUserToListRequest.java delete mode 100644 src/main/java/com/courier/api/resources/lists/requests/SubscribeUsersToListRequest.java delete mode 100644 src/main/java/com/courier/api/resources/lists/types/List.java delete mode 100644 src/main/java/com/courier/api/resources/lists/types/ListGetAllResponse.java delete mode 100644 src/main/java/com/courier/api/resources/lists/types/ListGetSubscriptionsResponse.java delete mode 100644 src/main/java/com/courier/api/resources/lists/types/ListPutParams.java delete mode 100644 src/main/java/com/courier/api/resources/lists/types/ListSubscriptionRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/lists/types/PutSubscriptionsRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/messages/MessagesClient.java delete mode 100644 src/main/java/com/courier/api/resources/messages/requests/GetMessageHistoryRequest.java delete mode 100644 src/main/java/com/courier/api/resources/messages/requests/ListMessagesRequest.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/IMessageDetails.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/ListMessagesResponse.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/MessageDetails.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/MessageDetailsExtended.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/MessageHistoryResponse.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/MessageStatus.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/Reason.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/RenderOutput.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/RenderOutputResponse.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/RenderedMessageBlock.java delete mode 100644 src/main/java/com/courier/api/resources/messages/types/RenderedMessageContent.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/NotificationsClient.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/requests/NotificationListParams.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/requests/SubmissionChecksReplaceParams.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/BaseCheck.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/BlockType.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/Check.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/CheckStatus.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/IBaseCheck.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/MessageRouting.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/MessageRoutingChannel.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/MessageRoutingMethod.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/Notification.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationBlock.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationChannel.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationChannelContent.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationContent.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationContentHierarchy.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationGetContentResponse.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationListResponse.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationTag.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/NotificationTagData.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksGetResponse.java delete mode 100644 src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksReplaceResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/ProfilesClient.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/requests/GetListSubscriptionsRequest.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/requests/MergeProfileRequest.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/requests/ReplaceProfileRequest.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Address.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/AirshipProfile.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/AirshipProfileAudience.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/DeleteListSubscriptionResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Discord.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Expo.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsList.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/IMsTeamsBaseProperties.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/ISlackBaseProperties.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Intercom.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/IntercomRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/MergeProfileResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/MsTeams.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/MsTeamsBaseProperties.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/MultipleTokens.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Pagerduty.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/ProfileGetParameters.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/ProfileGetResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/ProfileUpdateRequest.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/ReplaceProfileResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendDirectMessage.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToChannel.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelId.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelName.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsConversationId.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsEmail.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsUserId.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToSlackChannel.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToSlackEmail.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SendToSlackUserId.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Slack.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SlackBaseProperties.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SnoozeRule.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SnoozeRuleType.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequest.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequestListObject.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsResponse.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/Token.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/UserProfile.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/UserProfileFirebaseToken.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/UserProfilePatch.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/WebhookAuthMode.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/WebhookAuthentication.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/WebhookMethod.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/WebhookProfile.java delete mode 100644 src/main/java/com/courier/api/resources/profiles/types/WebhookProfileType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/AudienceFilter.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/AudienceRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BaseMessage.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BaseMessageSendTo.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BaseSocialPresence.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BrandSettingsEmail.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BrandSettingsInApp.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BrandSettingsSocialPresence.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BrandTemplate.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/BrandTemplateOverride.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Channel.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ChannelMetadata.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ChannelSource.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Content.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ContentMessage.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Criteria.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Delay.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalActionNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalBaseNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalChannelNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalContent.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalContentSugar.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalDividerNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalGroupNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalImageNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalMetaNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalQuoteNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ElementalTextNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/EmailFooter.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/EmailHead.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/EmailHeader.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ExpiresInType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Expiry.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IActionButtonStyle.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IAlignment.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IBaseMessage.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IBaseMessageSendTo.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IBrandTemplate.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IElementalBaseNode.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IListPatternRecipientType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IListRecipientType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IProfilePreferences.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/IUserRecipientType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Icons.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/InAppPlacement.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/InvalidListPatternRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/InvalidListRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/InvalidUserRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ListFilter.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ListPatternRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ListPatternRecipientType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ListRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/ListRecipientType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Locale.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Logo.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Message.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/MessageContext.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/MessageMetadata.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/MessagePreferences.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/MessageProvidersType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/MessageRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Metadata.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/MsTeamsRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/PagerdutyRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Preference.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Preferences.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Recipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Routing.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/RoutingMethod.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/RuleType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/SlackRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/TemplateMessage.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/TextAlign.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/TextStyle.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Timeout.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Timeouts.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/TrackingOverride.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/UserRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/UserRecipientType.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/Utm.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/WebhookRecipient.java delete mode 100644 src/main/java/com/courier/api/resources/send/types/WidgetBackground.java delete mode 100644 src/main/java/com/courier/api/resources/templates/TemplatesClient.java delete mode 100644 src/main/java/com/courier/api/resources/templates/requests/ListTemplatesRequest.java delete mode 100644 src/main/java/com/courier/api/resources/templates/types/ListTemplatesResponse.java delete mode 100644 src/main/java/com/courier/api/resources/templates/types/NotificationTemplates.java delete mode 100644 src/main/java/com/courier/api/resources/templates/types/RoutingStrategy.java delete mode 100644 src/main/java/com/courier/api/resources/templates/types/RoutingStrategyMethod.java delete mode 100644 src/main/java/com/courier/api/resources/templates/types/Tag.java delete mode 100644 src/main/java/com/courier/api/resources/templates/types/TagData.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/TenantsClient.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/requests/GetTemplateListByTenantParams.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/requests/ListTenantParams.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/requests/ListUsersForTenantParams.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/requests/TenantCreateOrReplaceParams.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/DefaultPreferences.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/GetTemplateByTenantResponse.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/ISubscriptionTopicNew.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/ListTemplatesByTenantResponse.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/ListUsersForTenantResponse.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopic.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicNew.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicStatus.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/Tenant.java delete mode 100644 src/main/java/com/courier/api/resources/tenants/types/TenantListResponse.java delete mode 100644 src/main/java/com/courier/api/resources/translations/TranslationsClient.java delete mode 100644 src/main/java/com/courier/api/resources/users/UsersClient.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/PreferencesClient.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesParams.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesTopicParams.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesUpdateParams.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/types/TopicPreference.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/types/TopicPreferenceUpdate.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesGetResponse.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesListResponse.java delete mode 100644 src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesUpdateResponse.java delete mode 100644 src/main/java/com/courier/api/resources/users/tenants/TenantsClient.java delete mode 100644 src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToMultipleTenantsParams.java delete mode 100644 src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToSingleTenantsParams.java delete mode 100644 src/main/java/com/courier/api/resources/users/tenants/requests/ListTenantsForUserParams.java delete mode 100644 src/main/java/com/courier/api/resources/users/tenants/types/AddUserToSingleTenantsParamsProfile.java delete mode 100644 src/main/java/com/courier/api/resources/users/tenants/types/ListTenantsForUserResponse.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/TokensClient.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/DeleteUserTokenOpts.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/Device.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/ExpiryDate.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenOpts.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenResponse.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokensOpts.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/IUserToken.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/PatchOp.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/PatchOperation.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/PatchUserTokenOpts.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/ProviderKey.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokenOpts.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokensOpts.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/TokenStatus.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/Tracking.java delete mode 100644 src/main/java/com/courier/api/resources/users/tokens/types/UserToken.java delete mode 100644 src/main/java/com/courier/api/types/SendMessageResponse.java delete mode 100644 src/test/java/com/courier/api/TestClient.java diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..bd8e2619 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1 +FROM debian:bookworm-slim + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libxkbcommon0 \ + ca-certificates \ + ca-certificates-java \ + make \ + curl \ + git \ + openjdk-17-jdk-headless \ + unzip \ + libc++1 \ + vim \ + && apt-get clean autoclean + +# Ensure UTF-8 encoding +ENV LANG=C.UTF-8 +ENV LC_ALL=C.UTF-8 + +WORKDIR /workspace + +COPY . /workspace diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..d55fc4d6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/debian +{ + "name": "Debian", + "build": { + "dockerfile": "Dockerfile" + } + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.fernignore b/.fernignore deleted file mode 100644 index 793636f0..00000000 --- a/.fernignore +++ /dev/null @@ -1,4 +0,0 @@ -# Specify files that shouldn't be modified by Fern - -LICENSE -README.md diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..022b8414 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# +# https://help.github.com/articles/dealing-with-line-endings/ +# +# These are explicitly windows files and should use crlf +*.bat text eol=crlf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e52af1f..f668ddf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,65 +1,85 @@ -name: ci - -on: [push] +name: CI +on: + push: + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'stl-preview-head/**' + - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: - compile: - runs-on: ubuntu-latest + lint: + timeout-minutes: 15 + name: lint + runs-on: ${{ github.repository == 'stainless-sdks/courier-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Java - id: setup-jre - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: "11" - architecture: x64 + distribution: temurin + java-version: | + 8 + 21 + cache: gradle - - name: Compile - run: ./gradlew compileJava + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Run lints + run: ./scripts/lint + + build: + timeout-minutes: 15 + name: build + runs-on: ${{ github.repository == 'stainless-sdks/courier-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork - test: - needs: [ compile ] - runs-on: ubuntu-latest steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Java - id: setup-jre - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: "11" - architecture: x64 + distribution: temurin + java-version: | + 8 + 21 + cache: gradle - - name: Test - run: ./gradlew test - publish: - needs: [ compile, test ] - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-latest + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v4 + - name: Build SDK + run: ./scripts/build + + test: + timeout-minutes: 15 + name: test + runs-on: ${{ github.repository == 'stainless-sdks/courier-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - name: Checkout repo - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Java - id: setup-jre - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: "11" - architecture: x64 + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 - - name: Publish to maven - run: | - ./.publish/prepare.sh - ./gradlew publish - env: - MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - MAVEN_PUBLISH_REGISTRY_URL: "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }} - MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }} - MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }} + - name: Run tests + run: ./scripts/test diff --git a/.gitignore b/.gitignore index d4199abc..b1346e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1,7 @@ -*.class -.project +.prism.log .gradle -? -.classpath -.checkstyle -.settings -.node -build - -# IntelliJ -*.iml -*.ipr -*.iws -.idea/ -out/ - -# Eclipse/IntelliJ APT -generated_src/ -generated_testSrc/ -generated/ - -bin -build \ No newline at end of file +.idea +.kotlin +build/ +codegen.log +kls_database.db diff --git a/.publish/prepare.sh b/.publish/prepare.sh deleted file mode 100755 index df3948e3..00000000 --- a/.publish/prepare.sh +++ /dev/null @@ -1,8 +0,0 @@ -# Write key ring file -echo "$MAVEN_SIGNATURE_SECRET_KEY" > armored_key.asc -gpg -o publish_key.gpg --dearmor armored_key.asc - -# Generate gradle.properties file -echo "signing.keyId=$MAVEN_SIGNATURE_KID" > gradle.properties -echo "signing.secretKeyRingFile=publish_key.gpg" >> gradle.properties -echo "signing.password=$MAVEN_SIGNATURE_PASSWORD" >> gradle.properties diff --git a/.stats.yml b/.stats.yml new file mode 100644 index 00000000..a30affc9 --- /dev/null +++ b/.stats.yml @@ -0,0 +1,4 @@ +configured_endpoints: 75 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml +openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 +config_hash: cdd0e8b97754393a5262fb5e52e2ddcf diff --git a/LICENSE b/LICENSE index d82d2ea7..efaa7fe8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,201 @@ -MIT License - -Copyright (c) 2020 Courier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2025 Courier + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 60ee7d22..cb8be759 100644 --- a/README.md +++ b/README.md @@ -1,149 +1,653 @@ -# Courier Java Library +# Courier Java API Library -[![Maven Central](https://img.shields.io/maven-central/v/com.courier/courier-java)](https://central.sonatype.com/artifact/com.courier/courier-java) -[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://buildwithfern.com/?utm_source=trycourier/courier-java/readme) +[![Maven Central](https://img.shields.io/maven-central/v/com.courier.api/courier-java)](https://central.sonatype.com/artifact/com.courier.api/courier-java/0.0.1) +[![javadoc](https://javadoc.io/badge2/com.courier.api/courier-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.courier.api/courier-java/0.0.1) -This is the official Java library for sending notifications with the [Courier](https://courier.com) REST API. +The Courier Java SDK provides convenient access to the Courier REST API from applications written in Java. -## Documentation +It is generated with [Stainless](https://www.stainless.com/). -For a full description of request and response payloads and properties, please see the -[official Courier API docs](https://www.courier.com/docs/reference/). - -## Requirements - -This library requires Java 11+. +Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.courier.api/courier-java/0.0.1). ## Installation ### Gradle -Add the dependency in your `build.gradle`: - -```groovy -dependencies { - implementation 'com.courier:courier-java:x.x.x' -} +```kotlin +implementation("com.courier.api:courier-java:0.0.1") ``` ### Maven -Add the dependency in your `pom.xml`: - ```xml - com.courier - courier-java - 0.x.x + com.courier.api + courier-java + 0.0.1 ``` +## Requirements + +This library requires Java 8 or later. + ## Usage -Below is an example of how to instantiate the Courier client -and send a message. ```java -import com.courier.api.Courier; +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; +import com.courier.api.models.send.Content; +import com.courier.api.models.send.ElementalNode; +import com.courier.api.models.send.Message; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; + +// Configures using the `courier.apiKey` and `courier.baseUrl` system properties +// Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables +CourierClient client = CourierOkHttpClient.fromEnv(); + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(Message.ContentMessage.builder() + .content(Content.ElementalContent.builder() + .addElement(ElementalNode.UnionMember0.builder().build()) + .version("version") + .build()) + .build()) + .build(); +SendSendMessageResponse response = client.send().sendMessage(params); +``` + +## Client configuration + +Configure the client using system properties or environment variables: -Courier courier = Courier.builder() - .authorizationToken("YOUR_TOKEN") # Defaults to System.getenv("COURIER_AUTHORIZATION_TOKEN") +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; + +// Configures using the `courier.apiKey` and `courier.baseUrl` system properties +// Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables +CourierClient client = CourierOkHttpClient.fromEnv(); +``` + +Or manually: + +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; + +CourierClient client = CourierOkHttpClient.builder() + .apiKey("My API Key") .build(); +``` + +Or using a combination of the two approaches: -courier.send(SendMessageRequest.builder() - .message(Message.of(TemplateMessage.builder() - .template("") - .to(MessageRecipient.of(Recipient.of(UserRecipient.builder() - .email("marty_mcfly@email.com") - .build()))) - .build())) - .build()); +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; + +CourierClient client = CourierOkHttpClient.builder() + // Configures using the `courier.apiKey` and `courier.baseUrl` system properties + // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables + .fromEnv() + .apiKey("My API Key") + .build(); ``` -## Upgrade Guides +See this table for the available options: + +| Setter | System property | Environment variable | Required | Default value | +| --------- | ----------------- | -------------------- | -------- | --------------------------- | +| `apiKey` | `courier.apiKey` | `COURIER_API_KEY` | true | - | +| `baseUrl` | `courier.baseUrl` | `COURIER_BASE_URL` | true | `"https://api.courier.com"` | -### v2 to v3 +System properties take precedence over environment variables. -v3 of our SDK is automatically generated by [Fern](https://buildwithfern.com/). v3 comes -with several improvements that we describe below: +> [!TIP] +> Don't create more than one client in the same application. Each client has a connection pool and +> thread pools, which are more efficient to share between requests. -- **Resource-scoped SDK methods**: Endpoints are scoped under their resource. For - example, instead of `courier.deleteBrands` the SDK now reads `courier.brands.delete(...)` -- **Docs on Hover**: All endpoint and parameter level documentation that you see - on our docs website is now embedded directly within the SDKs. -- **Retries with exponential backoff**: The SDK will automatically retry failures with - exponential backoff. -- **Strongly Typed**: The SDK has Java objects to describe each of our request and - response models. Each object has a static `builder` method and uses the staged - builder pattern. - ```java - UserRecipient.builder() - .email("marty_mcfly@email.com") - .build(); - ``` -- **Unions** The SDK has natively supports unions. Every union is modelled as a java - class that has static factory methods. - ```java - // Message has static factory methods that either take a TemplateMessage or - // ContentMessage - Message.of(TemplateMessage.builder()...) - - Message.of(ContentMessage.builder()...) - ``` +### Modifying configuration -## Request Options -Every endpoint has an overloaded equivalent which takes [RequestOptions](./src/main/java/com/courier/api/core/RequestOptions.java) -that allow you to override settings for that particular request. +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: ```java -import com.courier.api.Courier; +import com.courier.api.client.CourierClient; -courier.brands.get(..., RequestOptions.builder() - .authorizationToken(...) - .build()) +CourierClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); ``` -## Idempotency Headers -You can specify idempotency headers by providing an `IdempotentRequestOptions` parameter. +The `withOptions()` method does not affect the original client or service. + +## Requests and responses + +To send a request to the Courier API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. + +For example, `client.send().sendMessage(...)` should be called with an instance of `SendSendMessageParams`, and it will return an instance of `SendSendMessageResponse`. + +## Immutability + +Each class in the SDK has an associated [builder](https://blogs.oracle.com/javamagazine/post/exploring-joshua-blochs-builder-design-pattern-in-java) or factory method for constructing it. + +Each class is [immutable](https://docs.oracle.com/javase/tutorial/essential/concurrency/immutable.html) once constructed. If the class has an associated builder, then it has a `toBuilder()` method, which can be used to convert it back to a builder for making a modified copy. + +Because each class is immutable, builder modification will _never_ affect already built class instances. + +## Asynchronous execution + +The default client is synchronous. To switch to asynchronous execution, call the `async()` method: + +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; +import com.courier.api.models.send.Content; +import com.courier.api.models.send.ElementalNode; +import com.courier.api.models.send.Message; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; +import java.util.concurrent.CompletableFuture; + +// Configures using the `courier.apiKey` and `courier.baseUrl` system properties +// Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables +CourierClient client = CourierOkHttpClient.fromEnv(); + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(Message.ContentMessage.builder() + .content(Content.ElementalContent.builder() + .addElement(ElementalNode.UnionMember0.builder().build()) + .version("version") + .build()) + .build()) + .build(); +CompletableFuture response = client.async().send().sendMessage(params); +``` + +Or create an asynchronous client from the beginning: + +```java +import com.courier.api.client.CourierClientAsync; +import com.courier.api.client.okhttp.CourierOkHttpClientAsync; +import com.courier.api.models.send.Content; +import com.courier.api.models.send.ElementalNode; +import com.courier.api.models.send.Message; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; +import java.util.concurrent.CompletableFuture; + +// Configures using the `courier.apiKey` and `courier.baseUrl` system properties +// Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables +CourierClientAsync client = CourierOkHttpClientAsync.fromEnv(); + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(Message.ContentMessage.builder() + .content(Content.ElementalContent.builder() + .addElement(ElementalNode.UnionMember0.builder().build()) + .version("version") + .build()) + .build()) + .build(); +CompletableFuture response = client.send().sendMessage(params); +``` + +The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. + +## Raw responses + +The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don't provide access to the response headers, status code, or the raw response body. + +To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java -import com.courier.api.Courier; -import java.util.UUID; +import com.courier.api.core.http.Headers; +import com.courier.api.core.http.HttpResponseFor; +import com.courier.api.models.send.Content; +import com.courier.api.models.send.ElementalNode; +import com.courier.api.models.send.Message; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(Message.ContentMessage.builder() + .content(Content.ElementalContent.builder() + .addElement(ElementalNode.UnionMember0.builder().build()) + .version("version") + .build()) + .build()) + .build(); +HttpResponseFor response = client.send().withRawResponse().sendMessage(params); -courier.send(..., IdempotentRequestOptions.builder() - .idempotencyKey(UUID.randomUUID().toString()) - .build()) +int statusCode = response.statusCode(); +Headers headers = response.headers(); ``` -## Exception Handling -All errors thrown by the SDK will be subclasses of `com.courier.api.APIError`. +You can still deserialize the response into an instance of a Java class if needed: ```java -import com.courier.api.core.ApiError; +import com.courier.api.models.send.SendSendMessageResponse; -try { - courier.brands.get(...) -} catch (ApiError e) { - System.out.println(e.statusCode()); - System.out.println(e.body()); +SendSendMessageResponse parsedResponse = response.parse(); +``` + +## Error handling + +The SDK throws custom unchecked exception types: + +- [`CourierServiceException`](courier-java-core/src/main/kotlin/com/courier/api/errors/CourierServiceException.kt): Base class for HTTP errors. See this table for which exception subclass is thrown for each HTTP status code: + + | Status | Exception | + | ------ | ---------------------------------------------------------------------------------------------------------------------------- | + | 400 | [`BadRequestException`](courier-java-core/src/main/kotlin/com/courier/api/errors/BadRequestException.kt) | + | 401 | [`UnauthorizedException`](courier-java-core/src/main/kotlin/com/courier/api/errors/UnauthorizedException.kt) | + | 403 | [`PermissionDeniedException`](courier-java-core/src/main/kotlin/com/courier/api/errors/PermissionDeniedException.kt) | + | 404 | [`NotFoundException`](courier-java-core/src/main/kotlin/com/courier/api/errors/NotFoundException.kt) | + | 422 | [`UnprocessableEntityException`](courier-java-core/src/main/kotlin/com/courier/api/errors/UnprocessableEntityException.kt) | + | 429 | [`RateLimitException`](courier-java-core/src/main/kotlin/com/courier/api/errors/RateLimitException.kt) | + | 5xx | [`InternalServerException`](courier-java-core/src/main/kotlin/com/courier/api/errors/InternalServerException.kt) | + | others | [`UnexpectedStatusCodeException`](courier-java-core/src/main/kotlin/com/courier/api/errors/UnexpectedStatusCodeException.kt) | + +- [`CourierIoException`](courier-java-core/src/main/kotlin/com/courier/api/errors/CourierIoException.kt): I/O networking errors. + +- [`CourierRetryableException`](courier-java-core/src/main/kotlin/com/courier/api/errors/CourierRetryableException.kt): Generic error indicating a failure that could be retried by the client. + +- [`CourierInvalidDataException`](courier-java-core/src/main/kotlin/com/courier/api/errors/CourierInvalidDataException.kt): Failure to interpret successfully parsed data. For example, when accessing a property that's supposed to be required, but the API unexpectedly omitted it from the response. + +- [`CourierException`](courier-java-core/src/main/kotlin/com/courier/api/errors/CourierException.kt): Base class for all exceptions. Most errors will result in one of the previously mentioned ones, but completely generic errors may be thrown using the base class. + +## Logging + +The SDK uses the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor). + +Enable logging by setting the `COURIER_LOG` environment variable to `info`: + +```sh +$ export COURIER_LOG=info +``` + +Or to `debug` for more verbose logging: + +```sh +$ export COURIER_LOG=debug +``` + +## ProGuard and R8 + +Although the SDK uses reflection, it is still usable with [ProGuard](https://github.com/Guardsquare/proguard) and [R8](https://developer.android.com/topic/performance/app-optimization/enable-app-optimization) because `courier-java-core` is published with a [configuration file](courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro) containing [keep rules](https://www.guardsquare.com/manual/configuration/usage). + +ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary. + +## Jackson + +The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. + +The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config). + +If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`CourierOkHttpClient`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt) or [`CourierOkHttpClientAsync`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt). + +> [!CAUTION] +> We make no guarantee that the SDK works correctly when the Jackson version check is disabled. + +## Network options + +### Retries + +The SDK automatically retries 2 times by default, with a short exponential backoff between requests. + +Only the following error types are retried: + +- Connection errors (for example, due to a network connectivity problem) +- 408 Request Timeout +- 409 Conflict +- 429 Rate Limit +- 5xx Internal + +The API may also explicitly instruct the SDK to retry or not retry a request. + +To set a custom number of retries, configure the client using the `maxRetries` method: + +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; + +CourierClient client = CourierOkHttpClient.builder() + .fromEnv() + .maxRetries(4) + .build(); +``` + +### Timeouts + +Requests time out after 1 minute by default. + +To set a custom timeout, configure the method call using the `timeout` method: + +```java +import com.courier.api.models.send.SendSendMessageResponse; + +SendSendMessageResponse response = client.send().sendMessage( + params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() +); +``` + +Or configure the default for all method calls at the client level: + +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; +import java.time.Duration; + +CourierClient client = CourierOkHttpClient.builder() + .fromEnv() + .timeout(Duration.ofSeconds(30)) + .build(); +``` + +### Proxies + +To route requests through a proxy, configure the client using the `proxy` method: + +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; +import java.net.InetSocketAddress; +import java.net.Proxy; + +CourierClient client = CourierOkHttpClient.builder() + .fromEnv() + .proxy(new Proxy( + Proxy.Type.HTTP, new InetSocketAddress( + "https://example.com", 8080 + ) + )) + .build(); +``` + +### HTTPS + +> [!NOTE] +> Most applications should not call these methods, and instead use the system defaults. The defaults include +> special optimizations that can be lost if the implementations are modified. + +To configure how HTTPS connections are secured, configure the client using the `sslSocketFactory`, `trustManager`, and `hostnameVerifier` methods: + +```java +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; + +CourierClient client = CourierOkHttpClient.builder() + .fromEnv() + // If `sslSocketFactory` is set, then `trustManager` must be set, and vice versa. + .sslSocketFactory(yourSSLSocketFactory) + .trustManager(yourTrustManager) + .hostnameVerifier(yourHostnameVerifier) + .build(); +``` + +### Custom HTTP client + +The SDK consists of three artifacts: + +- `courier-java-core` + - Contains core SDK logic + - Does not depend on [OkHttp](https://square.github.io/okhttp) + - Exposes [`CourierClient`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt), [`CourierClientAsync`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt), [`CourierClientImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt), and [`CourierClientAsyncImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt), all of which can work with any HTTP client +- `courier-java-client-okhttp` + - Depends on [OkHttp](https://square.github.io/okhttp) + - Exposes [`CourierOkHttpClient`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt) and [`CourierOkHttpClientAsync`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt), which provide a way to construct [`CourierClientImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt) and [`CourierClientAsyncImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt), respectively, using OkHttp +- `courier-java` + - Depends on and exposes the APIs of both `courier-java-core` and `courier-java-client-okhttp` + - Does not have its own logic + +This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies. + +#### Customized [`OkHttpClient`](https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.html) + +> [!TIP] +> Try the available [network options](#network-options) before replacing the default client. + +To use a customized `OkHttpClient`: + +1. Replace your [`courier-java` dependency](#installation) with `courier-java-core` +2. Copy `courier-java-client-okhttp`'s [`OkHttpClient`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/OkHttpClient.kt) class into your code and customize it +3. Construct [`CourierClientImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt) or [`CourierClientAsyncImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt), similarly to [`CourierOkHttpClient`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt) or [`CourierOkHttpClientAsync`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt), using your customized client + +### Completely custom HTTP client + +To use a completely custom HTTP client: + +1. Replace your [`courier-java` dependency](#installation) with `courier-java-core` +2. Write a class that implements the [`HttpClient`](courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpClient.kt) interface +3. Construct [`CourierClientImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt) or [`CourierClientAsyncImpl`](courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt), similarly to [`CourierOkHttpClient`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt) or [`CourierOkHttpClientAsync`](courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt), using your new client class + +## Undocumented API functionality + +The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API. + +### Parameters + +To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQueryParam`, or `putAdditionalBodyProperty` methods on any `Params` class: + +```java +import com.courier.api.core.JsonValue; +import com.courier.api.models.send.SendSendMessageParams; + +SendSendMessageParams params = SendSendMessageParams.builder() + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build(); +``` + +These can be accessed on the built object later using the `_additionalHeaders()`, `_additionalQueryParams()`, and `_additionalBodyProperties()` methods. + +To set undocumented parameters on _nested_ headers, query params, or body classes, call the `putAdditionalProperty` method on the nested class: + +```java +import com.courier.api.core.JsonValue; +import com.courier.api.models.automations.AutomationInvokeAdHocParams; + +AutomationInvokeAdHocParams params = AutomationInvokeAdHocParams.builder() + .automation(AutomationInvokeAdHocParams.Automation.builder() + .putAdditionalProperty("secretProperty", JsonValue.from("42")) + .build()) + .build(); +``` + +These properties can be accessed on the nested built object later using the `_additionalProperties()` method. + +To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt) object to its setter: + +```java +import com.courier.api.core.JsonValue; +import com.courier.api.models.send.SendSendMessageParams; + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(JsonValue.from(42)) + .build(); +``` + +The most straightforward way to create a [`JsonValue`](courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt) is using its `from(...)` method: + +```java +import com.courier.api.core.JsonValue; +import java.util.List; +import java.util.Map; + +// Create primitive JSON values +JsonValue nullValue = JsonValue.from(null); +JsonValue booleanValue = JsonValue.from(true); +JsonValue numberValue = JsonValue.from(42); +JsonValue stringValue = JsonValue.from("Hello World!"); + +// Create a JSON array value equivalent to `["Hello", "World"]` +JsonValue arrayValue = JsonValue.from(List.of( + "Hello", "World" +)); + +// Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` +JsonValue objectValue = JsonValue.from(Map.of( + "a", 1, + "b", 2 +)); + +// Create an arbitrarily nested JSON equivalent to: +// { +// "a": [1, 2], +// "b": [3, 4] +// } +JsonValue complexValue = JsonValue.from(Map.of( + "a", List.of( + 1, 2 + ), + "b", List.of( + 3, 4 + ) +)); +``` + +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. + +To forcibly omit a required parameter or property, pass [`JsonMissing`](courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt): + +```java +import com.courier.api.core.JsonMissing; +import com.courier.api.models.send.SendSendMessageParams; + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(JsonMissing.of()) + .build(); +``` + +### Response properties + +To access undocumented response properties, call the `_additionalProperties()` method: + +```java +import com.courier.api.core.JsonValue; +import java.util.Map; + +Map additionalProperties = client.send().sendMessage(params)._additionalProperties(); +JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); + +String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { + @Override + public String visitNull() { + return "It's null!"; + } + + @Override + public String visitBoolean(boolean value) { + return "It's a boolean!"; + } + + @Override + public String visitNumber(Number value) { + return "It's a number!"; + } + + // Other methods include `visitMissing`, `visitString`, `visitArray`, and `visitObject` + // The default implementation of each unimplemented method delegates to `visitDefault`, which throws by default, but can also be overridden +}); +``` + +To access a property's raw JSON value, which may be undocumented, call its `_` prefixed method: + +```java +import com.courier.api.core.JsonField; +import com.courier.api.models.send.Message; +import java.util.Optional; + +JsonField message = client.send().sendMessage(params)._message(); + +if (message.isMissing()) { + // The property is absent from the JSON response +} else if (message.isNull()) { + // The property was set to literal null +} else { + // Check if value was provided as a string + // Other methods include `asNumber()`, `asBoolean()`, etc. + Optional jsonString = message.asString(); + + // Try to deserialize into a custom type + MyClass myObject = message.asUnknown().orElseThrow().convert(MyClass.class); } ``` -## Retries -409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried twice -with exponential backoff. +### Response validation + +In rare cases, the API may return a response that doesn't match the expected type. For example, the SDK may expect a property to contain a `String`, but the API could return something else. + +By default, the SDK will not throw an exception in this case. It will throw [`CourierInvalidDataException`](courier-java-core/src/main/kotlin/com/courier/api/errors/CourierInvalidDataException.kt) only if you directly access the property. + +If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: + +```java +import com.courier.api.models.send.SendSendMessageResponse; + +SendSendMessageResponse response = client.send().sendMessage(params).validate(); +``` + +Or configure the method call to validate the response using the `responseValidation` method: + +```java +import com.courier.api.models.send.SendSendMessageResponse; + +SendSendMessageResponse response = client.send().sendMessage( + params, RequestOptions.builder().responseValidation(true).build() +); +``` -## Additional Properties -Sometimes, the server response may include additional properties that are not -available in the SDK. Use the `getAdditionalProperties()` method to access them. +Or configure the default for all method calls at the client level: ```java -Object value = entity.getAdditionalProperties().get("new_prop"); +import com.courier.api.client.CourierClient; +import com.courier.api.client.okhttp.CourierOkHttpClient; + +CourierClient client = CourierOkHttpClient.builder() + .fromEnv() + .responseValidation(true) + .build(); ``` -## Contributing -While we value open-source contributions to this SDK, this library is generated programmatically. -Additions made directly to this library would have to be moved over to our generation code, otherwise -they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, -but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us! +## FAQ + +### Why don't you use plain `enum` classes? + +Java `enum` classes are not trivially [forwards compatible](https://www.stainless.com/blog/making-java-enums-forwards-compatible). Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value. + +### Why do you represent fields using `JsonField` instead of just plain `T`? + +Using `JsonField` enables a few features: + +- Allowing usage of [undocumented API functionality](#undocumented-api-functionality) +- Lazily [validating the API response against the expected shape](#response-validation) +- Representing absent vs explicitly null values + +### Why don't you use [`data` classes](https://kotlinlang.org/docs/data-classes.html)? + +It is not [backwards compatible to add new fields to a data class](https://kotlinlang.org/docs/api-guidelines-backward-compatibility.html#avoid-using-data-classes-in-your-api) and we don't want to introduce a breaking change every time we add a field to a class. + +### Why don't you use checked exceptions? + +Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. + +Checked exceptions: + +- Are verbose to handle +- Encourage error handling at the wrong level of abstraction, where nothing can be done about the error +- Are tedious to propagate due to the [function coloring problem](https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function) +- Don't play well with lambdas (also due to the function coloring problem) + +## Semantic versioning + +This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: + +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ +2. Changes that we do not expect to impact the vast majority of users in practice. + +We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -On the other hand, contributions to the README are always very welcome! \ No newline at end of file +We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/courier-java/issues) with questions, bugs, or suggestions. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..e8a2e774 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,23 @@ +# Security Policy + +## Reporting Security Issues + +This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken. + +To report a security issue, please contact the Stainless team at security@stainless.com. + +## Responsible Disclosure + +We appreciate the efforts of security researchers and individuals who help us maintain the security of +SDKs we generate. If you believe you have found a security vulnerability, please adhere to responsible +disclosure practices by allowing us a reasonable amount of time to investigate and address the issue +before making any information public. + +## Reporting Non-SDK Related Security Issues + +If you encounter security issues that are not directly related to SDKs but pertain to the services +or products provided by Courier, please follow the respective company's security reporting guidelines. + +--- + +Thank you for helping us keep the SDKs and systems they interact with secure. diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 2154b2e1..00000000 --- a/build.gradle +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id 'java-library' - id 'maven-publish' - id 'com.diffplug.spotless' version '6.11.0' - id 'signing' -} - -repositories { - mavenCentral() - maven { - url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' - } -} - -dependencies { - api 'com.squareup.okhttp3:okhttp:4.12.0' - api 'com.fasterxml.jackson.core:jackson-databind:2.13.0' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3' - api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3' - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2' - testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2' -} - - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - -spotless { - java { - palantirJavaFormat() - } -} - -java { - withSourcesJar() - withJavadocJar() -} - -signing { - sign(publishing.publications) -} -test { - useJUnitPlatform() - testLogging { - showStandardStreams = true - } -} -publishing { - publications { - maven(MavenPublication) { - groupId = 'com.courier' - artifactId = 'courier-java' - version = '3.6.0' - from components.java - pom { - name = 'courier' - description = 'The official Java library for sending notifications with the Courier REST API.' - url = 'https://www.courier.com/docs/reference/' - licenses { - license { - name = 'MIT' - } - } - developers { - developer { - name = 'courier' - email = 'developers@courier.com' - } - } - scm { - connection = 'scm:git:git://github.com/trycourier/courier-java.git' - developerConnection = 'scm:git:git://github.com/trycourier/courier-java.git' - url = 'https://github.com/trycourier/courier-java' - } - } - } - } - repositories { - maven { - url "$System.env.MAVEN_PUBLISH_REGISTRY_URL" - credentials { - username "$System.env.MAVEN_USERNAME" - password "$System.env.MAVEN_PASSWORD" - } - } - } -} - diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..4170b798 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,49 @@ +plugins { + id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + id("org.jetbrains.dokka") version "2.0.0" +} + +repositories { + mavenCentral() +} + +allprojects { + group = "com.courier.api" + version = "0.0.1" +} + +subprojects { + // These are populated with dependencies by `buildSrc` scripts. + tasks.register("format") { + group = "Verification" + description = "Formats all source files." + } + tasks.register("lint") { + group = "Verification" + description = "Verifies all source files are formatted." + } + apply(plugin = "org.jetbrains.dokka") +} + +subprojects { + apply(plugin = "org.jetbrains.dokka") +} + +// Avoid race conditions between `dokkaJavadocCollector` and `dokkaJavadocJar` tasks +tasks.named("dokkaJavadocCollector").configure { + subprojects.flatMap { it.tasks } + .filter { it.project.name != "courier-java" && it.name == "dokkaJavadocJar" } + .forEach { mustRunAfter(it) } +} + +nexusPublishing { + repositories { + sonatype { + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + + username.set(System.getenv("SONATYPE_USERNAME")) + password.set(System.getenv("SONATYPE_PASSWORD")) + } + } +} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 00000000..0b141353 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + `kotlin-dsl` + kotlin("jvm") version "1.9.20" +} + +repositories { + gradlePluginPortal() +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20") +} diff --git a/buildSrc/src/main/kotlin/courier.java.gradle.kts b/buildSrc/src/main/kotlin/courier.java.gradle.kts new file mode 100644 index 00000000..81d5d32b --- /dev/null +++ b/buildSrc/src/main/kotlin/courier.java.gradle.kts @@ -0,0 +1,136 @@ +import org.gradle.api.tasks.testing.logging.TestExceptionFormat + +plugins { + `java-library` +} + +repositories { + mavenCentral() +} + +configure { + withJavadocJar() + withSourcesJar() +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.withType().configureEach { + options.compilerArgs.add("-Werror") + options.release.set(8) +} + +tasks.named("javadocJar") { + setZip64(true) +} + +tasks.named("jar") { + manifest { + attributes(mapOf( + "Implementation-Title" to project.name, + "Implementation-Version" to project.version + )) + } +} + +tasks.withType().configureEach { + useJUnitPlatform() + + // Run tests in parallel to some degree. + maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) + forkEvery = 100 + + testLogging { + exceptionFormat = TestExceptionFormat.FULL + } +} + +val palantir by configurations.creating +dependencies { + palantir("com.palantir.javaformat:palantir-java-format:2.73.0") +} + +fun registerPalantir( + name: String, + description: String, +) { + val javaName = "${name}Java" + tasks.register(javaName) { + group = "Verification" + this.description = description + + classpath = palantir + mainClass = "com.palantir.javaformat.java.Main" + + // Avoid an `IllegalAccessError` on Java 9+. + jvmArgs( + "--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ) + + // Use paths relative to the current module. + val argumentFile = + project.layout.buildDirectory.file("palantir-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("palantir-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val javaFiles = project.fileTree("src") { include("**/*.java") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file. + onlyIf { javaFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(javaFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--palantir\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } else { + // `--dry-run` and `--replace` (for in-place formatting) are mutually exclusive. + argumentFile.appendText("--replace\n") + } + + // Write the modified files to the argument file. + javaFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { javaFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(javaName)) + } +} + +registerPalantir(name = "format", description = "Formats all Java source files.") +registerPalantir(name = "lint", description = "Verifies all Java source files are formatted.") diff --git a/buildSrc/src/main/kotlin/courier.kotlin.gradle.kts b/buildSrc/src/main/kotlin/courier.kotlin.gradle.kts new file mode 100644 index 00000000..365ccefa --- /dev/null +++ b/buildSrc/src/main/kotlin/courier.kotlin.gradle.kts @@ -0,0 +1,106 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinVersion + +plugins { + id("courier.java") + kotlin("jvm") +} + +repositories { + mavenCentral() +} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(21)) + } + + compilerOptions { + freeCompilerArgs = listOf( + "-Xjvm-default=all", + "-Xjdk-release=1.8", + // Suppress deprecation warnings because we may still reference and test deprecated members. + // TODO: Replace with `-Xsuppress-warning=DEPRECATION` once we use Kotlin compiler 2.1.0+. + "-nowarn", + ) + jvmTarget.set(JvmTarget.JVM_1_8) + languageVersion.set(KotlinVersion.KOTLIN_1_8) + apiVersion.set(KotlinVersion.KOTLIN_1_8) + coreLibrariesVersion = "1.8.0" + } +} + +tasks.withType().configureEach { + systemProperty("junit.jupiter.execution.parallel.enabled", true) + systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") +} + +val ktfmt by configurations.creating +dependencies { + ktfmt("com.facebook:ktfmt:0.56") +} + +fun registerKtfmt( + name: String, + description: String, +) { + val kotlinName = "${name}Kotlin" + tasks.register(kotlinName) { + group = "Verification" + this.description = description + + classpath = ktfmt + mainClass = "com.facebook.ktfmt.cli.Main" + + // Use paths relative to the current module. + val argumentFile = project.layout.buildDirectory.file("ktfmt-$name-args.txt").get().asFile + val lastRunTimeFile = + project.layout.buildDirectory.file("ktfmt-$name-last-run.txt").get().asFile + + // Read the time when this task was last executed for this module (if ever). + val lastRunTime = lastRunTimeFile.takeIf { it.exists() }?.readText()?.toLongOrNull() ?: 0L + + // Use a `fileTree` relative to the module's source directory. + val kotlinFiles = project.fileTree("src") { include("**/*.kt") } + + // Determine if any files need to be formatted or linted and continue only if there is at least + // one file (otherwise Ktfmt will fail). + onlyIf { kotlinFiles.any { it.lastModified() > lastRunTime } } + + inputs.files(kotlinFiles) + + doFirst { + // Create the argument file and set the preferred formatting style. + argumentFile.parentFile.mkdirs() + argumentFile.writeText("--kotlinlang-style\n") + + if (name == "lint") { + // For lint, do a dry run, so no files are modified. Set the exit code to 1 (instead of + // the default 0) if any files need to be formatted, indicating that linting has failed. + argumentFile.appendText("--dry-run\n") + argumentFile.appendText("--set-exit-if-changed\n") + } + + // Write the modified files to the argument file. + kotlinFiles.filter { it.lastModified() > lastRunTime } + .forEach { argumentFile.appendText("${it.absolutePath}\n") } + } + + doLast { + // Record the last execution time for later up-to-date checking. + lastRunTimeFile.writeText(System.currentTimeMillis().toString()) + } + + // Pass the argument file using the @ symbol + args = listOf("@${argumentFile.absolutePath}") + + outputs.upToDateWhen { kotlinFiles.none { it.lastModified() > lastRunTime } } + } + + tasks.named(name) { + dependsOn(tasks.named(kotlinName)) + } +} + +registerKtfmt(name = "format", description = "Formats all Kotlin source files.") +registerKtfmt(name = "lint", description = "Verifies all Kotlin source files are formatted.") diff --git a/buildSrc/src/main/kotlin/courier.publish.gradle.kts b/buildSrc/src/main/kotlin/courier.publish.gradle.kts new file mode 100644 index 00000000..a3deea52 --- /dev/null +++ b/buildSrc/src/main/kotlin/courier.publish.gradle.kts @@ -0,0 +1,60 @@ +plugins { + `maven-publish` + signing +} + +configure { + publications { + register("maven") { + from(components["java"]) + + pom { + name.set("Courier") + description.set("An SDK library for courier") + url.set("https://www.github.com/stainless-sdks/courier-java") + + licenses { + license { + name.set("Apache-2.0") + } + } + + developers { + developer { + name.set("Courier") + } + } + + scm { + connection.set("scm:git:git://github.com/stainless-sdks/courier-java.git") + developerConnection.set("scm:git:git://github.com/stainless-sdks/courier-java.git") + url.set("https://github.com/stainless-sdks/courier-java") + } + + versionMapping { + allVariants { + fromResolutionResult() + } + } + } + } + } +} + +signing { + val signingKeyId = System.getenv("GPG_SIGNING_KEY_ID")?.ifBlank { null } + val signingKey = System.getenv("GPG_SIGNING_KEY")?.ifBlank { null } + val signingPassword = System.getenv("GPG_SIGNING_PASSWORD")?.ifBlank { null } + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys( + signingKeyId, + signingKey, + signingPassword, + ) + sign(publishing.publications["maven"]) + } +} + +tasks.named("publish") { + dependsOn(":closeAndReleaseSonatypeStagingRepository") +} diff --git a/courier-java-client-okhttp/build.gradle.kts b/courier-java-client-okhttp/build.gradle.kts new file mode 100644 index 00000000..4b62416c --- /dev/null +++ b/courier-java-client-okhttp/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("courier.kotlin") + id("courier.publish") +} + +dependencies { + api(project(":courier-java-core")) + + implementation("com.squareup.okhttp3:okhttp:4.12.0") + implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") + + testImplementation(kotlin("test")) + testImplementation("org.assertj:assertj-core:3.25.3") +} diff --git a/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt b/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt new file mode 100644 index 00000000..4ff91a1b --- /dev/null +++ b/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClient.kt @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.client.okhttp + +import com.courier.api.client.CourierClient +import com.courier.api.client.CourierClientImpl +import com.courier.api.core.ClientOptions +import com.courier.api.core.Sleeper +import com.courier.api.core.Timeout +import com.courier.api.core.http.Headers +import com.courier.api.core.http.HttpClient +import com.courier.api.core.http.QueryParams +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.databind.json.JsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [CourierClient] with [OkHttpClient] as the underlying + * [HttpClient]. + */ +class CourierOkHttpClient private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [CourierClient]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): CourierClient = builder().fromEnv().build() + } + + /** A builder for [CourierOkHttpClient]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.courier.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.courier.com`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + fun fromEnv() = apply { clientOptions.fromEnv() } + + /** + * Returns an immutable instance of [CourierClient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CourierClient = + CourierClientImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt b/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt new file mode 100644 index 00000000..9360f485 --- /dev/null +++ b/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/CourierOkHttpClientAsync.kt @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.client.okhttp + +import com.courier.api.client.CourierClientAsync +import com.courier.api.client.CourierClientAsyncImpl +import com.courier.api.core.ClientOptions +import com.courier.api.core.Sleeper +import com.courier.api.core.Timeout +import com.courier.api.core.http.Headers +import com.courier.api.core.http.HttpClient +import com.courier.api.core.http.QueryParams +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.databind.json.JsonMapper +import java.net.Proxy +import java.time.Clock +import java.time.Duration +import java.util.Optional +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import kotlin.jvm.optionals.getOrNull + +/** + * A class that allows building an instance of [CourierClientAsync] with [OkHttpClient] as the + * underlying [HttpClient]. + */ +class CourierOkHttpClientAsync private constructor() { + + companion object { + + /** Returns a mutable builder for constructing an instance of [CourierClientAsync]. */ + @JvmStatic fun builder() = Builder() + + /** + * Returns a client configured using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + @JvmStatic fun fromEnv(): CourierClientAsync = builder().fromEnv().build() + } + + /** A builder for [CourierOkHttpClientAsync]. */ + class Builder internal constructor() { + + private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ + fun proxy(proxy: Optional) = proxy(proxy.getOrNull()) + + /** + * The socket factory used to secure HTTPS connections. + * + * If this is set, then [trustManager] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + /** Alias for calling [Builder.sslSocketFactory] with `sslSocketFactory.orElse(null)`. */ + fun sslSocketFactory(sslSocketFactory: Optional) = + sslSocketFactory(sslSocketFactory.getOrNull()) + + /** + * The trust manager used to secure HTTPS connections. + * + * If this is set, then [sslSocketFactory] must also be set. + * + * If unset, then the system default is used. Most applications should not call this method, + * and instead use the system default. The default include special optimizations that can be + * lost if the implementation is modified. + */ + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + /** Alias for calling [Builder.trustManager] with `trustManager.orElse(null)`. */ + fun trustManager(trustManager: Optional) = + trustManager(trustManager.getOrNull()) + + /** + * The verifier used to confirm that response certificates apply to requested hostnames for + * HTTPS connections. + * + * If unset, then a default hostname verifier is used. + */ + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + /** Alias for calling [Builder.hostnameVerifier] with `hostnameVerifier.orElse(null)`. */ + fun hostnameVerifier(hostnameVerifier: Optional) = + hostnameVerifier(hostnameVerifier.getOrNull()) + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + clientOptions.checkJacksonVersionCompatibility(checkJacksonVersionCompatibility) + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.courier.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { clientOptions.jsonMapper(jsonMapper) } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { clientOptions.sleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { clientOptions.clock(clock) } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.courier.com`. + */ + fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + clientOptions.responseValidation(responseValidation) + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { clientOptions.timeout(timeout) } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = apply { clientOptions.timeout(timeout) } + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) } + + fun apiKey(apiKey: String) = apply { clientOptions.apiKey(apiKey) } + + fun headers(headers: Headers) = apply { clientOptions.headers(headers) } + + fun headers(headers: Map>) = apply { + clientOptions.headers(headers) + } + + fun putHeader(name: String, value: String) = apply { clientOptions.putHeader(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { + clientOptions.putHeaders(name, values) + } + + fun putAllHeaders(headers: Headers) = apply { clientOptions.putAllHeaders(headers) } + + fun putAllHeaders(headers: Map>) = apply { + clientOptions.putAllHeaders(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { + clientOptions.replaceHeaders(name, value) + } + + fun replaceHeaders(name: String, values: Iterable) = apply { + clientOptions.replaceHeaders(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { clientOptions.replaceAllHeaders(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + clientOptions.replaceAllHeaders(headers) + } + + fun removeHeaders(name: String) = apply { clientOptions.removeHeaders(name) } + + fun removeAllHeaders(names: Set) = apply { clientOptions.removeAllHeaders(names) } + + fun queryParams(queryParams: QueryParams) = apply { clientOptions.queryParams(queryParams) } + + fun queryParams(queryParams: Map>) = apply { + clientOptions.queryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { + clientOptions.putQueryParam(key, value) + } + + fun putQueryParams(key: String, values: Iterable) = apply { + clientOptions.putQueryParams(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + clientOptions.putAllQueryParams(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + clientOptions.replaceQueryParams(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + clientOptions.replaceQueryParams(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + clientOptions.replaceAllQueryParams(queryParams) + } + + fun removeQueryParams(key: String) = apply { clientOptions.removeQueryParams(key) } + + fun removeAllQueryParams(keys: Set) = apply { + clientOptions.removeAllQueryParams(keys) + } + + /** + * Updates configuration using system properties and environment variables. + * + * @see ClientOptions.Builder.fromEnv + */ + fun fromEnv() = apply { clientOptions.fromEnv() } + + /** + * Returns an immutable instance of [CourierClientAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CourierClientAsync = + CourierClientAsyncImpl( + clientOptions + .httpClient( + OkHttpClient.builder() + .timeout(clientOptions.timeout()) + .proxy(proxy) + .sslSocketFactory(sslSocketFactory) + .trustManager(trustManager) + .hostnameVerifier(hostnameVerifier) + .build() + ) + .build() + ) + } +} diff --git a/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/OkHttpClient.kt b/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/OkHttpClient.kt new file mode 100644 index 00000000..33ff3abe --- /dev/null +++ b/courier-java-client-okhttp/src/main/kotlin/com/courier/api/client/okhttp/OkHttpClient.kt @@ -0,0 +1,246 @@ +package com.courier.api.client.okhttp + +import com.courier.api.core.RequestOptions +import com.courier.api.core.Timeout +import com.courier.api.core.http.Headers +import com.courier.api.core.http.HttpClient +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpRequestBody +import com.courier.api.core.http.HttpResponse +import com.courier.api.errors.CourierIoException +import java.io.IOException +import java.io.InputStream +import java.net.Proxy +import java.time.Duration +import java.util.concurrent.CompletableFuture +import javax.net.ssl.HostnameVerifier +import javax.net.ssl.SSLSocketFactory +import javax.net.ssl.X509TrustManager +import okhttp3.Call +import okhttp3.Callback +import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MediaType +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.Request +import okhttp3.RequestBody +import okhttp3.RequestBody.Companion.toRequestBody +import okhttp3.Response +import okhttp3.logging.HttpLoggingInterceptor +import okio.BufferedSink + +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : + HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + val call = newCall(request, requestOptions) + + return try { + call.execute().toResponse() + } catch (e: IOException) { + throw CourierIoException("Request failed", e) + } finally { + request.body?.close() + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val future = CompletableFuture() + + request.body?.run { future.whenComplete { _, _ -> close() } } + + newCall(request, requestOptions) + .enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } + + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(CourierIoException("Request failed", e)) + } + } + ) + + return future + } + + override fun close() { + okHttpClient.dispatcher.executorService.shutdown() + okHttpClient.connectionPool.evictAll() + okHttpClient.cache?.close() + } + + private fun newCall(request: HttpRequest, requestOptions: RequestOptions): Call { + val clientBuilder = okHttpClient.newBuilder() + + val logLevel = + when (System.getenv("COURIER_LOG")?.lowercase()) { + "info" -> HttpLoggingInterceptor.Level.BASIC + "debug" -> HttpLoggingInterceptor.Level.BODY + else -> null + } + if (logLevel != null) { + clientBuilder.addNetworkInterceptor( + HttpLoggingInterceptor().setLevel(logLevel).apply { redactHeader("Authorization") } + ) + } + + requestOptions.timeout?.let { + clientBuilder + .connectTimeout(it.connect()) + .readTimeout(it.read()) + .writeTimeout(it.write()) + .callTimeout(it.request()) + } + + val client = clientBuilder.build() + return client.newCall(request.toRequest(client)) + } + + private fun HttpRequest.toRequest(client: okhttp3.OkHttpClient): Request { + var body: RequestBody? = body?.toRequestBody() + if (body == null && requiresBody(method)) { + body = "".toRequestBody() + } + + val builder = Request.Builder().url(toUrl()).method(method.name, body) + headers.names().forEach { name -> + headers.values(name).forEach { builder.header(name, it) } + } + + if ( + !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 + ) { + builder.header( + "X-Stainless-Read-Timeout", + Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), + ) + } + if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { + builder.header( + "X-Stainless-Timeout", + Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), + ) + } + + return builder.build() + } + + /** `OkHttpClient` always requires a request body for some methods. */ + private fun requiresBody(method: HttpMethod): Boolean = + when (method) { + HttpMethod.POST, + HttpMethod.PUT, + HttpMethod.PATCH -> true + else -> false + } + + private fun HttpRequest.toUrl(): String { + val builder = baseUrl.toHttpUrl().newBuilder() + pathSegments.forEach(builder::addPathSegment) + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { builder.addQueryParameter(key, it) } + } + + return builder.toString() + } + + private fun HttpRequestBody.toRequestBody(): RequestBody { + val mediaType = contentType()?.toMediaType() + val length = contentLength() + + return object : RequestBody() { + override fun contentType(): MediaType? = mediaType + + override fun contentLength(): Long = length + + override fun isOneShot(): Boolean = !repeatable() + + override fun writeTo(sink: BufferedSink) = writeTo(sink.outputStream()) + } + } + + private fun Response.toResponse(): HttpResponse { + val headers = headers.toHeaders() + + return object : HttpResponse { + override fun statusCode(): Int = code + + override fun headers(): Headers = headers + + override fun body(): InputStream = body!!.byteStream() + + override fun close() = body!!.close() + } + } + + private fun okhttp3.Headers.toHeaders(): Headers { + val headersBuilder = Headers.builder() + forEach { (name, value) -> headersBuilder.put(name, value) } + return headersBuilder.build() + } + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var timeout: Timeout = Timeout.default() + private var proxy: Proxy? = null + private var sslSocketFactory: SSLSocketFactory? = null + private var trustManager: X509TrustManager? = null + private var hostnameVerifier: HostnameVerifier? = null + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { + this.sslSocketFactory = sslSocketFactory + } + + fun trustManager(trustManager: X509TrustManager?) = apply { + this.trustManager = trustManager + } + + fun hostnameVerifier(hostnameVerifier: HostnameVerifier?) = apply { + this.hostnameVerifier = hostnameVerifier + } + + fun build(): OkHttpClient = + OkHttpClient( + okhttp3.OkHttpClient.Builder() + .connectTimeout(timeout.connect()) + .readTimeout(timeout.read()) + .writeTimeout(timeout.write()) + .callTimeout(timeout.request()) + .proxy(proxy) + .apply { + val sslSocketFactory = sslSocketFactory + val trustManager = trustManager + if (sslSocketFactory != null && trustManager != null) { + sslSocketFactory(sslSocketFactory, trustManager) + } else { + check((sslSocketFactory != null) == (trustManager != null)) { + "Both or none of `sslSocketFactory` and `trustManager` must be set, but only one was set" + } + } + + hostnameVerifier?.let(::hostnameVerifier) + } + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } + ) + } +} diff --git a/courier-java-core/build.gradle.kts b/courier-java-core/build.gradle.kts new file mode 100644 index 00000000..d31e4b11 --- /dev/null +++ b/courier-java-core/build.gradle.kts @@ -0,0 +1,41 @@ +plugins { + id("courier.kotlin") + id("courier.publish") +} + +configurations.all { + resolutionStrategy { + // Compile and test against a lower Jackson version to ensure we're compatible with it. + // We publish with a higher version (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.13.4") + force("com.fasterxml.jackson.core:jackson-databind:2.13.4") + force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + } +} + +dependencies { + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") + api("com.google.errorprone:error_prone_annotations:2.33.0") + + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") + implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") + implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") + + testImplementation(kotlin("test")) + testImplementation(project(":courier-java-client-okhttp")) + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") + testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") + testImplementation("org.mockito:mockito-core:5.14.2") + testImplementation("org.mockito:mockito-junit-jupiter:5.14.2") + testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt new file mode 100644 index 00000000..180e5483 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt @@ -0,0 +1,147 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.client + +import com.courier.api.core.ClientOptions +import com.courier.api.services.blocking.AudienceService +import com.courier.api.services.blocking.AuditEventService +import com.courier.api.services.blocking.AuthService +import com.courier.api.services.blocking.AutomationService +import com.courier.api.services.blocking.BrandService +import com.courier.api.services.blocking.BulkService +import com.courier.api.services.blocking.InboundService +import com.courier.api.services.blocking.ListService +import com.courier.api.services.blocking.MessageService +import com.courier.api.services.blocking.NotificationService +import com.courier.api.services.blocking.ProfileService +import com.courier.api.services.blocking.RequestService +import com.courier.api.services.blocking.SendService +import com.courier.api.services.blocking.TenantService +import com.courier.api.services.blocking.TranslationService +import com.courier.api.services.blocking.UserService +import java.util.function.Consumer + +/** + * A client for interacting with the Courier REST API synchronously. You can also switch to + * asynchronous execution via the [async] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ +interface CourierClient { + + /** + * Returns a version of this client that uses asynchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ + fun async(): CourierClientAsync + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CourierClient + + fun send(): SendService + + fun audiences(): AudienceService + + fun auditEvents(): AuditEventService + + fun auth(): AuthService + + fun automations(): AutomationService + + fun brands(): BrandService + + fun bulk(): BulkService + + fun inbound(): InboundService + + fun lists(): ListService + + fun messages(): MessageService + + fun requests(): RequestService + + fun notifications(): NotificationService + + fun profiles(): ProfileService + + fun tenants(): TenantService + + fun translations(): TranslationService + + fun users(): UserService + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** A view of [CourierClient] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CourierClient.WithRawResponse + + fun send(): SendService.WithRawResponse + + fun audiences(): AudienceService.WithRawResponse + + fun auditEvents(): AuditEventService.WithRawResponse + + fun auth(): AuthService.WithRawResponse + + fun automations(): AutomationService.WithRawResponse + + fun brands(): BrandService.WithRawResponse + + fun bulk(): BulkService.WithRawResponse + + fun inbound(): InboundService.WithRawResponse + + fun lists(): ListService.WithRawResponse + + fun messages(): MessageService.WithRawResponse + + fun requests(): RequestService.WithRawResponse + + fun notifications(): NotificationService.WithRawResponse + + fun profiles(): ProfileService.WithRawResponse + + fun tenants(): TenantService.WithRawResponse + + fun translations(): TranslationService.WithRawResponse + + fun users(): UserService.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt new file mode 100644 index 00000000..c9af54aa --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.client + +import com.courier.api.core.ClientOptions +import com.courier.api.services.async.AudienceServiceAsync +import com.courier.api.services.async.AuditEventServiceAsync +import com.courier.api.services.async.AuthServiceAsync +import com.courier.api.services.async.AutomationServiceAsync +import com.courier.api.services.async.BrandServiceAsync +import com.courier.api.services.async.BulkServiceAsync +import com.courier.api.services.async.InboundServiceAsync +import com.courier.api.services.async.ListServiceAsync +import com.courier.api.services.async.MessageServiceAsync +import com.courier.api.services.async.NotificationServiceAsync +import com.courier.api.services.async.ProfileServiceAsync +import com.courier.api.services.async.RequestServiceAsync +import com.courier.api.services.async.SendServiceAsync +import com.courier.api.services.async.TenantServiceAsync +import com.courier.api.services.async.TranslationServiceAsync +import com.courier.api.services.async.UserServiceAsync +import java.util.function.Consumer + +/** + * A client for interacting with the Courier REST API asynchronously. You can also switch to + * synchronous execution via the [sync] method. + * + * This client performs best when you create a single instance and reuse it for all interactions + * with the REST API. This is because each client holds its own connection pool and thread pools. + * Reusing connections and threads reduces latency and saves memory. The client also handles rate + * limiting per client. This means that creating and using multiple instances at the same time will + * not respect rate limits. + * + * The threads and connections that are held will be released automatically if they remain idle. But + * if you are writing an application that needs to aggressively release unused resources, then you + * may call [close]. + */ +interface CourierClientAsync { + + /** + * Returns a version of this client that uses synchronous execution. + * + * The returned client shares its resources, like its connection pool and thread pools, with + * this client. + */ + fun sync(): CourierClient + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CourierClientAsync + + fun send(): SendServiceAsync + + fun audiences(): AudienceServiceAsync + + fun auditEvents(): AuditEventServiceAsync + + fun auth(): AuthServiceAsync + + fun automations(): AutomationServiceAsync + + fun brands(): BrandServiceAsync + + fun bulk(): BulkServiceAsync + + fun inbound(): InboundServiceAsync + + fun lists(): ListServiceAsync + + fun messages(): MessageServiceAsync + + fun requests(): RequestServiceAsync + + fun notifications(): NotificationServiceAsync + + fun profiles(): ProfileServiceAsync + + fun tenants(): TenantServiceAsync + + fun translations(): TranslationServiceAsync + + fun users(): UserServiceAsync + + /** + * Closes this client, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client is long-lived and + * usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default HTTP client + * automatically releases threads and connections if they remain idle, but if you are writing an + * application that needs to aggressively release unused resources, then you may call this + * method. + */ + fun close() + + /** + * A view of [CourierClientAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CourierClientAsync.WithRawResponse + + fun send(): SendServiceAsync.WithRawResponse + + fun audiences(): AudienceServiceAsync.WithRawResponse + + fun auditEvents(): AuditEventServiceAsync.WithRawResponse + + fun auth(): AuthServiceAsync.WithRawResponse + + fun automations(): AutomationServiceAsync.WithRawResponse + + fun brands(): BrandServiceAsync.WithRawResponse + + fun bulk(): BulkServiceAsync.WithRawResponse + + fun inbound(): InboundServiceAsync.WithRawResponse + + fun lists(): ListServiceAsync.WithRawResponse + + fun messages(): MessageServiceAsync.WithRawResponse + + fun requests(): RequestServiceAsync.WithRawResponse + + fun notifications(): NotificationServiceAsync.WithRawResponse + + fun profiles(): ProfileServiceAsync.WithRawResponse + + fun tenants(): TenantServiceAsync.WithRawResponse + + fun translations(): TranslationServiceAsync.WithRawResponse + + fun users(): UserServiceAsync.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt new file mode 100644 index 00000000..01a0126c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.client + +import com.courier.api.core.ClientOptions +import com.courier.api.core.getPackageVersion +import com.courier.api.services.async.AudienceServiceAsync +import com.courier.api.services.async.AudienceServiceAsyncImpl +import com.courier.api.services.async.AuditEventServiceAsync +import com.courier.api.services.async.AuditEventServiceAsyncImpl +import com.courier.api.services.async.AuthServiceAsync +import com.courier.api.services.async.AuthServiceAsyncImpl +import com.courier.api.services.async.AutomationServiceAsync +import com.courier.api.services.async.AutomationServiceAsyncImpl +import com.courier.api.services.async.BrandServiceAsync +import com.courier.api.services.async.BrandServiceAsyncImpl +import com.courier.api.services.async.BulkServiceAsync +import com.courier.api.services.async.BulkServiceAsyncImpl +import com.courier.api.services.async.InboundServiceAsync +import com.courier.api.services.async.InboundServiceAsyncImpl +import com.courier.api.services.async.ListServiceAsync +import com.courier.api.services.async.ListServiceAsyncImpl +import com.courier.api.services.async.MessageServiceAsync +import com.courier.api.services.async.MessageServiceAsyncImpl +import com.courier.api.services.async.NotificationServiceAsync +import com.courier.api.services.async.NotificationServiceAsyncImpl +import com.courier.api.services.async.ProfileServiceAsync +import com.courier.api.services.async.ProfileServiceAsyncImpl +import com.courier.api.services.async.RequestServiceAsync +import com.courier.api.services.async.RequestServiceAsyncImpl +import com.courier.api.services.async.SendServiceAsync +import com.courier.api.services.async.SendServiceAsyncImpl +import com.courier.api.services.async.TenantServiceAsync +import com.courier.api.services.async.TenantServiceAsyncImpl +import com.courier.api.services.async.TranslationServiceAsync +import com.courier.api.services.async.TranslationServiceAsyncImpl +import com.courier.api.services.async.UserServiceAsync +import com.courier.api.services.async.UserServiceAsyncImpl +import java.util.function.Consumer + +class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : CourierClientAsync { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val sync: CourierClient by lazy { CourierClientImpl(clientOptions) } + + private val withRawResponse: CourierClientAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val send: SendServiceAsync by lazy { SendServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val audiences: AudienceServiceAsync by lazy { + AudienceServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val auditEvents: AuditEventServiceAsync by lazy { + AuditEventServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val auth: AuthServiceAsync by lazy { AuthServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val automations: AutomationServiceAsync by lazy { + AutomationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val brands: BrandServiceAsync by lazy { + BrandServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val bulk: BulkServiceAsync by lazy { BulkServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val inbound: InboundServiceAsync by lazy { + InboundServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val lists: ListServiceAsync by lazy { ListServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val messages: MessageServiceAsync by lazy { + MessageServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val requests: RequestServiceAsync by lazy { + RequestServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val notifications: NotificationServiceAsync by lazy { + NotificationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val profiles: ProfileServiceAsync by lazy { + ProfileServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val tenants: TenantServiceAsync by lazy { + TenantServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val translations: TranslationServiceAsync by lazy { + TranslationServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptionsWithUserAgent) } + + override fun sync(): CourierClient = sync + + override fun withRawResponse(): CourierClientAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CourierClientAsync = + CourierClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun send(): SendServiceAsync = send + + override fun audiences(): AudienceServiceAsync = audiences + + override fun auditEvents(): AuditEventServiceAsync = auditEvents + + override fun auth(): AuthServiceAsync = auth + + override fun automations(): AutomationServiceAsync = automations + + override fun brands(): BrandServiceAsync = brands + + override fun bulk(): BulkServiceAsync = bulk + + override fun inbound(): InboundServiceAsync = inbound + + override fun lists(): ListServiceAsync = lists + + override fun messages(): MessageServiceAsync = messages + + override fun requests(): RequestServiceAsync = requests + + override fun notifications(): NotificationServiceAsync = notifications + + override fun profiles(): ProfileServiceAsync = profiles + + override fun tenants(): TenantServiceAsync = tenants + + override fun translations(): TranslationServiceAsync = translations + + override fun users(): UserServiceAsync = users + + override fun close() = clientOptions.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CourierClientAsync.WithRawResponse { + + private val send: SendServiceAsync.WithRawResponse by lazy { + SendServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val audiences: AudienceServiceAsync.WithRawResponse by lazy { + AudienceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val auditEvents: AuditEventServiceAsync.WithRawResponse by lazy { + AuditEventServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val auth: AuthServiceAsync.WithRawResponse by lazy { + AuthServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val automations: AutomationServiceAsync.WithRawResponse by lazy { + AutomationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val brands: BrandServiceAsync.WithRawResponse by lazy { + BrandServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val bulk: BulkServiceAsync.WithRawResponse by lazy { + BulkServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val inbound: InboundServiceAsync.WithRawResponse by lazy { + InboundServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val lists: ListServiceAsync.WithRawResponse by lazy { + ListServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val messages: MessageServiceAsync.WithRawResponse by lazy { + MessageServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val requests: RequestServiceAsync.WithRawResponse by lazy { + RequestServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val notifications: NotificationServiceAsync.WithRawResponse by lazy { + NotificationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val profiles: ProfileServiceAsync.WithRawResponse by lazy { + ProfileServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tenants: TenantServiceAsync.WithRawResponse by lazy { + TenantServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val translations: TranslationServiceAsync.WithRawResponse by lazy { + TranslationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val users: UserServiceAsync.WithRawResponse by lazy { + UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): CourierClientAsync.WithRawResponse = + CourierClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun send(): SendServiceAsync.WithRawResponse = send + + override fun audiences(): AudienceServiceAsync.WithRawResponse = audiences + + override fun auditEvents(): AuditEventServiceAsync.WithRawResponse = auditEvents + + override fun auth(): AuthServiceAsync.WithRawResponse = auth + + override fun automations(): AutomationServiceAsync.WithRawResponse = automations + + override fun brands(): BrandServiceAsync.WithRawResponse = brands + + override fun bulk(): BulkServiceAsync.WithRawResponse = bulk + + override fun inbound(): InboundServiceAsync.WithRawResponse = inbound + + override fun lists(): ListServiceAsync.WithRawResponse = lists + + override fun messages(): MessageServiceAsync.WithRawResponse = messages + + override fun requests(): RequestServiceAsync.WithRawResponse = requests + + override fun notifications(): NotificationServiceAsync.WithRawResponse = notifications + + override fun profiles(): ProfileServiceAsync.WithRawResponse = profiles + + override fun tenants(): TenantServiceAsync.WithRawResponse = tenants + + override fun translations(): TranslationServiceAsync.WithRawResponse = translations + + override fun users(): UserServiceAsync.WithRawResponse = users + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt new file mode 100644 index 00000000..9332ccdc --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt @@ -0,0 +1,247 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.client + +import com.courier.api.core.ClientOptions +import com.courier.api.core.getPackageVersion +import com.courier.api.services.blocking.AudienceService +import com.courier.api.services.blocking.AudienceServiceImpl +import com.courier.api.services.blocking.AuditEventService +import com.courier.api.services.blocking.AuditEventServiceImpl +import com.courier.api.services.blocking.AuthService +import com.courier.api.services.blocking.AuthServiceImpl +import com.courier.api.services.blocking.AutomationService +import com.courier.api.services.blocking.AutomationServiceImpl +import com.courier.api.services.blocking.BrandService +import com.courier.api.services.blocking.BrandServiceImpl +import com.courier.api.services.blocking.BulkService +import com.courier.api.services.blocking.BulkServiceImpl +import com.courier.api.services.blocking.InboundService +import com.courier.api.services.blocking.InboundServiceImpl +import com.courier.api.services.blocking.ListService +import com.courier.api.services.blocking.ListServiceImpl +import com.courier.api.services.blocking.MessageService +import com.courier.api.services.blocking.MessageServiceImpl +import com.courier.api.services.blocking.NotificationService +import com.courier.api.services.blocking.NotificationServiceImpl +import com.courier.api.services.blocking.ProfileService +import com.courier.api.services.blocking.ProfileServiceImpl +import com.courier.api.services.blocking.RequestService +import com.courier.api.services.blocking.RequestServiceImpl +import com.courier.api.services.blocking.SendService +import com.courier.api.services.blocking.SendServiceImpl +import com.courier.api.services.blocking.TenantService +import com.courier.api.services.blocking.TenantServiceImpl +import com.courier.api.services.blocking.TranslationService +import com.courier.api.services.blocking.TranslationServiceImpl +import com.courier.api.services.blocking.UserService +import com.courier.api.services.blocking.UserServiceImpl +import java.util.function.Consumer + +class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClient { + + private val clientOptionsWithUserAgent = + if (clientOptions.headers.names().contains("User-Agent")) clientOptions + else + clientOptions + .toBuilder() + .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .build() + + // Pass the original clientOptions so that this client sets its own User-Agent. + private val async: CourierClientAsync by lazy { CourierClientAsyncImpl(clientOptions) } + + private val withRawResponse: CourierClient.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val send: SendService by lazy { SendServiceImpl(clientOptionsWithUserAgent) } + + private val audiences: AudienceService by lazy { + AudienceServiceImpl(clientOptionsWithUserAgent) + } + + private val auditEvents: AuditEventService by lazy { + AuditEventServiceImpl(clientOptionsWithUserAgent) + } + + private val auth: AuthService by lazy { AuthServiceImpl(clientOptionsWithUserAgent) } + + private val automations: AutomationService by lazy { + AutomationServiceImpl(clientOptionsWithUserAgent) + } + + private val brands: BrandService by lazy { BrandServiceImpl(clientOptionsWithUserAgent) } + + private val bulk: BulkService by lazy { BulkServiceImpl(clientOptionsWithUserAgent) } + + private val inbound: InboundService by lazy { InboundServiceImpl(clientOptionsWithUserAgent) } + + private val lists: ListService by lazy { ListServiceImpl(clientOptionsWithUserAgent) } + + private val messages: MessageService by lazy { MessageServiceImpl(clientOptionsWithUserAgent) } + + private val requests: RequestService by lazy { RequestServiceImpl(clientOptionsWithUserAgent) } + + private val notifications: NotificationService by lazy { + NotificationServiceImpl(clientOptionsWithUserAgent) + } + + private val profiles: ProfileService by lazy { ProfileServiceImpl(clientOptionsWithUserAgent) } + + private val tenants: TenantService by lazy { TenantServiceImpl(clientOptionsWithUserAgent) } + + private val translations: TranslationService by lazy { + TranslationServiceImpl(clientOptionsWithUserAgent) + } + + private val users: UserService by lazy { UserServiceImpl(clientOptionsWithUserAgent) } + + override fun async(): CourierClientAsync = async + + override fun withRawResponse(): CourierClient.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CourierClient = + CourierClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun send(): SendService = send + + override fun audiences(): AudienceService = audiences + + override fun auditEvents(): AuditEventService = auditEvents + + override fun auth(): AuthService = auth + + override fun automations(): AutomationService = automations + + override fun brands(): BrandService = brands + + override fun bulk(): BulkService = bulk + + override fun inbound(): InboundService = inbound + + override fun lists(): ListService = lists + + override fun messages(): MessageService = messages + + override fun requests(): RequestService = requests + + override fun notifications(): NotificationService = notifications + + override fun profiles(): ProfileService = profiles + + override fun tenants(): TenantService = tenants + + override fun translations(): TranslationService = translations + + override fun users(): UserService = users + + override fun close() = clientOptions.close() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CourierClient.WithRawResponse { + + private val send: SendService.WithRawResponse by lazy { + SendServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val audiences: AudienceService.WithRawResponse by lazy { + AudienceServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val auditEvents: AuditEventService.WithRawResponse by lazy { + AuditEventServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val auth: AuthService.WithRawResponse by lazy { + AuthServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val automations: AutomationService.WithRawResponse by lazy { + AutomationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val brands: BrandService.WithRawResponse by lazy { + BrandServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val bulk: BulkService.WithRawResponse by lazy { + BulkServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val inbound: InboundService.WithRawResponse by lazy { + InboundServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val lists: ListService.WithRawResponse by lazy { + ListServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val messages: MessageService.WithRawResponse by lazy { + MessageServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val requests: RequestService.WithRawResponse by lazy { + RequestServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val notifications: NotificationService.WithRawResponse by lazy { + NotificationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val profiles: ProfileService.WithRawResponse by lazy { + ProfileServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tenants: TenantService.WithRawResponse by lazy { + TenantServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val translations: TranslationService.WithRawResponse by lazy { + TranslationServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val users: UserService.WithRawResponse by lazy { + UserServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): CourierClient.WithRawResponse = + CourierClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun send(): SendService.WithRawResponse = send + + override fun audiences(): AudienceService.WithRawResponse = audiences + + override fun auditEvents(): AuditEventService.WithRawResponse = auditEvents + + override fun auth(): AuthService.WithRawResponse = auth + + override fun automations(): AutomationService.WithRawResponse = automations + + override fun brands(): BrandService.WithRawResponse = brands + + override fun bulk(): BulkService.WithRawResponse = bulk + + override fun inbound(): InboundService.WithRawResponse = inbound + + override fun lists(): ListService.WithRawResponse = lists + + override fun messages(): MessageService.WithRawResponse = messages + + override fun requests(): RequestService.WithRawResponse = requests + + override fun notifications(): NotificationService.WithRawResponse = notifications + + override fun profiles(): ProfileService.WithRawResponse = profiles + + override fun tenants(): TenantService.WithRawResponse = tenants + + override fun translations(): TranslationService.WithRawResponse = translations + + override fun users(): UserService.WithRawResponse = users + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/BaseDeserializer.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/BaseDeserializer.kt new file mode 100644 index 00000000..6210d0dd --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/BaseDeserializer.kt @@ -0,0 +1,44 @@ +package com.courier.api.core + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.BeanProperty +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JavaType +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.deser.ContextualDeserializer +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import kotlin.reflect.KClass + +abstract class BaseDeserializer(type: KClass) : + StdDeserializer(type.java), ContextualDeserializer { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer { + return this + } + + override fun deserialize(parser: JsonParser, context: DeserializationContext): T { + return parser.codec.deserialize(parser.readValueAsTree()) + } + + protected abstract fun ObjectCodec.deserialize(node: JsonNode): T + + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: TypeReference): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } + + protected fun ObjectCodec.tryDeserialize(node: JsonNode, type: JavaType): T? = + try { + readValue(treeAsTokens(node), type) + } catch (e: Exception) { + null + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/BaseSerializer.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/BaseSerializer.kt new file mode 100644 index 00000000..b62dd939 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/BaseSerializer.kt @@ -0,0 +1,6 @@ +package com.courier.api.core + +import com.fasterxml.jackson.databind.ser.std.StdSerializer +import kotlin.reflect.KClass + +abstract class BaseSerializer(type: KClass) : StdSerializer(type.java) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt new file mode 100644 index 00000000..c1e1eaf5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt @@ -0,0 +1,96 @@ +@file:JvmName("Check") + +package com.courier.api.core + +import com.fasterxml.jackson.core.Version +import com.fasterxml.jackson.core.util.VersionUtil + +fun checkRequired(name: String, condition: Boolean) = + check(condition) { "`$name` is required, but was not set" } + +fun checkRequired(name: String, value: T?): T = + checkNotNull(value) { "`$name` is required, but was not set" } + +@JvmSynthetic +internal fun checkKnown(name: String, value: JsonField): T = + value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkKnown(name: String, value: MultipartField): T = + value.value.asKnown().orElseThrow { + IllegalStateException("`$name` is not a known type: ${value.javaClass.simpleName}") + } + +@JvmSynthetic +internal fun checkLength(name: String, value: String, length: Int): String = + value.also { + check(it.length == length) { "`$name` must have length $length, but was ${it.length}" } + } + +@JvmSynthetic +internal fun checkMinLength(name: String, value: String, minLength: Int): String = + value.also { + check(it.length >= minLength) { + if (minLength == 1) "`$name` must be non-empty, but was empty" + else "`$name` must have at least length $minLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkMaxLength(name: String, value: String, maxLength: Int): String = + value.also { + check(it.length <= maxLength) { + "`$name` must have at most length $maxLength, but was ${it.length}" + } + } + +@JvmSynthetic +internal fun checkJacksonVersionCompatibility() { + val incompatibleJacksonVersions = + RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] + when { + it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> + it to "incompatible major version" + it.minorVersion < MINIMUM_JACKSON_VERSION.minorVersion -> + it to "minor version too low" + it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && + it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> + it to "patch version too low" + badVersionReason != null -> it to badVersionReason + else -> null + } + } + check(incompatibleJacksonVersions.isEmpty()) { + """ +This SDK requires a minimum Jackson version of $MINIMUM_JACKSON_VERSION, but the following incompatible Jackson versions were detected at runtime: + +${incompatibleJacksonVersions.asSequence().map { (version, incompatibilityReason) -> + "- `${version.toFullString().replace("/", ":")}` ($incompatibilityReason)" +}.joinToString("\n")} + +This can happen if you are either: +1. Directly depending on different Jackson versions +2. Depending on some library that depends on different Jackson versions, potentially transitively + +Double-check that you are depending on compatible Jackson versions. + +See https://www.github.com/stainless-sdks/courier-java#jackson for more information. + """ + .trimIndent() + } +} + +private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") +private val RUNTIME_JACKSON_VERSIONS: List = + listOf( + com.fasterxml.jackson.core.json.PackageVersion.VERSION, + com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jdk8.PackageVersion.VERSION, + com.fasterxml.jackson.datatype.jsr310.PackageVersion.VERSION, + com.fasterxml.jackson.module.kotlin.PackageVersion.VERSION, + ) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/ClientOptions.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/ClientOptions.kt new file mode 100644 index 00000000..232898e7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/ClientOptions.kt @@ -0,0 +1,450 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.core + +import com.courier.api.core.http.Headers +import com.courier.api.core.http.HttpClient +import com.courier.api.core.http.PhantomReachableClosingHttpClient +import com.courier.api.core.http.QueryParams +import com.courier.api.core.http.RetryingHttpClient +import com.fasterxml.jackson.databind.json.JsonMapper +import java.time.Clock +import java.time.Duration +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class representing the SDK client configuration. */ +class ClientOptions +private constructor( + private val originalHttpClient: HttpClient, + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `courier-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + @get:JvmName("httpClient") val httpClient: HttpClient, + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee that + * the SDK will work correctly when using an incompatible Jackson version. + */ + @get:JvmName("checkJacksonVersionCompatibility") val checkJacksonVersionCompatibility: Boolean, + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.courier.api.core.jsonMapper]. The default is usually sufficient and rarely + * needs to be overridden. + */ + @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + @get:JvmName("sleeper") val sleeper: Sleeper, + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + @get:JvmName("clock") val clock: Clock, + private val baseUrl: String?, + /** Headers to send with the request. */ + @get:JvmName("headers") val headers: Headers, + /** Query params to send with the request. */ + @get:JvmName("queryParams") val queryParams: QueryParams, + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + @get:JvmName("responseValidation") val responseValidation: Boolean, + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + @get:JvmName("timeout") val timeout: Timeout, + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + @get:JvmName("maxRetries") val maxRetries: Int, + @get:JvmName("apiKey") val apiKey: String, +) { + + init { + if (checkJacksonVersionCompatibility) { + checkJacksonVersionCompatibility() + } + } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.courier.com`. + */ + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + + fun toBuilder() = Builder().from(this) + + companion object { + + const val PRODUCTION_URL = "https://api.courier.com" + + /** + * Returns a mutable builder for constructing an instance of [ClientOptions]. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns options configured using system properties and environment variables. + * + * @see Builder.fromEnv + */ + @JvmStatic fun fromEnv(): ClientOptions = builder().fromEnv().build() + } + + /** A builder for [ClientOptions]. */ + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var checkJacksonVersionCompatibility: Boolean = true + private var jsonMapper: JsonMapper = jsonMapper() + private var sleeper: Sleeper? = null + private var clock: Clock = Clock.systemUTC() + private var baseUrl: String? = null + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() + private var responseValidation: Boolean = false + private var timeout: Timeout = Timeout.default() + private var maxRetries: Int = 2 + private var apiKey: String? = null + + @JvmSynthetic + internal fun from(clientOptions: ClientOptions) = apply { + httpClient = clientOptions.originalHttpClient + checkJacksonVersionCompatibility = clientOptions.checkJacksonVersionCompatibility + jsonMapper = clientOptions.jsonMapper + sleeper = clientOptions.sleeper + clock = clientOptions.clock + baseUrl = clientOptions.baseUrl + headers = clientOptions.headers.toBuilder() + queryParams = clientOptions.queryParams.toBuilder() + responseValidation = clientOptions.responseValidation + timeout = clientOptions.timeout + maxRetries = clientOptions.maxRetries + apiKey = clientOptions.apiKey + } + + /** + * The HTTP client to use in the SDK. + * + * Use the one published in `courier-java-client-okhttp` or implement your own. + * + * This class takes ownership of the client and closes it when closed. + */ + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } + + /** + * Whether to throw an exception if any of the Jackson versions detected at runtime are + * incompatible with the SDK's minimum supported Jackson version (2.13.4). + * + * Defaults to true. Use extreme caution when disabling this option. There is no guarantee + * that the SDK will work correctly when using an incompatible Jackson version. + */ + fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { + this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility + } + + /** + * The Jackson JSON mapper to use for serializing and deserializing JSON. + * + * Defaults to [com.courier.api.core.jsonMapper]. The default is usually sufficient and + * rarely needs to be overridden. + */ + fun jsonMapper(jsonMapper: JsonMapper) = apply { this.jsonMapper = jsonMapper } + + /** + * The interface to use for delaying execution, like during retries. + * + * This is primarily useful for using fake delays in tests. + * + * Defaults to real execution delays. + * + * This class takes ownership of the sleeper and closes it when closed. + */ + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = PhantomReachableSleeper(sleeper) } + + /** + * The clock to use for operations that require timing, like retries. + * + * This is primarily useful for using a fake clock in tests. + * + * Defaults to [Clock.systemUTC]. + */ + fun clock(clock: Clock) = apply { this.clock = clock } + + /** + * The base URL to use for every request. + * + * Defaults to the production environment: `https://api.courier.com`. + */ + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + + /** + * Whether to call `validate` on every response before returning it. + * + * Defaults to false, which means the shape of the response will not be validated upfront. + * Instead, validation will only occur for the parts of the response that are accessed. + */ + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + /** + * Sets the maximum time allowed for various parts of an HTTP call's lifecycle, excluding + * retries. + * + * Defaults to [Timeout.default]. + */ + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + /** + * Sets the maximum time allowed for a complete HTTP call, not including retries. + * + * See [Timeout.request] for more details. + * + * For fine-grained control, pass a [Timeout] object. + */ + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + /** + * The maximum number of times to retry failed requests, with a short exponential backoff + * between requests. + * + * Only the following error types are retried: + * - Connection errors (for example, due to a network connectivity problem) + * - 408 Request Timeout + * - 409 Conflict + * - 429 Rate Limit + * - 5xx Internal + * + * The API may also explicitly instruct the SDK to retry or not retry a request. + * + * Defaults to 2. + */ + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun timeout(): Timeout = timeout + + /** + * Updates configuration using system properties and environment variables. + * + * See this table for the available options: + * + * |Setter |System property |Environment variable|Required|Default value | + * |---------|-----------------|--------------------|--------|---------------------------| + * |`apiKey` |`courier.apiKey` |`COURIER_API_KEY` |true |- | + * |`baseUrl`|`courier.baseUrl`|`COURIER_BASE_URL` |true |`"https://api.courier.com"`| + * + * System properties take precedence over environment variables. + */ + fun fromEnv() = apply { + (System.getProperty("courier.baseUrl") ?: System.getenv("COURIER_BASE_URL"))?.let { + baseUrl(it) + } + (System.getProperty("courier.apiKey") ?: System.getenv("COURIER_API_KEY"))?.let { + apiKey(it) + } + } + + /** + * Returns an immutable instance of [ClientOptions]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .httpClient() + * .apiKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ClientOptions { + val httpClient = checkRequired("httpClient", httpClient) + val sleeper = sleeper ?: PhantomReachableSleeper(DefaultSleeper()) + val apiKey = checkRequired("apiKey", apiKey) + + val headers = Headers.builder() + val queryParams = QueryParams.builder() + headers.put("X-Stainless-Lang", "java") + headers.put("X-Stainless-Arch", getOsArch()) + headers.put("X-Stainless-OS", getOsName()) + headers.put("X-Stainless-OS-Version", getOsVersion()) + headers.put("X-Stainless-Package-Version", getPackageVersion()) + headers.put("X-Stainless-Runtime", "JRE") + headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + apiKey.let { + if (!it.isEmpty()) { + headers.put("Authorization", "Bearer $it") + } + } + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) + + return ClientOptions( + httpClient, + RetryingHttpClient.builder() + .httpClient(httpClient) + .sleeper(sleeper) + .clock(clock) + .maxRetries(maxRetries) + .build(), + checkJacksonVersionCompatibility, + jsonMapper, + sleeper, + clock, + baseUrl, + headers.build(), + queryParams.build(), + responseValidation, + timeout, + maxRetries, + apiKey, + ) + } + } + + /** + * Closes these client options, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because the client options are + * long-lived and usually should not be synchronously closed via try-with-resources. + * + * It's also usually not necessary to call this method at all. the default client automatically + * releases threads and connections if they remain idle, but if you are writing an application + * that needs to aggressively release unused resources, then you may call this method. + */ + fun close() { + httpClient.close() + sleeper.close() + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/DefaultSleeper.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/DefaultSleeper.kt new file mode 100644 index 00000000..e068e204 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/DefaultSleeper.kt @@ -0,0 +1,28 @@ +package com.courier.api.core + +import java.time.Duration +import java.util.Timer +import java.util.TimerTask +import java.util.concurrent.CompletableFuture + +class DefaultSleeper : Sleeper { + + private val timer = Timer("DefaultSleeper", true) + + override fun sleep(duration: Duration) = Thread.sleep(duration.toMillis()) + + override fun sleepAsync(duration: Duration): CompletableFuture { + val future = CompletableFuture() + timer.schedule( + object : TimerTask() { + override fun run() { + future.complete(null) + } + }, + duration.toMillis(), + ) + return future + } + + override fun close() = timer.cancel() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/ObjectMappers.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/ObjectMappers.kt new file mode 100644 index 00000000..5cfc46de --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/ObjectMappers.kt @@ -0,0 +1,167 @@ +@file:JvmName("ObjectMappers") + +package com.courier.api.core + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.JsonParseException +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.DeserializationFeature +import com.fasterxml.jackson.databind.MapperFeature +import com.fasterxml.jackson.databind.SerializationFeature +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.cfg.CoercionAction +import com.fasterxml.jackson.databind.cfg.CoercionInputShape +import com.fasterxml.jackson.databind.deser.std.StdDeserializer +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.module.SimpleModule +import com.fasterxml.jackson.databind.type.LogicalType +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule +import com.fasterxml.jackson.module.kotlin.kotlinModule +import java.io.InputStream +import java.time.DateTimeException +import java.time.LocalDate +import java.time.LocalDateTime +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter +import java.time.temporal.ChronoField + +fun jsonMapper(): JsonMapper = + JsonMapper.builder() + .addModule(kotlinModule()) + .addModule(Jdk8Module()) + .addModule(JavaTimeModule()) + .addModule( + SimpleModule() + .addSerializer(InputStreamSerializer) + .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + ) + .withCoercionConfig(LogicalType.Boolean) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Integer) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Float) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Textual) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Array) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Collection) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.Map) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } + .withCoercionConfig(LogicalType.POJO) { + it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.String, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + } + .serializationInclusion(JsonInclude.Include.NON_ABSENT) + .disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE) + .disable(SerializationFeature.FLUSH_AFTER_WRITE_VALUE) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS) + .disable(MapperFeature.ALLOW_COERCION_OF_SCALARS) + .disable(MapperFeature.AUTO_DETECT_CREATORS) + .disable(MapperFeature.AUTO_DETECT_FIELDS) + .disable(MapperFeature.AUTO_DETECT_GETTERS) + .disable(MapperFeature.AUTO_DETECT_IS_GETTERS) + .disable(MapperFeature.AUTO_DETECT_SETTERS) + .build() + +/** A serializer that serializes [InputStream] to bytes. */ +private object InputStreamSerializer : BaseSerializer(InputStream::class) { + + private fun readResolve(): Any = InputStreamSerializer + + override fun serialize( + value: InputStream?, + gen: JsonGenerator?, + serializers: SerializerProvider?, + ) { + if (value == null) { + gen?.writeNull() + } else { + value.use { gen?.writeBinary(it.readBytes()) } + } + } +} + +/** + * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + */ +private class LenientLocalDateTimeDeserializer : + StdDeserializer(LocalDateTime::class.java) { + + companion object { + + private val DATE_TIME_FORMATTERS = + listOf( + DateTimeFormatter.ISO_LOCAL_DATE_TIME, + DateTimeFormatter.ISO_LOCAL_DATE, + DateTimeFormatter.ISO_ZONED_DATE_TIME, + ) + } + + override fun logicalType(): LogicalType = LogicalType.DateTime + + override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + val exceptions = mutableListOf() + + for (formatter in DATE_TIME_FORMATTERS) { + try { + val temporal = formatter.parse(p.text) + + return when { + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + } catch (e: DateTimeException) { + exceptions.add(e) + } + } + + throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + exceptions.forEach { addSuppressed(it) } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Params.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Params.kt new file mode 100644 index 00000000..a04c55b9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Params.kt @@ -0,0 +1,16 @@ +package com.courier.api.core + +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams + +/** An interface representing parameters passed to a service method. */ +interface Params { + /** The full set of headers in the parameters, including both fixed and additional headers. */ + fun _headers(): Headers + + /** + * The full set of query params in the parameters, including both fixed and additional query + * params. + */ + fun _queryParams(): QueryParams +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachable.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachable.kt new file mode 100644 index 00000000..42ae140e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachable.kt @@ -0,0 +1,56 @@ +@file:JvmName("PhantomReachable") + +package com.courier.api.core + +import com.courier.api.errors.CourierException +import java.lang.reflect.InvocationTargetException + +/** + * Closes [closeable] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, closeable: AutoCloseable) { + check(observed !== closeable) { + "`observed` cannot be the same object as `closeable` because it would never become phantom reachable" + } + closeWhenPhantomReachable(observed, closeable::close) +} + +/** + * Calls [close] when [observed] becomes only phantom reachable. + * + * This is a wrapper around a Java 9+ [java.lang.ref.Cleaner], or a no-op in older Java versions. + */ +@JvmSynthetic +internal fun closeWhenPhantomReachable(observed: Any, close: () -> Unit) { + closeWhenPhantomReachable?.let { it(observed, close) } +} + +private val closeWhenPhantomReachable: ((Any, () -> Unit) -> Unit)? by lazy { + try { + val cleanerClass = Class.forName("java.lang.ref.Cleaner") + val cleanerCreate = cleanerClass.getMethod("create") + val cleanerRegister = + cleanerClass.getMethod("register", Any::class.java, Runnable::class.java) + val cleanerObject = cleanerCreate.invoke(null); + + { observed, close -> + try { + cleanerRegister.invoke(cleanerObject, observed, Runnable { close() }) + } catch (e: ReflectiveOperationException) { + if (e is InvocationTargetException) { + when (val cause = e.cause) { + is RuntimeException, + is Error -> throw cause + } + } + throw CourierException("Unexpected reflective invocation failure", e) + } + } + } catch (e: ReflectiveOperationException) { + // We're running Java 8, which has no Cleaner. + null + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableExecutorService.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableExecutorService.kt new file mode 100644 index 00000000..20e6c410 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableExecutorService.kt @@ -0,0 +1,58 @@ +package com.courier.api.core + +import java.util.concurrent.Callable +import java.util.concurrent.ExecutorService +import java.util.concurrent.Future +import java.util.concurrent.TimeUnit + +/** + * A delegating wrapper around an [ExecutorService] that shuts it down once it's only phantom + * reachable. + * + * This class ensures the [ExecutorService] is shut down even if the user forgets to do it. + */ +internal class PhantomReachableExecutorService(private val executorService: ExecutorService) : + ExecutorService { + init { + closeWhenPhantomReachable(this) { executorService.shutdown() } + } + + override fun execute(command: Runnable) = executorService.execute(command) + + override fun shutdown() = executorService.shutdown() + + override fun shutdownNow(): MutableList = executorService.shutdownNow() + + override fun isShutdown(): Boolean = executorService.isShutdown + + override fun isTerminated(): Boolean = executorService.isTerminated + + override fun awaitTermination(timeout: Long, unit: TimeUnit): Boolean = + executorService.awaitTermination(timeout, unit) + + override fun submit(task: Callable): Future = executorService.submit(task) + + override fun submit(task: Runnable, result: T): Future = + executorService.submit(task, result) + + override fun submit(task: Runnable): Future<*> = executorService.submit(task) + + override fun invokeAll( + tasks: MutableCollection> + ): MutableList> = executorService.invokeAll(tasks) + + override fun invokeAll( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): MutableList> = executorService.invokeAll(tasks, timeout, unit) + + override fun invokeAny(tasks: MutableCollection>): T = + executorService.invokeAny(tasks) + + override fun invokeAny( + tasks: MutableCollection>, + timeout: Long, + unit: TimeUnit, + ): T = executorService.invokeAny(tasks, timeout, unit) +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableSleeper.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableSleeper.kt new file mode 100644 index 00000000..6af9d159 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/PhantomReachableSleeper.kt @@ -0,0 +1,23 @@ +package com.courier.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around a [Sleeper] that closes it once it's only phantom reachable. + * + * This class ensures the [Sleeper] is closed even if the user forgets to do it. + */ +internal class PhantomReachableSleeper(private val sleeper: Sleeper) : Sleeper { + + init { + closeWhenPhantomReachable(this, sleeper) + } + + override fun sleep(duration: Duration) = sleeper.sleep(duration) + + override fun sleepAsync(duration: Duration): CompletableFuture = + sleeper.sleepAsync(duration) + + override fun close() = sleeper.close() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/PrepareRequest.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/PrepareRequest.kt new file mode 100644 index 00000000..0864d52b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/PrepareRequest.kt @@ -0,0 +1,24 @@ +@file:JvmName("PrepareRequest") + +package com.courier.api.core + +import com.courier.api.core.http.HttpRequest +import java.util.concurrent.CompletableFuture + +@JvmSynthetic +internal fun HttpRequest.prepare(clientOptions: ClientOptions, params: Params): HttpRequest = + toBuilder() + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params._queryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params._headers()) + .build() + +@JvmSynthetic +internal fun HttpRequest.prepareAsync( + clientOptions: ClientOptions, + params: Params, +): CompletableFuture = + // This async version exists to make it easier to add async specific preparation logic in the + // future. + CompletableFuture.completedFuture(prepare(clientOptions, params)) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Properties.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Properties.kt new file mode 100644 index 00000000..e2c8c5f6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Properties.kt @@ -0,0 +1,42 @@ +@file:JvmName("Properties") + +package com.courier.api.core + +import com.courier.api.client.CourierClient + +fun getOsArch(): String { + val osArch = System.getProperty("os.arch") + + return when (osArch) { + null -> "unknown" + "i386", + "x32", + "x86" -> "x32" + "amd64", + "x86_64" -> "x64" + "arm" -> "arm" + "aarch64" -> "arm64" + else -> "other:$osArch" + } +} + +fun getOsName(): String { + val osName = System.getProperty("os.name") + val vendorUrl = System.getProperty("java.vendor.url") + + return when { + osName == null -> "Unknown" + osName.startsWith("Linux") && vendorUrl == "http://www.android.com/" -> "Android" + osName.startsWith("Linux") -> "Linux" + osName.startsWith("Mac OS") -> "MacOS" + osName.startsWith("Windows") -> "Windows" + else -> "Other:$osName" + } +} + +fun getOsVersion(): String = System.getProperty("os.version", "unknown") + +fun getPackageVersion(): String = + CourierClient::class.java.`package`.implementationVersion ?: "unknown" + +fun getJavaVersion(): String = System.getProperty("java.version", "unknown") diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/RequestOptions.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/RequestOptions.kt new file mode 100644 index 00000000..40194eea --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/RequestOptions.kt @@ -0,0 +1,46 @@ +package com.courier.api.core + +import java.time.Duration + +class RequestOptions private constructor(val responseValidation: Boolean?, val timeout: Timeout?) { + + companion object { + + private val NONE = builder().build() + + @JvmStatic fun none() = NONE + + @JvmSynthetic + internal fun from(clientOptions: ClientOptions): RequestOptions = + builder() + .responseValidation(clientOptions.responseValidation) + .timeout(clientOptions.timeout) + .build() + + @JvmStatic fun builder() = Builder() + } + + fun applyDefaults(options: RequestOptions): RequestOptions = + RequestOptions( + responseValidation = responseValidation ?: options.responseValidation, + timeout = + if (options.timeout != null && timeout != null) timeout.assign(options.timeout) + else timeout ?: options.timeout, + ) + + class Builder internal constructor() { + + private var responseValidation: Boolean? = null + private var timeout: Timeout? = null + + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun timeout(timeout: Timeout) = apply { this.timeout = timeout } + + fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) + + fun build(): RequestOptions = RequestOptions(responseValidation, timeout) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Sleeper.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Sleeper.kt new file mode 100644 index 00000000..3289f942 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Sleeper.kt @@ -0,0 +1,21 @@ +package com.courier.api.core + +import java.time.Duration +import java.util.concurrent.CompletableFuture + +/** + * An interface for delaying execution for a specified amount of time. + * + * Useful for testing and cleaning up resources. + */ +interface Sleeper : AutoCloseable { + + /** Synchronously pauses execution for the given [duration]. */ + fun sleep(duration: Duration) + + /** Asynchronously pauses execution for the given [duration]. */ + fun sleepAsync(duration: Duration): CompletableFuture + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Timeout.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Timeout.kt new file mode 100644 index 00000000..614a6434 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Timeout.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.core + +import java.time.Duration +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A class containing timeouts for various processing phases of a request. */ +class Timeout +private constructor( + private val connect: Duration?, + private val read: Duration?, + private val write: Duration?, + private val request: Duration?, +) { + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(): Duration = connect ?: Duration.ofMinutes(1) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(): Duration = read ?: request() + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(): Duration = write ?: request() + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as well + * as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(): Duration = request ?: Duration.ofMinutes(1) + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun default() = builder().build() + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var connect: Duration? = null + private var read: Duration? = null + private var write: Duration? = null + private var request: Duration? = null + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + connect = timeout.connect + read = timeout.read + write = timeout.write + request = timeout.request + } + + /** + * The maximum time allowed to establish a connection with a host. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun connect(connect: Duration?) = apply { this.connect = connect } + + /** Alias for calling [Builder.connect] with `connect.orElse(null)`. */ + fun connect(connect: Optional) = connect(connect.getOrNull()) + + /** + * The maximum time allowed between two data packets when waiting for the server’s response. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun read(read: Duration?) = apply { this.read = read } + + /** Alias for calling [Builder.read] with `read.orElse(null)`. */ + fun read(read: Optional) = read(read.getOrNull()) + + /** + * The maximum time allowed between two data packets when sending the request to the server. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `request()`. + */ + fun write(write: Duration?) = apply { this.write = write } + + /** Alias for calling [Builder.write] with `write.orElse(null)`. */ + fun write(write: Optional) = write(write.getOrNull()) + + /** + * The maximum time allowed for a complete HTTP call, not including retries. + * + * This includes resolving DNS, connecting, writing the request body, server processing, as + * well as reading the response body. + * + * A value of [Duration.ZERO] means there's no timeout. + * + * Defaults to `Duration.ofMinutes(1)`. + */ + fun request(request: Duration?) = apply { this.request = request } + + /** Alias for calling [Builder.request] with `request.orElse(null)`. */ + fun request(request: Optional) = request(request.getOrNull()) + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = Timeout(connect, read, write, request) + } + + @JvmSynthetic + internal fun assign(target: Timeout): Timeout = + target + .toBuilder() + .apply { + connect?.let(this::connect) + read?.let(this::read) + write?.let(this::write) + request?.let(this::request) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Timeout && + connect == other.connect && + read == other.read && + write == other.write && + request == other.request + } + + override fun hashCode(): Int = Objects.hash(connect, read, write, request) + + override fun toString() = + "Timeout{connect=$connect, read=$read, write=$write, request=$request}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Utils.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Utils.kt new file mode 100644 index 00000000..cac76471 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Utils.kt @@ -0,0 +1,115 @@ +@file:JvmName("Utils") + +package com.courier.api.core + +import com.courier.api.errors.CourierInvalidDataException +import java.util.Collections +import java.util.SortedMap +import java.util.concurrent.CompletableFuture +import java.util.concurrent.locks.Lock + +@JvmSynthetic +internal fun T?.getOrThrow(name: String): T = + this ?: throw CourierInvalidDataException("`${name}` is not present") + +@JvmSynthetic +internal fun List.toImmutable(): List = + if (isEmpty()) Collections.emptyList() else Collections.unmodifiableList(toList()) + +@JvmSynthetic +internal fun Map.toImmutable(): Map = + if (isEmpty()) immutableEmptyMap() else Collections.unmodifiableMap(toMap()) + +@JvmSynthetic internal fun immutableEmptyMap(): Map = Collections.emptyMap() + +@JvmSynthetic +internal fun , V> SortedMap.toImmutable(): SortedMap = + if (isEmpty()) Collections.emptySortedMap() + else Collections.unmodifiableSortedMap(toSortedMap(comparator())) + +/** + * Returns all elements that yield the largest value for the given function, or an empty list if + * there are zero elements. + * + * This is similar to [Sequence.maxByOrNull] except it returns _all_ elements that yield the largest + * value; not just the first one. + */ +@JvmSynthetic +internal fun > Sequence.allMaxBy(selector: (T) -> R): List { + var maxValue: R? = null + val maxElements = mutableListOf() + + val iterator = iterator() + while (iterator.hasNext()) { + val element = iterator.next() + val value = selector(element) + if (maxValue == null || value > maxValue) { + maxValue = value + maxElements.clear() + maxElements.add(element) + } else if (value == maxValue) { + maxElements.add(element) + } + } + + return maxElements +} + +/** + * Returns whether [this] is equal to [other]. + * + * This differs from [Object.equals] because it also deeply equates arrays based on their contents, + * even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal infix fun Any?.contentEquals(other: Any?): Boolean = + arrayOf(this).contentDeepEquals(arrayOf(other)) + +/** + * Returns a hash of the given sequence of [values]. + * + * This differs from [java.util.Objects.hash] because it also deeply hashes arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic internal fun contentHash(vararg values: Any?): Int = values.contentDeepHashCode() + +/** + * Returns a [String] representation of [this]. + * + * This differs from [Object.toString] because it also deeply stringifies arrays based on their + * contents, even when there are arrays directly nested within other arrays. + */ +@JvmSynthetic +internal fun Any?.contentToString(): String { + var string = arrayOf(this).contentDeepToString() + if (string.startsWith('[')) { + string = string.substring(1) + } + if (string.endsWith(']')) { + string = string.substring(0, string.length - 1) + } + return string +} + +internal interface Enum + +/** + * Executes the given [action] while holding the lock, returning a [CompletableFuture] with the + * result. + * + * @param action The asynchronous action to execute while holding the lock + * @return A [CompletableFuture] that completes with the result of the action + */ +@JvmSynthetic +internal fun Lock.withLockAsync(action: () -> CompletableFuture): CompletableFuture { + lock() + val future = + try { + action() + } catch (e: Throwable) { + unlock() + throw e + } + future.whenComplete { _, _ -> unlock() } + return future +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt new file mode 100644 index 00000000..4017bb76 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Values.kt @@ -0,0 +1,723 @@ +package com.courier.api.core + +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JacksonAnnotationsInside +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.BeanProperty +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.JavaType +import com.fasterxml.jackson.databind.JsonDeserializer +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.databind.node.JsonNodeType.ARRAY +import com.fasterxml.jackson.databind.node.JsonNodeType.BINARY +import com.fasterxml.jackson.databind.node.JsonNodeType.BOOLEAN +import com.fasterxml.jackson.databind.node.JsonNodeType.MISSING +import com.fasterxml.jackson.databind.node.JsonNodeType.NULL +import com.fasterxml.jackson.databind.node.JsonNodeType.NUMBER +import com.fasterxml.jackson.databind.node.JsonNodeType.OBJECT +import com.fasterxml.jackson.databind.node.JsonNodeType.POJO +import com.fasterxml.jackson.databind.node.JsonNodeType.STRING +import com.fasterxml.jackson.databind.ser.std.NullSerializer +import java.io.InputStream +import java.util.Objects +import java.util.Optional + +/** + * A class representing a serializable JSON field. + * + * It can either be a [KnownValue] value of type [T], matching the type the SDK expects, or an + * arbitrary JSON value that bypasses the type system (via [JsonValue]). + */ +@JsonDeserialize(using = JsonField.Deserializer::class) +sealed class JsonField { + + /** + * Returns whether this field is missing, which means it will be omitted from the serialized + * JSON entirely. + */ + fun isMissing(): Boolean = this is JsonMissing + + /** Whether this field is explicitly set to `null`. */ + fun isNull(): Boolean = this is JsonNull + + /** + * Returns an [Optional] containing this field's "known" value, meaning it matches the type the + * SDK expects, or an empty [Optional] if this field contains an arbitrary [JsonValue]. + * + * This is the opposite of [asUnknown]. + */ + fun asKnown(): + Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = Optional.ofNullable((this as? KnownValue)?.value) + + /** + * Returns an [Optional] containing this field's arbitrary [JsonValue], meaning it mismatches + * the type the SDK expects, or an empty [Optional] if this field contains a "known" value. + * + * This is the opposite of [asKnown]. + */ + fun asUnknown(): Optional = Optional.ofNullable(this as? JsonValue) + + /** + * Returns an [Optional] containing this field's boolean value, or an empty [Optional] if it + * doesn't contain a boolean. + * + * This method checks for both a [KnownValue] containing a boolean and for [JsonBoolean]. + */ + fun asBoolean(): Optional = + when (this) { + is JsonBoolean -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Boolean) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's numerical value, or an empty [Optional] if it + * doesn't contain a number. + * + * This method checks for both a [KnownValue] containing a number and for [JsonNumber]. + */ + fun asNumber(): Optional = + when (this) { + is JsonNumber -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? Number) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's string value, or an empty [Optional] if it + * doesn't contain a string. + * + * This method checks for both a [KnownValue] containing a string and for [JsonString]. + */ + fun asString(): Optional = + when (this) { + is JsonString -> Optional.of(value) + is KnownValue -> Optional.ofNullable(value as? String) + else -> Optional.empty() + } + + fun asStringOrThrow(): String = + asString().orElseThrow { CourierInvalidDataException("Value is not a string") } + + /** + * Returns an [Optional] containing this field's list value, or an empty [Optional] if it + * doesn't contain a list. + * + * This method checks for both a [KnownValue] containing a list and for [JsonArray]. + */ + fun asArray(): Optional> = + when (this) { + is JsonArray -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? List<*>)?.map { + try { + JsonValue.from(it) + } catch (e: IllegalArgumentException) { + // The known value is a list, but not all values are convertible to + // `JsonValue`. + return Optional.empty() + } + } + ) + else -> Optional.empty() + } + + /** + * Returns an [Optional] containing this field's map value, or an empty [Optional] if it doesn't + * contain a map. + * + * This method checks for both a [KnownValue] containing a map and for [JsonObject]. + */ + fun asObject(): Optional> = + when (this) { + is JsonObject -> Optional.of(values) + is KnownValue -> + Optional.ofNullable( + (value as? Map<*, *>) + ?.map { (key, value) -> + if (key !is String) { + return Optional.empty() + } + + val jsonValue = + try { + JsonValue.from(value) + } catch (e: IllegalArgumentException) { + // The known value is a map, but not all items are convertible + // to `JsonValue`. + return Optional.empty() + } + + key to jsonValue + } + ?.toMap() + ) + else -> Optional.empty() + } + + @JvmSynthetic + internal fun getRequired(name: String): T = + when (this) { + is KnownValue -> value + is JsonMissing -> throw CourierInvalidDataException("`$name` is not set") + is JsonNull -> throw CourierInvalidDataException("`$name` is null") + else -> throw CourierInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun getOptional( + name: String + ): Optional< + // Safe because `Optional` is effectively covariant, but Kotlin doesn't know that. + @UnsafeVariance + T + > = + when (this) { + is KnownValue -> Optional.of(value) + is JsonMissing, + is JsonNull -> Optional.empty() + else -> throw CourierInvalidDataException("`$name` is invalid, received $this") + } + + @JvmSynthetic + internal fun map(transform: (T) -> R): JsonField = + when (this) { + is KnownValue -> KnownValue.of(transform(value)) + is JsonValue -> this + } + + @JvmSynthetic internal fun accept(consume: (T) -> Unit) = asKnown().ifPresent(consume) + + /** Returns the result of calling the [visitor] method corresponding to this field's state. */ + fun accept(visitor: Visitor): R = + when (this) { + is KnownValue -> visitor.visitKnown(value) + is JsonValue -> accept(visitor as JsonValue.Visitor) + } + + /** + * An interface that defines how to map each possible state of a `JsonField` to a value of + * type [R]. + */ + interface Visitor : JsonValue.Visitor { + + fun visitKnown(value: T): R = visitDefault() + } + + companion object { + + /** Returns a [JsonField] containing the given "known" [value]. */ + @JvmStatic fun of(value: T): JsonField = KnownValue.of(value) + + /** + * Returns a [JsonField] containing the given "known" [value], or [JsonNull] if [value] is + * null. + */ + @JvmStatic + fun ofNullable(value: T?): JsonField = + when (value) { + null -> JsonNull.of() + else -> KnownValue.of(value) + } + } + + /** + * This class is a Jackson filter that can be used to exclude missing properties from objects. + * This filter should not be used directly and should instead use the @ExcludeMissing + * annotation. + */ + class IsMissing { + + override fun equals(other: Any?): Boolean = other is JsonMissing + + override fun hashCode(): Int = Objects.hash() + } + + class Deserializer(private val type: JavaType? = null) : + BaseDeserializer>(JsonField::class) { + + override fun createContextual( + context: DeserializationContext, + property: BeanProperty?, + ): JsonDeserializer> = Deserializer(context.contextualType?.containedType(0)) + + override fun ObjectCodec.deserialize(node: JsonNode): JsonField<*> = + type?.let { tryDeserialize(node, type) }?.let { of(it) } + ?: JsonValue.fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext): JsonField<*> = JsonNull.of() + } +} + +/** + * A class representing an arbitrary JSON value. + * + * It is immutable and assignable to any [JsonField], regardless of its expected type (i.e. its + * generic type argument). + */ +@JsonDeserialize(using = JsonValue.Deserializer::class) +sealed class JsonValue : JsonField() { + + fun convert(type: TypeReference): R? = JSON_MAPPER.convertValue(this, type) + + fun convert(type: Class): R? = JSON_MAPPER.convertValue(this, type) + + /** Returns the result of calling the [visitor] method corresponding to this value's variant. */ + fun accept(visitor: Visitor): R = + when (this) { + is JsonMissing -> visitor.visitMissing() + is JsonNull -> visitor.visitNull() + is JsonBoolean -> visitor.visitBoolean(value) + is JsonNumber -> visitor.visitNumber(value) + is JsonString -> visitor.visitString(value) + is JsonArray -> visitor.visitArray(values) + is JsonObject -> visitor.visitObject(values) + } + + /** + * An interface that defines how to map each variant state of a [JsonValue] to a value of type + * [R]. + */ + interface Visitor { + + fun visitNull(): R = visitDefault() + + fun visitMissing(): R = visitDefault() + + fun visitBoolean(value: Boolean): R = visitDefault() + + fun visitNumber(value: Number): R = visitDefault() + + fun visitString(value: String): R = visitDefault() + + fun visitArray(values: List): R = visitDefault() + + fun visitObject(values: Map): R = visitDefault() + + /** + * The default implementation for unimplemented visitor methods. + * + * @throws IllegalArgumentException in the default implementation. + */ + fun visitDefault(): R = throw IllegalArgumentException("Unexpected value") + } + + companion object { + + private val JSON_MAPPER = jsonMapper() + + /** + * Converts the given [value] to a [JsonValue]. + * + * This method works best on primitive types, [List] values, [Map] values, and nested + * combinations of these. For example: + * ```java + * // Create primitive JSON values + * JsonValue nullValue = JsonValue.from(null); + * JsonValue booleanValue = JsonValue.from(true); + * JsonValue numberValue = JsonValue.from(42); + * JsonValue stringValue = JsonValue.from("Hello World!"); + * + * // Create a JSON array value equivalent to `["Hello", "World"]` + * JsonValue arrayValue = JsonValue.from(List.of("Hello", "World")); + * + * // Create a JSON object value equivalent to `{ "a": 1, "b": 2 }` + * JsonValue objectValue = JsonValue.from(Map.of( + * "a", 1, + * "b", 2 + * )); + * + * // Create an arbitrarily nested JSON equivalent to: + * // { + * // "a": [1, 2], + * // "b": [3, 4] + * // } + * JsonValue complexValue = JsonValue.from(Map.of( + * "a", List.of(1, 2), + * "b", List.of(3, 4) + * )); + * ``` + * + * @throws IllegalArgumentException if [value] is not JSON serializable. + */ + @JvmStatic + fun from(value: Any?): JsonValue = + when (value) { + null -> JsonNull.of() + is JsonValue -> value + else -> JSON_MAPPER.convertValue(value, JsonValue::class.java) + } + + /** + * Returns a [JsonValue] converted from the given Jackson [JsonNode]. + * + * @throws IllegalStateException for unsupported node types. + */ + @JvmStatic + fun fromJsonNode(node: JsonNode): JsonValue = + when (node.nodeType) { + MISSING -> JsonMissing.of() + NULL -> JsonNull.of() + BOOLEAN -> JsonBoolean.of(node.booleanValue()) + NUMBER -> JsonNumber.of(node.numberValue()) + STRING -> JsonString.of(node.textValue()) + ARRAY -> + JsonArray.of(node.elements().asSequence().map { fromJsonNode(it) }.toList()) + OBJECT -> + JsonObject.of( + node.fields().asSequence().map { it.key to fromJsonNode(it.value) }.toMap() + ) + BINARY, + POJO, + null -> throw IllegalStateException("Unexpected JsonNode type: ${node.nodeType}") + } + } + + class Deserializer : BaseDeserializer(JsonValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): JsonValue = fromJsonNode(node) + + override fun getNullValue(context: DeserializationContext?): JsonValue = JsonNull.of() + } +} + +/** + * A class representing a "known" JSON serializable value of type [T], matching the type the SDK + * expects. + * + * It is assignable to `JsonField`. + */ +class KnownValue +private constructor( + @com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: T +) : JsonField() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KnownValue<*> && value contentEquals other.value + } + + override fun hashCode() = contentHash(value) + + override fun toString() = value.contentToString() + + companion object { + + /** Returns a [KnownValue] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: T) = KnownValue(value) + } +} + +/** + * A [JsonValue] representing an omitted JSON field. + * + * An instance of this class will cause a JSON field to be omitted from the serialized JSON + * entirely. + */ +@JsonSerialize(using = JsonMissing.Serializer::class) +class JsonMissing : JsonValue() { + + override fun toString() = "" + + companion object { + + private val INSTANCE: JsonMissing = JsonMissing() + + /** Returns the singleton instance of [JsonMissing]. */ + @JvmStatic fun of() = INSTANCE + } + + class Serializer : BaseSerializer(JsonMissing::class) { + + override fun serialize( + value: JsonMissing, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + throw IllegalStateException("JsonMissing cannot be serialized") + } + } +} + +/** A [JsonValue] representing a JSON `null` value. */ +@JsonSerialize(using = NullSerializer::class) +class JsonNull : JsonValue() { + + override fun toString() = "null" + + companion object { + + private val INSTANCE: JsonNull = JsonNull() + + /** Returns the singleton instance of [JsonMissing]. */ + @JsonCreator @JvmStatic fun of() = INSTANCE + } +} + +/** A [JsonValue] representing a JSON boolean value. */ +class JsonBoolean +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Boolean +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonBoolean && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + /** Returns a [JsonBoolean] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: Boolean) = JsonBoolean(value) + } +} + +/** A [JsonValue] representing a JSON number value. */ +class JsonNumber +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: Number +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonNumber && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + /** Returns a [JsonNumber] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: Number) = JsonNumber(value) + } +} + +/** A [JsonValue] representing a JSON string value. */ +class JsonString +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: String +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonString && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value + + companion object { + + /** Returns a [JsonString] containing the given [value]. */ + @JsonCreator @JvmStatic fun of(value: String) = JsonString(value) + } +} + +/** A [JsonValue] representing a JSON array value. */ +class JsonArray +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: List +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonArray && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + + /** Returns a [JsonArray] containing the given [values]. */ + @JsonCreator @JvmStatic fun of(values: List) = JsonArray(values.toImmutable()) + } +} + +/** A [JsonValue] representing a JSON object value. */ +class JsonObject +private constructor( + @get:com.fasterxml.jackson.annotation.JsonValue + @get:JvmName("values") + val values: Map +) : JsonValue() { + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JsonObject && values == other.values + } + + override fun hashCode() = values.hashCode() + + override fun toString() = values.toString() + + companion object { + + /** Returns a [JsonObject] containing the given [values]. */ + @JsonCreator + @JvmStatic + fun of(values: Map) = JsonObject(values.toImmutable()) + } +} + +/** A Jackson annotation for excluding fields set to [JsonMissing] from the serialized JSON. */ +@JacksonAnnotationsInside +@JsonInclude(JsonInclude.Include.CUSTOM, valueFilter = JsonField.IsMissing::class) +annotation class ExcludeMissing + +/** A class representing a field in a `multipart/form-data` request. */ +class MultipartField +private constructor( + /** A [JsonField] value, which will be serialized to zero or more parts. */ + @get:com.fasterxml.jackson.annotation.JsonValue @get:JvmName("value") val value: JsonField, + /** A content type for the serialized parts. */ + @get:JvmName("contentType") val contentType: String, + private val filename: String?, +) { + + companion object { + + /** + * Returns a [MultipartField] containing the given [value] as a [KnownValue]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: T?) = builder().value(value).build() + + /** + * Returns a [MultipartField] containing the given [value]. + * + * [contentType] will be set to `application/octet-stream` if [value] is binary data, or + * `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun of(value: JsonField) = builder().value(value).build() + + /** + * Returns a mutable builder for constructing an instance of [MultipartField]. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + */ + @JvmStatic fun builder() = Builder() + } + + /** Returns the filename directive that will be included in the serialized field. */ + fun filename(): Optional = Optional.ofNullable(filename) + + @JvmSynthetic + internal fun map(transform: (T) -> R): MultipartField = + builder().value(value.map(transform)).contentType(contentType).filename(filename).build() + + /** A builder for [MultipartField]. */ + class Builder internal constructor() { + + private var value: JsonField? = null + private var contentType: String? = null + private var filename: String? = null + + fun value(value: JsonField) = apply { this.value = value } + + fun value(value: T?) = value(JsonField.ofNullable(value)) + + fun contentType(contentType: String) = apply { this.contentType = contentType } + + fun filename(filename: String?) = apply { this.filename = filename } + + /** Alias for calling [Builder.filename] with `filename.orElse(null)`. */ + fun filename(filename: Optional) = filename(filename.orElse(null)) + + /** + * Returns an immutable instance of [MultipartField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .value() + * ``` + * + * If [contentType] is unset, then it will be set to `application/octet-stream` if [value] + * is binary data, or `text/plain; charset=utf-8` otherwise. + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MultipartField { + val value = checkRequired("value", value) + return MultipartField( + value, + contentType + ?: if ( + value is KnownValue && + (value.value is InputStream || value.value is ByteArray) + ) + "application/octet-stream" + else "text/plain; charset=utf-8", + filename, + ) + } + } + + private val hashCode: Int by lazy { contentHash(value, contentType, filename) } + + override fun hashCode(): Int = hashCode + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultipartField<*> && + value == other.value && + contentType == other.contentType && + filename == other.filename + } + + override fun toString(): String = + "MultipartField{value=$value, contentType=$contentType, filename=$filename}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt new file mode 100644 index 00000000..e4628b3a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt @@ -0,0 +1,12 @@ +@file:JvmName("EmptyHandler") + +package com.courier.api.core.handlers + +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal + +private object EmptyHandlerInternal : Handler { + override fun handle(response: HttpResponse): Void? = null +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/ErrorHandler.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/ErrorHandler.kt new file mode 100644 index 00000000..111485ae --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/ErrorHandler.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("ErrorHandler") + +package com.courier.api.core.handlers + +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.errors.BadRequestException +import com.courier.api.errors.InternalServerException +import com.courier.api.errors.NotFoundException +import com.courier.api.errors.PermissionDeniedException +import com.courier.api.errors.RateLimitException +import com.courier.api.errors.UnauthorizedException +import com.courier.api.errors.UnexpectedStatusCodeException +import com.courier.api.errors.UnprocessableEntityException +import com.fasterxml.jackson.databind.json.JsonMapper + +@JvmSynthetic +internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) + + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = + try { + handler.handle(response) + } catch (e: Exception) { + JsonMissing.of() + } + } +} + +@JvmSynthetic +internal fun errorHandler(errorBodyHandler: Handler): Handler = + object : Handler { + override fun handle(response: HttpResponse): HttpResponse = + when (val statusCode = response.statusCode()) { + in 200..299 -> response + 400 -> + throw BadRequestException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 401 -> + throw UnauthorizedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 403 -> + throw PermissionDeniedException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 404 -> + throw NotFoundException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 422 -> + throw UnprocessableEntityException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + 429 -> + throw RateLimitException.builder() + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + in 500..599 -> + throw InternalServerException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + else -> + throw UnexpectedStatusCodeException.builder() + .statusCode(statusCode) + .headers(response.headers()) + .body(errorBodyHandler.handle(response)) + .build() + } + } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/JsonHandler.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/JsonHandler.kt new file mode 100644 index 00000000..ec50c983 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/JsonHandler.kt @@ -0,0 +1,20 @@ +@file:JvmName("JsonHandler") + +package com.courier.api.core.handlers + +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef + +@JvmSynthetic +internal inline fun jsonHandler(jsonMapper: JsonMapper): Handler = + object : Handler { + override fun handle(response: HttpResponse): T = + try { + jsonMapper.readValue(response.body(), jacksonTypeRef()) + } catch (e: Exception) { + throw CourierInvalidDataException("Error reading response", e) + } + } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/StringHandler.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/StringHandler.kt new file mode 100644 index 00000000..fb961c6b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/StringHandler.kt @@ -0,0 +1,13 @@ +@file:JvmName("StringHandler") + +package com.courier.api.core.handlers + +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler + +@JvmSynthetic internal fun stringHandler(): Handler = StringHandlerInternal + +private object StringHandlerInternal : Handler { + override fun handle(response: HttpResponse): String = + response.body().readBytes().toString(Charsets.UTF_8) +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/AsyncStreamResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/AsyncStreamResponse.kt new file mode 100644 index 00000000..8776a843 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/AsyncStreamResponse.kt @@ -0,0 +1,157 @@ +package com.courier.api.core.http + +import com.courier.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.concurrent.atomic.AtomicReference + +/** + * A class providing access to an API response as an asynchronous stream of chunks of type [T], + * where each chunk can be individually processed as soon as it arrives instead of waiting on the + * full response. + */ +interface AsyncStreamResponse { + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the client's configured or default thread pool. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler): AsyncStreamResponse + + /** + * Registers [handler] to be called for events of this stream. + * + * [handler]'s methods will be called in the given [executor]. + * + * @throws IllegalStateException if [subscribe] has already been called. + */ + fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse + + /** + * Returns a future that completes when a stream is fully consumed, errors, or gets closed + * early. + */ + fun onCompleteFuture(): CompletableFuture + + /** + * Closes this resource, relinquishing any underlying resources. + * + * This is purposefully not inherited from [AutoCloseable] because this response should not be + * synchronously closed via try-with-resources. + */ + fun close() + + /** A class for handling streaming events. */ + fun interface Handler { + + /** Called whenever a chunk is received. */ + fun onNext(value: T) + + /** + * Called when a stream is fully consumed, errors, or gets closed early. + * + * [onNext] will not be called once this method is called. + * + * @param error Non-empty if the stream completed due to an error. + */ + fun onComplete(error: Optional) {} + } +} + +@JvmSynthetic +internal fun CompletableFuture>.toAsync(streamHandlerExecutor: Executor) = + PhantomReachableClosingAsyncStreamResponse( + object : AsyncStreamResponse { + + private val onCompleteFuture = CompletableFuture() + private val state = AtomicReference(State.NEW) + + init { + this@toAsync.whenComplete { _, error -> + // If an error occurs from the original future, then we should resolve the + // `onCompleteFuture` even if `subscribe` has not been called. + error?.let(onCompleteFuture::completeExceptionally) + } + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = + subscribe(handler, streamHandlerExecutor) + + override fun subscribe( + handler: Handler, + executor: Executor, + ): AsyncStreamResponse = apply { + // TODO(JDK): Use `compareAndExchange` once targeting JDK 9. + check(state.compareAndSet(State.NEW, State.SUBSCRIBED)) { + if (state.get() == State.SUBSCRIBED) "Cannot subscribe more than once" + else "Cannot subscribe after the response is closed" + } + + this@toAsync.whenCompleteAsync( + { streamResponse, futureError -> + if (state.get() == State.CLOSED) { + // Avoid doing any work if `close` was called before the future + // completed. + return@whenCompleteAsync + } + + if (futureError != null) { + // An error occurred before we started passing chunks to the handler. + handler.onComplete(Optional.of(futureError)) + return@whenCompleteAsync + } + + var streamError: Throwable? = null + try { + streamResponse.stream().forEach(handler::onNext) + } catch (e: Throwable) { + streamError = e + } + + try { + handler.onComplete(Optional.ofNullable(streamError)) + } finally { + try { + // Notify completion via the `onCompleteFuture` as well. This is in + // a separate `try-finally` block so that we still complete the + // future if `handler.onComplete` throws. + if (streamError == null) { + onCompleteFuture.complete(null) + } else { + onCompleteFuture.completeExceptionally(streamError) + } + } finally { + close() + } + } + }, + executor, + ) + } + + override fun onCompleteFuture(): CompletableFuture = onCompleteFuture + + override fun close() { + val previousState = state.getAndSet(State.CLOSED) + if (previousState == State.CLOSED) { + return + } + + this@toAsync.whenComplete { streamResponse, error -> streamResponse?.close() } + // When the stream is closed, we should always consider it closed. If it closed due + // to an error, then we will have already completed the future earlier, and this + // will be a no-op. + onCompleteFuture.complete(null) + } + } + ) + +private enum class State { + NEW, + SUBSCRIBED, + CLOSED, +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/Headers.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/Headers.kt new file mode 100644 index 00000000..38cb1932 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/Headers.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.core.http + +import com.courier.api.core.JsonArray +import com.courier.api.core.JsonBoolean +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonNull +import com.courier.api.core.JsonNumber +import com.courier.api.core.JsonObject +import com.courier.api.core.JsonString +import com.courier.api.core.JsonValue +import com.courier.api.core.toImmutable +import java.util.TreeMap + +class Headers +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun names(): Set = map.keys + + fun values(name: String): List = map[name].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = + TreeMap(String.CASE_INSENSITIVE_ORDER) + private var size: Int = 0 + + fun put(name: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(name, value.value.toString()) + is JsonNumber -> put(name, value.value.toString()) + is JsonString -> put(name, value.value) + is JsonArray -> value.values.forEach { put(name, it) } + is JsonObject -> + value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } + } + } + + fun put(name: String, value: String) = apply { + map.getOrPut(name) { mutableListOf() }.add(value) + size++ + } + + fun put(name: String, values: Iterable) = apply { values.forEach { put(name, it) } } + + fun putAll(headers: Map>) = apply { headers.forEach(::put) } + + fun putAll(headers: Headers) = apply { + headers.names().forEach { put(it, headers.values(it)) } + } + + fun replace(name: String, value: String) = apply { + remove(name) + put(name, value) + } + + fun replace(name: String, values: Iterable) = apply { + remove(name) + put(name, values) + } + + fun replaceAll(headers: Map>) = apply { + headers.forEach(::replace) + } + + fun replaceAll(headers: Headers) = apply { + headers.names().forEach { replace(it, headers.values(it)) } + } + + fun remove(name: String) = apply { size -= map.remove(name).orEmpty().size } + + fun removeAll(names: Set) = apply { names.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + Headers( + map.mapValuesTo(TreeMap(String.CASE_INSENSITIVE_ORDER)) { (_, values) -> + values.toImmutable() + } + .toImmutable(), + size, + ) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && map == other.map + } + + override fun toString(): String = "Headers{map=$map}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpClient.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpClient.kt new file mode 100644 index 00000000..edf43271 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpClient.kt @@ -0,0 +1,26 @@ +package com.courier.api.core.http + +import com.courier.api.core.RequestOptions +import java.lang.AutoCloseable +import java.util.concurrent.CompletableFuture + +interface HttpClient : AutoCloseable { + + fun execute( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + fun execute(request: HttpRequest): HttpResponse = execute(request, RequestOptions.none()) + + fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + fun executeAsync(request: HttpRequest): CompletableFuture = + executeAsync(request, RequestOptions.none()) + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpMethod.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpMethod.kt new file mode 100644 index 00000000..bee49976 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpMethod.kt @@ -0,0 +1,13 @@ +package com.courier.api.core.http + +enum class HttpMethod { + GET, + HEAD, + POST, + PUT, + DELETE, + CONNECT, + OPTIONS, + TRACE, + PATCH, +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequest.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequest.kt new file mode 100644 index 00000000..f9459ab0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequest.kt @@ -0,0 +1,146 @@ +package com.courier.api.core.http + +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable + +class HttpRequest +private constructor( + @get:JvmName("method") val method: HttpMethod, + @get:JvmName("baseUrl") val baseUrl: String, + @get:JvmName("pathSegments") val pathSegments: List, + @get:JvmName("headers") val headers: Headers, + @get:JvmName("queryParams") val queryParams: QueryParams, + @get:JvmName("body") val body: HttpRequestBody?, +) { + + fun toBuilder(): Builder = Builder().from(this) + + override fun toString(): String = + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + + companion object { + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var method: HttpMethod? = null + private var baseUrl: String? = null + private var pathSegments: MutableList = mutableListOf() + private var headers: Headers.Builder = Headers.builder() + private var queryParams: QueryParams.Builder = QueryParams.builder() + private var body: HttpRequestBody? = null + + @JvmSynthetic + internal fun from(request: HttpRequest) = apply { + method = request.method + baseUrl = request.baseUrl + pathSegments = request.pathSegments.toMutableList() + headers = request.headers.toBuilder() + queryParams = request.queryParams.toBuilder() + body = request.body + } + + fun method(method: HttpMethod) = apply { this.method = method } + + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + + fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } + + fun addPathSegments(vararg pathSegments: String) = apply { + this.pathSegments.addAll(pathSegments) + } + + fun headers(headers: Headers) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun headers(headers: Map>) = apply { + this.headers.clear() + putAllHeaders(headers) + } + + fun putHeader(name: String, value: String) = apply { headers.put(name, value) } + + fun putHeaders(name: String, values: Iterable) = apply { headers.put(name, values) } + + fun putAllHeaders(headers: Headers) = apply { this.headers.putAll(headers) } + + fun putAllHeaders(headers: Map>) = apply { + this.headers.putAll(headers) + } + + fun replaceHeaders(name: String, value: String) = apply { headers.replace(name, value) } + + fun replaceHeaders(name: String, values: Iterable) = apply { + headers.replace(name, values) + } + + fun replaceAllHeaders(headers: Headers) = apply { this.headers.replaceAll(headers) } + + fun replaceAllHeaders(headers: Map>) = apply { + this.headers.replaceAll(headers) + } + + fun removeHeaders(name: String) = apply { headers.remove(name) } + + fun removeAllHeaders(names: Set) = apply { headers.removeAll(names) } + + fun queryParams(queryParams: QueryParams) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun queryParams(queryParams: Map>) = apply { + this.queryParams.clear() + putAllQueryParams(queryParams) + } + + fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) } + + fun putQueryParams(key: String, values: Iterable) = apply { + queryParams.put(key, values) + } + + fun putAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.putAll(queryParams) + } + + fun putAllQueryParams(queryParams: Map>) = apply { + this.queryParams.putAll(queryParams) + } + + fun replaceQueryParams(key: String, value: String) = apply { + queryParams.replace(key, value) + } + + fun replaceQueryParams(key: String, values: Iterable) = apply { + queryParams.replace(key, values) + } + + fun replaceAllQueryParams(queryParams: QueryParams) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun replaceAllQueryParams(queryParams: Map>) = apply { + this.queryParams.replaceAll(queryParams) + } + + fun removeQueryParams(key: String) = apply { queryParams.remove(key) } + + fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } + + fun body(body: HttpRequestBody) = apply { this.body = body } + + fun build(): HttpRequest = + HttpRequest( + checkRequired("method", method), + checkRequired("baseUrl", baseUrl), + pathSegments.toImmutable(), + headers.build(), + queryParams.build(), + body, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBodies.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBodies.kt new file mode 100644 index 00000000..88592711 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBodies.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:JvmName("HttpRequestBodies") + +package com.courier.api.core.http + +import com.courier.api.core.MultipartField +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.json.JsonMapper +import com.fasterxml.jackson.databind.node.JsonNodeType +import java.io.InputStream +import java.io.OutputStream +import kotlin.jvm.optionals.getOrNull +import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType +import org.apache.hc.core5.http.HttpEntity + +@JvmSynthetic +internal inline fun json(jsonMapper: JsonMapper, value: T): HttpRequestBody = + object : HttpRequestBody { + private val bytes: ByteArray by lazy { jsonMapper.writeValueAsBytes(value) } + + override fun writeTo(outputStream: OutputStream) = outputStream.write(bytes) + + override fun contentType(): String = "application/json" + + override fun contentLength(): Long = bytes.size.toLong() + + override fun repeatable(): Boolean = true + + override fun close() {} + } + +@JvmSynthetic +internal fun multipartFormData( + jsonMapper: JsonMapper, + fields: Map>, +): HttpRequestBody = + object : HttpRequestBody { + private val entity: HttpEntity by lazy { + MultipartEntityBuilder.create() + .apply { + fields.forEach { (name, field) -> + val knownValue = field.value.asKnown().getOrNull() + val parts = + if (knownValue is InputStream) { + // Read directly from the `InputStream` instead of reading it all + // into memory due to the `jsonMapper` serialization below. + sequenceOf(name to knownValue) + } else { + val node = jsonMapper.valueToTree(field.value) + serializePart(name, node) + } + + parts.forEach { (name, bytes) -> + addBinaryBody( + name, + bytes, + ContentType.parseLenient(field.contentType), + field.filename().getOrNull(), + ) + } + } + } + .build() + } + + private fun serializePart( + name: String, + node: JsonNode, + ): Sequence> = + when (node.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> emptySequence() + JsonNodeType.BINARY -> sequenceOf(name to node.binaryValue().inputStream()) + JsonNodeType.STRING -> sequenceOf(name to node.textValue().inputStream()) + JsonNodeType.BOOLEAN -> + sequenceOf(name to node.booleanValue().toString().inputStream()) + JsonNodeType.NUMBER -> + sequenceOf(name to node.numberValue().toString().inputStream()) + JsonNodeType.ARRAY -> + sequenceOf( + name to + node + .elements() + .asSequence() + .mapNotNull { element -> + when (element.nodeType) { + JsonNodeType.MISSING, + JsonNodeType.NULL -> null + JsonNodeType.STRING -> node.textValue() + JsonNodeType.BOOLEAN -> node.booleanValue().toString() + JsonNodeType.NUMBER -> node.numberValue().toString() + null, + JsonNodeType.BINARY, + JsonNodeType.ARRAY, + JsonNodeType.OBJECT, + JsonNodeType.POJO -> + throw CourierInvalidDataException( + "Unexpected JsonNode type in array: ${node.nodeType}" + ) + } + } + .joinToString(",") + .inputStream() + ) + JsonNodeType.OBJECT -> + node.fields().asSequence().flatMap { (key, value) -> + serializePart("$name[$key]", value) + } + JsonNodeType.POJO, + null -> + throw CourierInvalidDataException("Unexpected JsonNode type: ${node.nodeType}") + } + + private fun String.inputStream(): InputStream = toByteArray().inputStream() + + override fun writeTo(outputStream: OutputStream) = entity.writeTo(outputStream) + + override fun contentType(): String = entity.contentType + + override fun contentLength(): Long = entity.contentLength + + override fun repeatable(): Boolean = entity.isRepeatable + + override fun close() = entity.close() + } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBody.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBody.kt new file mode 100644 index 00000000..941c489c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpRequestBody.kt @@ -0,0 +1,25 @@ +package com.courier.api.core.http + +import java.io.OutputStream +import java.lang.AutoCloseable + +interface HttpRequestBody : AutoCloseable { + + fun writeTo(outputStream: OutputStream) + + fun contentType(): String? + + fun contentLength(): Long + + /** + * Determines if a request can be repeated in a meaningful way, for example before doing a + * retry. + * + * The most typical case when a request can't be retried is if the request body is being + * streamed. In this case the body data isn't available on subsequent attempts. + */ + fun repeatable(): Boolean + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponse.kt new file mode 100644 index 00000000..549fb372 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponse.kt @@ -0,0 +1,22 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.core.http + +import java.io.InputStream + +interface HttpResponse : AutoCloseable { + + fun statusCode(): Int + + fun headers(): Headers + + fun body(): InputStream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() + + interface Handler { + + fun handle(response: HttpResponse): T + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponseFor.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponseFor.kt new file mode 100644 index 00000000..a3a4eabe --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/HttpResponseFor.kt @@ -0,0 +1,25 @@ +package com.courier.api.core.http + +import java.io.InputStream + +interface HttpResponseFor : HttpResponse { + + fun parse(): T +} + +@JvmSynthetic +internal fun HttpResponse.parseable(parse: () -> T): HttpResponseFor = + object : HttpResponseFor { + + private val parsed: T by lazy { parse() } + + override fun parse(): T = parsed + + override fun statusCode(): Int = this@parseable.statusCode() + + override fun headers(): Headers = this@parseable.headers() + + override fun body(): InputStream = this@parseable.body() + + override fun close() = this@parseable.close() + } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt new file mode 100644 index 00000000..9b145b29 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingAsyncStreamResponse.kt @@ -0,0 +1,56 @@ +package com.courier.api.core.http + +import com.courier.api.core.closeWhenPhantomReachable +import com.courier.api.core.http.AsyncStreamResponse.Handler +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor + +/** + * A delegating wrapper around an `AsyncStreamResponse` that closes it once it's only phantom + * reachable. + * + * This class ensures the `AsyncStreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingAsyncStreamResponse( + private val asyncStreamResponse: AsyncStreamResponse +) : AsyncStreamResponse { + + /** + * An object used for keeping `asyncStreamResponse` open while the object is still reachable. + */ + private val reachabilityTracker = Object() + + init { + closeWhenPhantomReachable(reachabilityTracker, asyncStreamResponse::close) + } + + override fun subscribe(handler: Handler): AsyncStreamResponse = apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker)) + } + + override fun subscribe(handler: Handler, executor: Executor): AsyncStreamResponse = + apply { + asyncStreamResponse.subscribe(TrackedHandler(handler, reachabilityTracker), executor) + } + + override fun onCompleteFuture(): CompletableFuture = + asyncStreamResponse.onCompleteFuture() + + override fun close() = asyncStreamResponse.close() +} + +/** + * A wrapper around a `Handler` that also references a `reachabilityTracker` object. + * + * Referencing the `reachabilityTracker` object prevents it from getting reclaimed while the handler + * is still reachable. + */ +private class TrackedHandler( + private val handler: Handler, + private val reachabilityTracker: Any, +) : Handler { + override fun onNext(value: T) = handler.onNext(value) + + override fun onComplete(error: Optional) = handler.onComplete(error) +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingHttpClient.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingHttpClient.kt new file mode 100644 index 00000000..d94ef4df --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingHttpClient.kt @@ -0,0 +1,26 @@ +package com.courier.api.core.http + +import com.courier.api.core.RequestOptions +import com.courier.api.core.closeWhenPhantomReachable +import java.util.concurrent.CompletableFuture + +/** + * A delegating wrapper around an `HttpClient` that closes it once it's only phantom reachable. + * + * This class ensures the `HttpClient` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingHttpClient(private val httpClient: HttpClient) : HttpClient { + init { + closeWhenPhantomReachable(this, httpClient) + } + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse = + httpClient.execute(request, requestOptions) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = httpClient.executeAsync(request, requestOptions) + + override fun close() = httpClient.close() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingStreamResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingStreamResponse.kt new file mode 100644 index 00000000..fb270e74 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/PhantomReachableClosingStreamResponse.kt @@ -0,0 +1,21 @@ +package com.courier.api.core.http + +import com.courier.api.core.closeWhenPhantomReachable +import java.util.stream.Stream + +/** + * A delegating wrapper around a `StreamResponse` that closes it once it's only phantom reachable. + * + * This class ensures the `StreamResponse` is closed even if the user forgets to close it. + */ +internal class PhantomReachableClosingStreamResponse( + private val streamResponse: StreamResponse +) : StreamResponse { + init { + closeWhenPhantomReachable(this, streamResponse) + } + + override fun stream(): Stream = streamResponse.stream() + + override fun close() = streamResponse.close() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/QueryParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/QueryParams.kt new file mode 100644 index 00000000..c898967c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/QueryParams.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.core.http + +import com.courier.api.core.JsonArray +import com.courier.api.core.JsonBoolean +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonNull +import com.courier.api.core.JsonNumber +import com.courier.api.core.JsonObject +import com.courier.api.core.JsonString +import com.courier.api.core.JsonValue +import com.courier.api.core.toImmutable + +class QueryParams +private constructor( + private val map: Map>, + @get:JvmName("size") val size: Int, +) { + + fun isEmpty(): Boolean = map.isEmpty() + + fun keys(): Set = map.keys + + fun values(key: String): List = map[key].orEmpty() + + fun toBuilder(): Builder = Builder().putAll(map) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private val map: MutableMap> = mutableMapOf() + private var size: Int = 0 + + fun put(key: String, value: JsonValue): Builder = apply { + when (value) { + is JsonMissing, + is JsonNull -> {} + is JsonBoolean -> put(key, value.value.toString()) + is JsonNumber -> put(key, value.value.toString()) + is JsonString -> put(key, value.value) + is JsonArray -> + put( + key, + value.values + .asSequence() + .mapNotNull { + when (it) { + is JsonMissing, + is JsonNull -> null + is JsonBoolean -> it.value.toString() + is JsonNumber -> it.value.toString() + is JsonString -> it.value + is JsonArray, + is JsonObject -> + throw IllegalArgumentException( + "Cannot comma separate non-primitives in query params" + ) + } + } + .joinToString(","), + ) + is JsonObject -> + value.values.forEach { (nestedKey, value) -> put("$key[$nestedKey]", value) } + } + } + + fun put(key: String, value: String) = apply { + map.getOrPut(key) { mutableListOf() }.add(value) + size++ + } + + fun put(key: String, values: Iterable) = apply { values.forEach { put(key, it) } } + + fun putAll(queryParams: Map>) = apply { + queryParams.forEach(::put) + } + + fun putAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { put(it, queryParams.values(it)) } + } + + fun replace(key: String, value: String) = apply { + remove(key) + put(key, value) + } + + fun replace(key: String, values: Iterable) = apply { + remove(key) + put(key, values) + } + + fun replaceAll(queryParams: Map>) = apply { + queryParams.forEach(::replace) + } + + fun replaceAll(queryParams: QueryParams) = apply { + queryParams.keys().forEach { replace(it, queryParams.values(it)) } + } + + fun remove(key: String) = apply { size -= map.remove(key).orEmpty().size } + + fun removeAll(keys: Set) = apply { keys.forEach(::remove) } + + fun clear() = apply { + map.clear() + size = 0 + } + + fun build() = + QueryParams(map.mapValues { (_, values) -> values.toImmutable() }.toImmutable(), size) + } + + override fun hashCode(): Int = map.hashCode() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is QueryParams && map == other.map + } + + override fun toString(): String = "QueryParams{map=$map}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/RetryingHttpClient.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/RetryingHttpClient.kt new file mode 100644 index 00000000..61bb8900 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/RetryingHttpClient.kt @@ -0,0 +1,265 @@ +package com.courier.api.core.http + +import com.courier.api.core.DefaultSleeper +import com.courier.api.core.RequestOptions +import com.courier.api.core.Sleeper +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierIoException +import com.courier.api.errors.CourierRetryableException +import java.io.IOException +import java.time.Clock +import java.time.Duration +import java.time.OffsetDateTime +import java.time.format.DateTimeFormatter +import java.time.format.DateTimeParseException +import java.time.temporal.ChronoUnit +import java.util.UUID +import java.util.concurrent.CompletableFuture +import java.util.concurrent.ThreadLocalRandom +import java.util.concurrent.TimeUnit +import java.util.function.Function +import kotlin.math.min +import kotlin.math.pow + +class RetryingHttpClient +private constructor( + private val httpClient: HttpClient, + private val sleeper: Sleeper, + private val clock: Clock, + private val maxRetries: Int, + private val idempotencyHeader: String?, +) : HttpClient { + + override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.execute(request, requestOptions) + } + + var modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + while (true) { + if (shouldSendRetryCount) { + modifiedRequest = setRetryCountHeader(modifiedRequest, retries) + } + + val response = + try { + val response = httpClient.execute(modifiedRequest, requestOptions) + if (++retries > maxRetries || !shouldRetry(response)) { + return response + } + + response + } catch (throwable: Throwable) { + if (++retries > maxRetries || !shouldRetry(throwable)) { + throw throwable + } + + null + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + sleeper.sleep(backoffDuration) + } + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + if (!isRetryable(request) || maxRetries <= 0) { + return httpClient.executeAsync(request, requestOptions) + } + + val modifiedRequest = maybeAddIdempotencyHeader(request) + + // Don't send the current retry count in the headers if the caller set their own value. + val shouldSendRetryCount = + !modifiedRequest.headers.names().contains("X-Stainless-Retry-Count") + + var retries = 0 + + fun executeWithRetries( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + val requestWithRetryCount = + if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request + + return httpClient + .executeAsync(requestWithRetryCount, requestOptions) + .handleAsync( + fun( + response: HttpResponse?, + throwable: Throwable?, + ): CompletableFuture { + if (response != null) { + if (++retries > maxRetries || !shouldRetry(response)) { + return CompletableFuture.completedFuture(response) + } + } else { + if (++retries > maxRetries || !shouldRetry(throwable!!)) { + val failedFuture = CompletableFuture() + failedFuture.completeExceptionally(throwable) + return failedFuture + } + } + + val backoffDuration = getRetryBackoffDuration(retries, response) + // All responses must be closed, so close the failed one before retrying. + response?.close() + return sleeper.sleepAsync(backoffDuration).thenCompose { + executeWithRetries(requestWithRetryCount, requestOptions) + } + } + ) { + // Run in the same thread. + it.run() + } + .thenCompose(Function.identity()) + } + + return executeWithRetries(modifiedRequest, requestOptions) + } + + override fun close() { + httpClient.close() + sleeper.close() + } + + private fun isRetryable(request: HttpRequest): Boolean = + // Some requests, such as when a request body is being streamed, cannot be retried because + // the body data aren't available on subsequent attempts. + request.body?.repeatable() ?: true + + private fun setRetryCountHeader(request: HttpRequest, retries: Int): HttpRequest = + request.toBuilder().replaceHeaders("X-Stainless-Retry-Count", retries.toString()).build() + + private fun idempotencyKey(): String = "stainless-java-retry-${UUID.randomUUID()}" + + private fun maybeAddIdempotencyHeader(request: HttpRequest): HttpRequest { + if (idempotencyHeader == null || request.headers.names().contains(idempotencyHeader)) { + return request + } + + return request + .toBuilder() + // Set a header to uniquely identify the request when retried. + .putHeader(idempotencyHeader, idempotencyKey()) + .build() + } + + private fun shouldRetry(response: HttpResponse): Boolean { + // Note: this is not a standard header + val shouldRetryHeader = response.headers().values("X-Should-Retry").getOrNull(0) + val statusCode = response.statusCode() + + return when { + // If the server explicitly says whether to retry, obey + shouldRetryHeader == "true" -> true + shouldRetryHeader == "false" -> false + + // Retry on request timeouts + statusCode == 408 -> true + // Retry on lock timeouts + statusCode == 409 -> true + // Retry on rate limits + statusCode == 429 -> true + // Retry internal errors + statusCode >= 500 -> true + else -> false + } + } + + private fun shouldRetry(throwable: Throwable): Boolean = + // Only retry known retryable exceptions, other exceptions are not intended to be retried. + throwable is IOException || + throwable is CourierIoException || + throwable is CourierRetryableException + + private fun getRetryBackoffDuration(retries: Int, response: HttpResponse?): Duration { + // About the Retry-After header: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After + response + ?.headers() + ?.let { headers -> + headers + .values("Retry-After-Ms") + .getOrNull(0) + ?.toFloatOrNull() + ?.times(TimeUnit.MILLISECONDS.toNanos(1)) + ?: headers.values("Retry-After").getOrNull(0)?.let { retryAfter -> + retryAfter.toFloatOrNull()?.times(TimeUnit.SECONDS.toNanos(1)) + ?: try { + ChronoUnit.MILLIS.between( + OffsetDateTime.now(clock), + OffsetDateTime.parse( + retryAfter, + DateTimeFormatter.RFC_1123_DATE_TIME, + ), + ) + } catch (e: DateTimeParseException) { + null + } + } + } + ?.let { retryAfterNanos -> + // If the API asks us to wait a certain amount of time (and it's a reasonable + // amount), just + // do what it says. + val retryAfter = Duration.ofNanos(retryAfterNanos.toLong()) + if (retryAfter in Duration.ofNanos(0)..Duration.ofMinutes(1)) { + return retryAfter + } + } + + // Apply exponential backoff, but not more than the max. + val backoffSeconds = min(0.5 * 2.0.pow(retries - 1), 8.0) + + // Apply some jitter + val jitter = 1.0 - 0.25 * ThreadLocalRandom.current().nextDouble() + + return Duration.ofNanos((TimeUnit.SECONDS.toNanos(1) * backoffSeconds * jitter).toLong()) + } + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder internal constructor() { + + private var httpClient: HttpClient? = null + private var sleeper: Sleeper? = null + private var clock: Clock = Clock.systemUTC() + private var maxRetries: Int = 2 + private var idempotencyHeader: String? = null + + fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + + fun sleeper(sleeper: Sleeper) = apply { this.sleeper = sleeper } + + fun clock(clock: Clock) = apply { this.clock = clock } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun idempotencyHeader(header: String) = apply { this.idempotencyHeader = header } + + fun build(): HttpClient = + RetryingHttpClient( + checkRequired("httpClient", httpClient), + sleeper ?: DefaultSleeper(), + clock, + maxRetries, + idempotencyHeader, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/http/StreamResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/http/StreamResponse.kt new file mode 100644 index 00000000..244d3313 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/http/StreamResponse.kt @@ -0,0 +1,19 @@ +package com.courier.api.core.http + +import java.util.stream.Stream + +interface StreamResponse : AutoCloseable { + + fun stream(): Stream + + /** Overridden from [AutoCloseable] to not have a checked exception in its signature. */ + override fun close() +} + +@JvmSynthetic +internal fun StreamResponse.map(transform: (T) -> R): StreamResponse = + object : StreamResponse { + override fun stream(): Stream = this@map.stream().map(transform) + + override fun close() = this@map.close() + } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/BadRequestException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/BadRequestException.kt new file mode 100644 index 00000000..0c7b3f67 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/BadRequestException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BadRequestException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + CourierServiceException("400: $body", cause) { + + override fun statusCode(): Int = 400 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BadRequestException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BadRequestException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(badRequestException: BadRequestException) = apply { + headers = badRequestException.headers + body = badRequestException.body + cause = badRequestException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [BadRequestException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BadRequestException = + BadRequestException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierException.kt new file mode 100644 index 00000000..9dca641e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierException.kt @@ -0,0 +1,5 @@ +package com.courier.api.errors + +open class CourierException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : RuntimeException(message, cause) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierInvalidDataException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierInvalidDataException.kt new file mode 100644 index 00000000..31f21175 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierInvalidDataException.kt @@ -0,0 +1,5 @@ +package com.courier.api.errors + +class CourierInvalidDataException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : CourierException(message, cause) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierIoException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierIoException.kt new file mode 100644 index 00000000..dab8bcbd --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierIoException.kt @@ -0,0 +1,5 @@ +package com.courier.api.errors + +class CourierIoException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : CourierException(message, cause) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierRetryableException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierRetryableException.kt new file mode 100644 index 00000000..cb6e816a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierRetryableException.kt @@ -0,0 +1,14 @@ +package com.courier.api.errors + +/** + * Exception that indicates a transient error that can be retried. + * + * When this exception is thrown during an HTTP request, the SDK will automatically retry the + * request up to the maximum number of retries. + * + * @param message A descriptive error message + * @param cause The underlying cause of this exception, if any + */ +class CourierRetryableException +@JvmOverloads +constructor(message: String? = null, cause: Throwable? = null) : CourierException(message, cause) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierServiceException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierServiceException.kt new file mode 100644 index 00000000..0455ff6a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/CourierServiceException.kt @@ -0,0 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.http.Headers + +abstract class CourierServiceException +protected constructor(message: String, cause: Throwable? = null) : + CourierException(message, cause) { + + abstract fun statusCode(): Int + + abstract fun headers(): Headers + + abstract fun body(): JsonValue +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/InternalServerException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/InternalServerException.kt new file mode 100644 index 00000000..70575e38 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/InternalServerException.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InternalServerException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : CourierServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalServerException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalServerException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(internalServerException: InternalServerException) = apply { + statusCode = internalServerException.statusCode + headers = internalServerException.headers + body = internalServerException.body + cause = internalServerException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/NotFoundException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/NotFoundException.kt new file mode 100644 index 00000000..b575d286 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/NotFoundException.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotFoundException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + CourierServiceException("404: $body", cause) { + + override fun statusCode(): Int = 404 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotFoundException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotFoundException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(notFoundException: NotFoundException) = apply { + headers = notFoundException.headers + body = notFoundException.body + cause = notFoundException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [NotFoundException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/PermissionDeniedException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/PermissionDeniedException.kt new file mode 100644 index 00000000..59bed2ff --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/PermissionDeniedException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PermissionDeniedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + CourierServiceException("403: $body", cause) { + + override fun statusCode(): Int = 403 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PermissionDeniedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PermissionDeniedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(permissionDeniedException: PermissionDeniedException) = apply { + headers = permissionDeniedException.headers + body = permissionDeniedException.body + cause = permissionDeniedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/RateLimitException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/RateLimitException.kt new file mode 100644 index 00000000..d302deaa --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/RateLimitException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RateLimitException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + CourierServiceException("429: $body", cause) { + + override fun statusCode(): Int = 429 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RateLimitException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RateLimitException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(rateLimitException: RateLimitException) = apply { + headers = rateLimitException.headers + body = rateLimitException.body + cause = rateLimitException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [RateLimitException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/UnauthorizedException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/UnauthorizedException.kt new file mode 100644 index 00000000..02ada94b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/UnauthorizedException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnauthorizedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + CourierServiceException("401: $body", cause) { + + override fun statusCode(): Int = 401 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnauthorizedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnauthorizedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unauthorizedException: UnauthorizedException) = apply { + headers = unauthorizedException.headers + body = unauthorizedException.body + cause = unauthorizedException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/UnexpectedStatusCodeException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/UnexpectedStatusCodeException.kt new file mode 100644 index 00000000..2dbe1a0d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/UnexpectedStatusCodeException.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnexpectedStatusCodeException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : CourierServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnexpectedStatusCodeException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnexpectedStatusCodeException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unexpectedStatusCodeException: UnexpectedStatusCodeException) = apply { + statusCode = unexpectedStatusCodeException.statusCode + headers = unexpectedStatusCodeException.headers + body = unexpectedStatusCodeException.body + cause = unexpectedStatusCodeException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/errors/UnprocessableEntityException.kt b/courier-java-core/src/main/kotlin/com/courier/api/errors/UnprocessableEntityException.kt new file mode 100644 index 00000000..ea689066 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/errors/UnprocessableEntityException.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.errors + +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnprocessableEntityException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + CourierServiceException("422: $body", cause) { + + override fun statusCode(): Int = 422 + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnprocessableEntityException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnprocessableEntityException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unprocessableEntityException: UnprocessableEntityException) = apply { + headers = unprocessableEntityException.headers + body = unprocessableEntityException.body + cause = unprocessableEntityException.cause + } + + fun headers(headers: Headers) = apply { this.headers = headers } + + fun body(body: JsonValue) = apply { this.body = body } + + fun cause(cause: Throwable?) = apply { this.cause = cause } + + /** Alias for calling [Builder.cause] with `cause.orElse(null)`. */ + fun cause(cause: Optional) = cause(cause.getOrNull()) + + /** + * Returns an immutable instance of [UnprocessableEntityException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnprocessableEntityException = + UnprocessableEntityException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt new file mode 100644 index 00000000..265d41e2 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt @@ -0,0 +1,364 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class Audience +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val description: JsonField, + private val filter: JsonField, + private val name: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + ) : this(id, createdAt, description, filter, name, updatedAt, mutableMapOf()) + + /** + * A unique identifier representing the audience_id + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): String = createdAt.getRequired("created_at") + + /** + * A description of the audience + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun description(): String = description.getRequired("description") + + /** + * The operator to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun filter(): Filter = filter.getRequired("filter") + + /** + * The name of the audience + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): String = updatedAt.getRequired("updated_at") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Audience]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .description() + * .filter() + * .name() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Audience]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var description: JsonField? = null + private var filter: JsonField? = null + private var name: JsonField? = null + private var updatedAt: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audience: Audience) = apply { + id = audience.id + createdAt = audience.createdAt + description = audience.description + filter = audience.filter + name = audience.name + updatedAt = audience.updatedAt + additionalProperties = audience.additionalProperties.toMutableMap() + } + + /** A unique identifier representing the audience_id */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** A description of the audience */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** The operator to use for filtering */ + fun filter(filter: Filter) = filter(JsonField.of(filter)) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [Filter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** Alias for calling [filter] with `Filter.ofUnionMember0(unionMember0)`. */ + fun filter(unionMember0: Filter.UnionMember0) = filter(Filter.ofUnionMember0(unionMember0)) + + /** Alias for calling [filter] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. */ + fun filter(nestedFilterConfig: NestedFilterConfig) = + filter(Filter.ofNestedFilterConfig(nestedFilterConfig)) + + /** The name of the audience */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Audience]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .description() + * .filter() + * .name() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Audience = + Audience( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("description", description), + checkRequired("filter", filter), + checkRequired("name", name), + checkRequired("updatedAt", updatedAt), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Audience = apply { + if (validated) { + return@apply + } + + id() + createdAt() + description() + filter().validate() + name() + updatedAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (filter.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Audience && + id == other.id && + createdAt == other.createdAt && + description == other.description && + filter == other.filter && + name == other.name && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, description, filter, name, updatedAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Audience{id=$id, createdAt=$createdAt, description=$description, filter=$filter, name=$name, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt new file mode 100644 index 00000000..913ee5cb --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Deletes the specified audience. */ +class AudienceDeleteParams +private constructor( + private val audienceId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun audienceId(): Optional = Optional.ofNullable(audienceId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AudienceDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AudienceDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceDeleteParams]. */ + class Builder internal constructor() { + + private var audienceId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audienceDeleteParams: AudienceDeleteParams) = apply { + audienceId = audienceDeleteParams.audienceId + additionalHeaders = audienceDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = audienceDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = audienceDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } + + /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ + fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [AudienceDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AudienceDeleteParams = + AudienceDeleteParams( + audienceId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> audienceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceDeleteParams && + audienceId == other.audienceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(audienceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "AudienceDeleteParams{audienceId=$audienceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt new file mode 100644 index 00000000..828b67d6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get list of members of an audience. */ +class AudienceListMembersParams +private constructor( + private val audienceId: String?, + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun audienceId(): Optional = Optional.ofNullable(audienceId) + + /** A unique identifier that allows for fetching the next set of members */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AudienceListMembersParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [AudienceListMembersParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceListMembersParams]. */ + class Builder internal constructor() { + + private var audienceId: String? = null + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(audienceListMembersParams: AudienceListMembersParams) = apply { + audienceId = audienceListMembersParams.audienceId + cursor = audienceListMembersParams.cursor + additionalHeaders = audienceListMembersParams.additionalHeaders.toBuilder() + additionalQueryParams = audienceListMembersParams.additionalQueryParams.toBuilder() + } + + fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } + + /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ + fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) + + /** A unique identifier that allows for fetching the next set of members */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AudienceListMembersParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AudienceListMembersParams = + AudienceListMembersParams( + audienceId, + cursor, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> audienceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceListMembersParams && + audienceId == other.audienceId && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(audienceId, cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AudienceListMembersParams{audienceId=$audienceId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt new file mode 100644 index 00000000..3f048565 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt @@ -0,0 +1,538 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AudienceListMembersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AudienceListMembersResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceListMembersResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audienceListMembersResponse: AudienceListMembersResponse) = apply { + items = audienceListMembersResponse.items.map { it.toMutableList() } + paging = audienceListMembersResponse.paging + additionalProperties = audienceListMembersResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AudienceListMembersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AudienceListMembersResponse = + AudienceListMembersResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AudienceListMembersResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val addedAt: JsonField, + private val audienceId: JsonField, + private val audienceVersion: JsonField, + private val memberId: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("added_at") @ExcludeMissing addedAt: JsonField = JsonMissing.of(), + @JsonProperty("audience_id") + @ExcludeMissing + audienceId: JsonField = JsonMissing.of(), + @JsonProperty("audience_version") + @ExcludeMissing + audienceVersion: JsonField = JsonMissing.of(), + @JsonProperty("member_id") + @ExcludeMissing + memberId: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + ) : this(addedAt, audienceId, audienceVersion, memberId, reason, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun addedAt(): String = addedAt.getRequired("added_at") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun audienceId(): String = audienceId.getRequired("audience_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun audienceVersion(): Long = audienceVersion.getRequired("audience_version") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun memberId(): String = memberId.getRequired("member_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun reason(): String = reason.getRequired("reason") + + /** + * Returns the raw JSON value of [addedAt]. + * + * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt + + /** + * Returns the raw JSON value of [audienceId]. + * + * Unlike [audienceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audience_id") + @ExcludeMissing + fun _audienceId(): JsonField = audienceId + + /** + * Returns the raw JSON value of [audienceVersion]. + * + * Unlike [audienceVersion], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("audience_version") + @ExcludeMissing + fun _audienceVersion(): JsonField = audienceVersion + + /** + * Returns the raw JSON value of [memberId]. + * + * Unlike [memberId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("member_id") @ExcludeMissing fun _memberId(): JsonField = memberId + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .addedAt() + * .audienceId() + * .audienceVersion() + * .memberId() + * .reason() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var addedAt: JsonField? = null + private var audienceId: JsonField? = null + private var audienceVersion: JsonField? = null + private var memberId: JsonField? = null + private var reason: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + addedAt = item.addedAt + audienceId = item.audienceId + audienceVersion = item.audienceVersion + memberId = item.memberId + reason = item.reason + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun addedAt(addedAt: String) = addedAt(JsonField.of(addedAt)) + + /** + * Sets [Builder.addedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.addedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } + + fun audienceId(audienceId: String) = audienceId(JsonField.of(audienceId)) + + /** + * Sets [Builder.audienceId] to an arbitrary JSON value. + * + * You should usually call [Builder.audienceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audienceId(audienceId: JsonField) = apply { this.audienceId = audienceId } + + fun audienceVersion(audienceVersion: Long) = + audienceVersion(JsonField.of(audienceVersion)) + + /** + * Sets [Builder.audienceVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.audienceVersion] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audienceVersion(audienceVersion: JsonField) = apply { + this.audienceVersion = audienceVersion + } + + fun memberId(memberId: String) = memberId(JsonField.of(memberId)) + + /** + * Sets [Builder.memberId] to an arbitrary JSON value. + * + * You should usually call [Builder.memberId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun memberId(memberId: JsonField) = apply { this.memberId = memberId } + + fun reason(reason: String) = reason(JsonField.of(reason)) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .addedAt() + * .audienceId() + * .audienceVersion() + * .memberId() + * .reason() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("addedAt", addedAt), + checkRequired("audienceId", audienceId), + checkRequired("audienceVersion", audienceVersion), + checkRequired("memberId", memberId), + checkRequired("reason", reason), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + addedAt() + audienceId() + audienceVersion() + memberId() + reason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (addedAt.asKnown().isPresent) 1 else 0) + + (if (audienceId.asKnown().isPresent) 1 else 0) + + (if (audienceVersion.asKnown().isPresent) 1 else 0) + + (if (memberId.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + addedAt == other.addedAt && + audienceId == other.audienceId && + audienceVersion == other.audienceVersion && + memberId == other.memberId && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + addedAt, + audienceId, + audienceVersion, + memberId, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{addedAt=$addedAt, audienceId=$audienceId, audienceVersion=$audienceVersion, memberId=$memberId, reason=$reason, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceListMembersResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AudienceListMembersResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt new file mode 100644 index 00000000..da6a10dc --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the audiences associated with the authorization token. */ +class AudienceListParams +private constructor( + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** A unique identifier that allows for fetching the next set of audiences */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AudienceListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AudienceListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(audienceListParams: AudienceListParams) = apply { + cursor = audienceListParams.cursor + additionalHeaders = audienceListParams.additionalHeaders.toBuilder() + additionalQueryParams = audienceListParams.additionalQueryParams.toBuilder() + } + + /** A unique identifier that allows for fetching the next set of audiences */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AudienceListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AudienceListParams = + AudienceListParams(cursor, additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceListParams && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AudienceListParams{cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt new file mode 100644 index 00000000..63852dcc --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AudienceListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AudienceListResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audienceListResponse: AudienceListResponse) = apply { + items = audienceListResponse.items.map { it.toMutableList() } + paging = audienceListResponse.paging + additionalProperties = audienceListResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Audience] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Audience) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AudienceListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AudienceListResponse = + AudienceListResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AudienceListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceListResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AudienceListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt new file mode 100644 index 00000000..af099647 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns the specified audience by id. */ +class AudienceRetrieveParams +private constructor( + private val audienceId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun audienceId(): Optional = Optional.ofNullable(audienceId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AudienceRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AudienceRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceRetrieveParams]. */ + class Builder internal constructor() { + + private var audienceId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(audienceRetrieveParams: AudienceRetrieveParams) = apply { + audienceId = audienceRetrieveParams.audienceId + additionalHeaders = audienceRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = audienceRetrieveParams.additionalQueryParams.toBuilder() + } + + fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } + + /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ + fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AudienceRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AudienceRetrieveParams = + AudienceRetrieveParams( + audienceId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> audienceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceRetrieveParams && + audienceId == other.audienceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(audienceId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AudienceRetrieveParams{audienceId=$audienceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt new file mode 100644 index 00000000..6aabb901 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt @@ -0,0 +1,577 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Creates or updates audience. */ +class AudienceUpdateParams +private constructor( + private val audienceId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun audienceId(): Optional = Optional.ofNullable(audienceId) + + /** + * A description of the audience + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = body.description() + + /** + * The operator to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = body.filter() + + /** + * The name of the audience + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = body.name() + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _description(): JsonField = body._description() + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _filter(): JsonField = body._filter() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AudienceUpdateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AudienceUpdateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceUpdateParams]. */ + class Builder internal constructor() { + + private var audienceId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(audienceUpdateParams: AudienceUpdateParams) = apply { + audienceId = audienceUpdateParams.audienceId + body = audienceUpdateParams.body.toBuilder() + additionalHeaders = audienceUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = audienceUpdateParams.additionalQueryParams.toBuilder() + } + + fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } + + /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ + fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [description] + * - [filter] + * - [name] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** A description of the audience */ + fun description(description: String?) = apply { body.description(description) } + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { body.description(description) } + + /** The operator to use for filtering */ + fun filter(filter: Filter?) = apply { body.filter(filter) } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [Filter] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun filter(filter: JsonField) = apply { body.filter(filter) } + + /** Alias for calling [filter] with `Filter.ofUnionMember0(unionMember0)`. */ + fun filter(unionMember0: Filter.UnionMember0) = apply { body.filter(unionMember0) } + + /** Alias for calling [filter] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. */ + fun filter(nestedFilterConfig: NestedFilterConfig) = apply { + body.filter(nestedFilterConfig) + } + + /** The name of the audience */ + fun name(name: String?) = apply { body.name(name) } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AudienceUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AudienceUpdateParams = + AudienceUpdateParams( + audienceId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> audienceId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val description: JsonField, + private val filter: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(description, filter, name, mutableMapOf()) + + /** + * A description of the audience + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The operator to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * The name of the audience + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var description: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + description = body.description + filter = body.filter + name = body.name + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** A description of the audience */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The operator to use for filtering */ + fun filter(filter: Filter?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [Filter] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** Alias for calling [filter] with `Filter.ofUnionMember0(unionMember0)`. */ + fun filter(unionMember0: Filter.UnionMember0) = + filter(Filter.ofUnionMember0(unionMember0)) + + /** + * Alias for calling [filter] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. + */ + fun filter(nestedFilterConfig: NestedFilterConfig) = + filter(Filter.ofNestedFilterConfig(nestedFilterConfig)) + + /** The name of the audience */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(description, filter, name, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + description() + filter().ifPresent { it.validate() } + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (description.asKnown().isPresent) 1 else 0) + + (filter.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + description == other.description && + filter == other.filter && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(description, filter, name, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{description=$description, filter=$filter, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceUpdateParams && + audienceId == other.audienceId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(audienceId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AudienceUpdateParams{audienceId=$audienceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt new file mode 100644 index 00000000..103d0ec4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AudienceUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val audience: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("audience") @ExcludeMissing audience: JsonField = JsonMissing.of() + ) : this(audience, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun audience(): Audience = audience.getRequired("audience") + + /** + * Returns the raw JSON value of [audience]. + * + * Unlike [audience], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audience") @ExcludeMissing fun _audience(): JsonField = audience + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AudienceUpdateResponse]. + * + * The following fields are required: + * ```java + * .audience() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceUpdateResponse]. */ + class Builder internal constructor() { + + private var audience: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audienceUpdateResponse: AudienceUpdateResponse) = apply { + audience = audienceUpdateResponse.audience + additionalProperties = audienceUpdateResponse.additionalProperties.toMutableMap() + } + + fun audience(audience: Audience) = audience(JsonField.of(audience)) + + /** + * Sets [Builder.audience] to an arbitrary JSON value. + * + * You should usually call [Builder.audience] with a well-typed [Audience] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun audience(audience: JsonField) = apply { this.audience = audience } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AudienceUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .audience() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AudienceUpdateResponse = + AudienceUpdateResponse( + checkRequired("audience", audience), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AudienceUpdateResponse = apply { + if (validated) { + return@apply + } + + audience().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (audience.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceUpdateResponse && + audience == other.audience && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(audience, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AudienceUpdateResponse{audience=$audience, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt new file mode 100644 index 00000000..80e05a56 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt @@ -0,0 +1,660 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** The operator to use for filtering */ +@JsonDeserialize(using = Filter.Deserializer::class) +@JsonSerialize(using = Filter.Serializer::class) +class Filter +private constructor( + private val unionMember0: UnionMember0? = null, + private val nestedFilterConfig: NestedFilterConfig? = null, + private val _json: JsonValue? = null, +) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + /** The operator to use for filtering */ + fun nestedFilterConfig(): Optional = Optional.ofNullable(nestedFilterConfig) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isNestedFilterConfig(): Boolean = nestedFilterConfig != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + /** The operator to use for filtering */ + fun asNestedFilterConfig(): NestedFilterConfig = + nestedFilterConfig.getOrThrow("nestedFilterConfig") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + nestedFilterConfig != null -> visitor.visitNestedFilterConfig(nestedFilterConfig) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitNestedFilterConfig(nestedFilterConfig: NestedFilterConfig) { + nestedFilterConfig.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitNestedFilterConfig(nestedFilterConfig: NestedFilterConfig) = + nestedFilterConfig.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + unionMember0 == other.unionMember0 && + nestedFilterConfig == other.nestedFilterConfig + } + + override fun hashCode(): Int = Objects.hash(unionMember0, nestedFilterConfig) + + override fun toString(): String = + when { + unionMember0 != null -> "Filter{unionMember0=$unionMember0}" + nestedFilterConfig != null -> "Filter{nestedFilterConfig=$nestedFilterConfig}" + _json != null -> "Filter{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Filter") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = Filter(unionMember0 = unionMember0) + + /** The operator to use for filtering */ + @JvmStatic + fun ofNestedFilterConfig(nestedFilterConfig: NestedFilterConfig) = + Filter(nestedFilterConfig = nestedFilterConfig) + } + + /** An interface that defines how to map each variant of [Filter] to a value of type [T]. */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + /** The operator to use for filtering */ + fun visitNestedFilterConfig(nestedFilterConfig: NestedFilterConfig): T + + /** + * Maps an unknown variant of [Filter] to a value of type [T]. + * + * An instance of [Filter] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Filter: $json") + } + } + + internal class Deserializer : BaseDeserializer(Filter::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Filter { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Filter(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Filter(nestedFilterConfig = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> Filter(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Filter::class) { + + override fun serialize( + value: Filter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.nestedFilterConfig != null -> generator.writeObject(value.nestedFilterConfig) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Filter") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val operator: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(operator, path, value, mutableMapOf()) + + /** + * The operator to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The attribe name from profile whose value will be operated against the filter value + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun path(): String = path.getRequired("path") + + /** + * The value to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember0]. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + operator = unionMember0.operator + path = unionMember0.path + value = unionMember0.value + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + /** The operator to use for filtering */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** + * The attribe name from profile whose value will be operated against the filter value + */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + /** The value to use for filtering */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember0 = + UnionMember0( + checkRequired("operator", operator), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + operator().validate() + path() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** The operator to use for filtering */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENDS_WITH = of("ENDS_WITH") + + @JvmField val EQ = of("EQ") + + @JvmField val EXISTS = of("EXISTS") + + @JvmField val GT = of("GT") + + @JvmField val GTE = of("GTE") + + @JvmField val INCLUDES = of("INCLUDES") + + @JvmField val IS_AFTER = of("IS_AFTER") + + @JvmField val IS_BEFORE = of("IS_BEFORE") + + @JvmField val LT = of("LT") + + @JvmField val LTE = of("LTE") + + @JvmField val NEQ = of("NEQ") + + @JvmField val OMIT = of("OMIT") + + @JvmField val STARTS_WITH = of("STARTS_WITH") + + @JvmField val AND = of("AND") + + @JvmField val OR = of("OR") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + ENDS_WITH, + EQ, + EXISTS, + GT, + GTE, + INCLUDES, + IS_AFTER, + IS_BEFORE, + LT, + LTE, + NEQ, + OMIT, + STARTS_WITH, + AND, + OR, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENDS_WITH, + EQ, + EXISTS, + GT, + GTE, + INCLUDES, + IS_AFTER, + IS_BEFORE, + LT, + LTE, + NEQ, + OMIT, + STARTS_WITH, + AND, + OR, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENDS_WITH -> Value.ENDS_WITH + EQ -> Value.EQ + EXISTS -> Value.EXISTS + GT -> Value.GT + GTE -> Value.GTE + INCLUDES -> Value.INCLUDES + IS_AFTER -> Value.IS_AFTER + IS_BEFORE -> Value.IS_BEFORE + LT -> Value.LT + LTE -> Value.LTE + NEQ -> Value.NEQ + OMIT -> Value.OMIT + STARTS_WITH -> Value.STARTS_WITH + AND -> Value.AND + OR -> Value.OR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENDS_WITH -> Known.ENDS_WITH + EQ -> Known.EQ + EXISTS -> Known.EXISTS + GT -> Known.GT + GTE -> Known.GTE + INCLUDES -> Known.INCLUDES + IS_AFTER -> Known.IS_AFTER + IS_BEFORE -> Known.IS_BEFORE + LT -> Known.LT + LTE -> Known.LTE + NEQ -> Known.NEQ + OMIT -> Known.OMIT + STARTS_WITH -> Known.STARTS_WITH + AND -> Known.AND + OR -> Known.OR + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + operator == other.operator && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(operator, path, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt new file mode 100644 index 00000000..d48f3590 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt @@ -0,0 +1,656 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** The operator to use for filtering */ +@JsonDeserialize(using = FilterConfig.Deserializer::class) +@JsonSerialize(using = FilterConfig.Serializer::class) +class FilterConfig +private constructor( + private val unionMember0: UnionMember0? = null, + private val nested: NestedFilterConfig? = null, + private val _json: JsonValue? = null, +) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + /** The operator to use for filtering */ + fun nested(): Optional = Optional.ofNullable(nested) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isNested(): Boolean = nested != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + /** The operator to use for filtering */ + fun asNested(): NestedFilterConfig = nested.getOrThrow("nested") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + nested != null -> visitor.visitNested(nested) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): FilterConfig = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitNested(nested: NestedFilterConfig) { + nested.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitNested(nested: NestedFilterConfig) = nested.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FilterConfig && unionMember0 == other.unionMember0 && nested == other.nested + } + + override fun hashCode(): Int = Objects.hash(unionMember0, nested) + + override fun toString(): String = + when { + unionMember0 != null -> "FilterConfig{unionMember0=$unionMember0}" + nested != null -> "FilterConfig{nested=$nested}" + _json != null -> "FilterConfig{_unknown=$_json}" + else -> throw IllegalStateException("Invalid FilterConfig") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = FilterConfig(unionMember0 = unionMember0) + + /** The operator to use for filtering */ + @JvmStatic fun ofNested(nested: NestedFilterConfig) = FilterConfig(nested = nested) + } + + /** + * An interface that defines how to map each variant of [FilterConfig] to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + /** The operator to use for filtering */ + fun visitNested(nested: NestedFilterConfig): T + + /** + * Maps an unknown variant of [FilterConfig] to a value of type [T]. + * + * An instance of [FilterConfig] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown FilterConfig: $json") + } + } + + internal class Deserializer : BaseDeserializer(FilterConfig::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): FilterConfig { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + FilterConfig(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + FilterConfig(nested = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> FilterConfig(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(FilterConfig::class) { + + override fun serialize( + value: FilterConfig, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.nested != null -> generator.writeObject(value.nested) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid FilterConfig") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val operator: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(operator, path, value, mutableMapOf()) + + /** + * The operator to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * The attribe name from profile whose value will be operated against the filter value + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun path(): String = path.getRequired("path") + + /** + * The value to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember0]. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + operator = unionMember0.operator + path = unionMember0.path + value = unionMember0.value + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + /** The operator to use for filtering */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + /** + * The attribe name from profile whose value will be operated against the filter value + */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + /** The value to use for filtering */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember0 = + UnionMember0( + checkRequired("operator", operator), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + operator().validate() + path() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** The operator to use for filtering */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENDS_WITH = of("ENDS_WITH") + + @JvmField val EQ = of("EQ") + + @JvmField val EXISTS = of("EXISTS") + + @JvmField val GT = of("GT") + + @JvmField val GTE = of("GTE") + + @JvmField val INCLUDES = of("INCLUDES") + + @JvmField val IS_AFTER = of("IS_AFTER") + + @JvmField val IS_BEFORE = of("IS_BEFORE") + + @JvmField val LT = of("LT") + + @JvmField val LTE = of("LTE") + + @JvmField val NEQ = of("NEQ") + + @JvmField val OMIT = of("OMIT") + + @JvmField val STARTS_WITH = of("STARTS_WITH") + + @JvmField val AND = of("AND") + + @JvmField val OR = of("OR") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + ENDS_WITH, + EQ, + EXISTS, + GT, + GTE, + INCLUDES, + IS_AFTER, + IS_BEFORE, + LT, + LTE, + NEQ, + OMIT, + STARTS_WITH, + AND, + OR, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENDS_WITH, + EQ, + EXISTS, + GT, + GTE, + INCLUDES, + IS_AFTER, + IS_BEFORE, + LT, + LTE, + NEQ, + OMIT, + STARTS_WITH, + AND, + OR, + /** + * An enum member indicating that [Operator] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENDS_WITH -> Value.ENDS_WITH + EQ -> Value.EQ + EXISTS -> Value.EXISTS + GT -> Value.GT + GTE -> Value.GTE + INCLUDES -> Value.INCLUDES + IS_AFTER -> Value.IS_AFTER + IS_BEFORE -> Value.IS_BEFORE + LT -> Value.LT + LTE -> Value.LTE + NEQ -> Value.NEQ + OMIT -> Value.OMIT + STARTS_WITH -> Value.STARTS_WITH + AND -> Value.AND + OR -> Value.OR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENDS_WITH -> Known.ENDS_WITH + EQ -> Known.EQ + EXISTS -> Known.EXISTS + GT -> Known.GT + GTE -> Known.GTE + INCLUDES -> Known.INCLUDES + IS_AFTER -> Known.IS_AFTER + IS_BEFORE -> Known.IS_BEFORE + LT -> Known.LT + LTE -> Known.LTE + NEQ -> Known.NEQ + OMIT -> Known.OMIT + STARTS_WITH -> Known.STARTS_WITH + AND -> Known.AND + OR -> Known.OR + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + operator == other.operator && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(operator, path, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt new file mode 100644 index 00000000..441d786d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt @@ -0,0 +1,439 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class NestedFilterConfig +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val operator: JsonField, + private val rules: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("operator") @ExcludeMissing operator: JsonField = JsonMissing.of(), + @JsonProperty("rules") + @ExcludeMissing + rules: JsonField> = JsonMissing.of(), + ) : this(operator, rules, mutableMapOf()) + + /** + * The operator to use for filtering + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun rules(): List = rules.getRequired("rules") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [rules]. + * + * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NestedFilterConfig]. + * + * The following fields are required: + * ```java + * .operator() + * .rules() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NestedFilterConfig]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var rules: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(nestedFilterConfig: NestedFilterConfig) = apply { + operator = nestedFilterConfig.operator + rules = nestedFilterConfig.rules.map { it.toMutableList() } + additionalProperties = nestedFilterConfig.additionalProperties.toMutableMap() + } + + /** The operator to use for filtering */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun rules(rules: List) = rules(JsonField.of(rules)) + + /** + * Sets [Builder.rules] to an arbitrary JSON value. + * + * You should usually call [Builder.rules] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun rules(rules: JsonField>) = apply { + this.rules = rules.map { it.toMutableList() } + } + + /** + * Adds a single [FilterConfig] to [rules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRule(rule: FilterConfig) = apply { + rules = + (rules ?: JsonField.of(mutableListOf())).also { checkKnown("rules", it).add(rule) } + } + + /** Alias for calling [addRule] with `FilterConfig.ofUnionMember0(unionMember0)`. */ + fun addRule(unionMember0: FilterConfig.UnionMember0) = + addRule(FilterConfig.ofUnionMember0(unionMember0)) + + /** Alias for calling [addRule] with `FilterConfig.ofNested(nested)`. */ + fun addRule(nested: NestedFilterConfig) = addRule(FilterConfig.ofNested(nested)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NestedFilterConfig]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .rules() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NestedFilterConfig = + NestedFilterConfig( + checkRequired("operator", operator), + checkRequired("rules", rules).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NestedFilterConfig = apply { + if (validated) { + return@apply + } + + operator().validate() + rules().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + /** The operator to use for filtering */ + class Operator @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ENDS_WITH = of("ENDS_WITH") + + @JvmField val EQ = of("EQ") + + @JvmField val EXISTS = of("EXISTS") + + @JvmField val GT = of("GT") + + @JvmField val GTE = of("GTE") + + @JvmField val INCLUDES = of("INCLUDES") + + @JvmField val IS_AFTER = of("IS_AFTER") + + @JvmField val IS_BEFORE = of("IS_BEFORE") + + @JvmField val LT = of("LT") + + @JvmField val LTE = of("LTE") + + @JvmField val NEQ = of("NEQ") + + @JvmField val OMIT = of("OMIT") + + @JvmField val STARTS_WITH = of("STARTS_WITH") + + @JvmField val AND = of("AND") + + @JvmField val OR = of("OR") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + ENDS_WITH, + EQ, + EXISTS, + GT, + GTE, + INCLUDES, + IS_AFTER, + IS_BEFORE, + LT, + LTE, + NEQ, + OMIT, + STARTS_WITH, + AND, + OR, + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ENDS_WITH, + EQ, + EXISTS, + GT, + GTE, + INCLUDES, + IS_AFTER, + IS_BEFORE, + LT, + LTE, + NEQ, + OMIT, + STARTS_WITH, + AND, + OR, + /** An enum member indicating that [Operator] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ENDS_WITH -> Value.ENDS_WITH + EQ -> Value.EQ + EXISTS -> Value.EXISTS + GT -> Value.GT + GTE -> Value.GTE + INCLUDES -> Value.INCLUDES + IS_AFTER -> Value.IS_AFTER + IS_BEFORE -> Value.IS_BEFORE + LT -> Value.LT + LTE -> Value.LTE + NEQ -> Value.NEQ + OMIT -> Value.OMIT + STARTS_WITH -> Value.STARTS_WITH + AND -> Value.AND + OR -> Value.OR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ENDS_WITH -> Known.ENDS_WITH + EQ -> Known.EQ + EXISTS -> Known.EXISTS + GT -> Known.GT + GTE -> Known.GTE + INCLUDES -> Known.INCLUDES + IS_AFTER -> Known.IS_AFTER + IS_BEFORE -> Known.IS_BEFORE + LT -> Known.LT + LTE -> Known.LTE + NEQ -> Known.NEQ + OMIT -> Known.OMIT + STARTS_WITH -> Known.STARTS_WITH + AND -> Known.AND + OR -> Known.OR + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NestedFilterConfig && + operator == other.operator && + rules == other.rules && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(operator, rules, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NestedFilterConfig{operator=$operator, rules=$rules, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt new file mode 100644 index 00000000..c4aa366b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Paging +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val more: JsonField, + private val cursor: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("more") @ExcludeMissing more: JsonField = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + ) : this(more, cursor, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun more(): Boolean = more.getRequired("more") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * Returns the raw JSON value of [more]. + * + * Unlike [more], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("more") @ExcludeMissing fun _more(): JsonField = more + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Paging]. + * + * The following fields are required: + * ```java + * .more() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Paging]. */ + class Builder internal constructor() { + + private var more: JsonField? = null + private var cursor: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paging: Paging) = apply { + more = paging.more + cursor = paging.cursor + additionalProperties = paging.additionalProperties.toMutableMap() + } + + fun more(more: Boolean) = more(JsonField.of(more)) + + /** + * Sets [Builder.more] to an arbitrary JSON value. + * + * You should usually call [Builder.more] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun more(more: JsonField) = apply { this.more = more } + + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Paging]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .more() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Paging = + Paging(checkRequired("more", more), cursor, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Paging = apply { + if (validated) { + return@apply + } + + more() + cursor() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (more.asKnown().isPresent) 1 else 0) + (if (cursor.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Paging && + more == other.more && + cursor == other.cursor && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(more, cursor, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Paging{more=$more, cursor=$cursor, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt new file mode 100644 index 00000000..693e852b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt @@ -0,0 +1,703 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AuditEvent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val auditEventId: JsonField, + private val source: JsonField, + private val timestamp: JsonField, + private val type: JsonField, + private val actor: JsonField, + private val target: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("auditEventId") + @ExcludeMissing + auditEventId: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") @ExcludeMissing timestamp: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("actor") @ExcludeMissing actor: JsonField = JsonMissing.of(), + @JsonProperty("target") @ExcludeMissing target: JsonField = JsonMissing.of(), + ) : this(auditEventId, source, timestamp, type, actor, target, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun auditEventId(): String = auditEventId.getRequired("auditEventId") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun source(): String = source.getRequired("source") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun timestamp(): String = timestamp.getRequired("timestamp") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): String = type.getRequired("type") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun actor(): Optional = actor.getOptional("actor") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun target(): Optional = target.getOptional("target") + + /** + * Returns the raw JSON value of [auditEventId]. + * + * Unlike [auditEventId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("auditEventId") + @ExcludeMissing + fun _auditEventId(): JsonField = auditEventId + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [timestamp]. + * + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timestamp") @ExcludeMissing fun _timestamp(): JsonField = timestamp + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [actor]. + * + * Unlike [actor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("actor") @ExcludeMissing fun _actor(): JsonField = actor + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AuditEvent]. + * + * The following fields are required: + * ```java + * .auditEventId() + * .source() + * .timestamp() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuditEvent]. */ + class Builder internal constructor() { + + private var auditEventId: JsonField? = null + private var source: JsonField? = null + private var timestamp: JsonField? = null + private var type: JsonField? = null + private var actor: JsonField = JsonMissing.of() + private var target: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(auditEvent: AuditEvent) = apply { + auditEventId = auditEvent.auditEventId + source = auditEvent.source + timestamp = auditEvent.timestamp + type = auditEvent.type + actor = auditEvent.actor + target = auditEvent.target + additionalProperties = auditEvent.additionalProperties.toMutableMap() + } + + fun auditEventId(auditEventId: String) = auditEventId(JsonField.of(auditEventId)) + + /** + * Sets [Builder.auditEventId] to an arbitrary JSON value. + * + * You should usually call [Builder.auditEventId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun auditEventId(auditEventId: JsonField) = apply { + this.auditEventId = auditEventId + } + + fun source(source: String) = source(JsonField.of(source)) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun timestamp(timestamp: String) = timestamp(JsonField.of(timestamp)) + + /** + * Sets [Builder.timestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.timestamp] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun timestamp(timestamp: JsonField) = apply { this.timestamp = timestamp } + + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun actor(actor: Actor?) = actor(JsonField.ofNullable(actor)) + + /** Alias for calling [Builder.actor] with `actor.orElse(null)`. */ + fun actor(actor: Optional) = actor(actor.getOrNull()) + + /** + * Sets [Builder.actor] to an arbitrary JSON value. + * + * You should usually call [Builder.actor] with a well-typed [Actor] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun actor(actor: JsonField) = apply { this.actor = actor } + + fun target(target: Target?) = target(JsonField.ofNullable(target)) + + /** Alias for calling [Builder.target] with `target.orElse(null)`. */ + fun target(target: Optional) = target(target.getOrNull()) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [Target] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AuditEvent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .auditEventId() + * .source() + * .timestamp() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AuditEvent = + AuditEvent( + checkRequired("auditEventId", auditEventId), + checkRequired("source", source), + checkRequired("timestamp", timestamp), + checkRequired("type", type), + actor, + target, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuditEvent = apply { + if (validated) { + return@apply + } + + auditEventId() + source() + timestamp() + type() + actor().ifPresent { it.validate() } + target().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (auditEventId.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + (actor.asKnown().getOrNull()?.validity() ?: 0) + + (target.asKnown().getOrNull()?.validity() ?: 0) + + class Actor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + ) : this(id, email, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Actor]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Actor]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(actor: Actor) = apply { + id = actor.id + email = actor.email + additionalProperties = actor.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Actor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Actor = Actor(id, email, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Actor = apply { + if (validated) { + return@apply + } + + id() + email() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Actor && + id == other.id && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, email, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Actor{id=$id, email=$email, additionalProperties=$additionalProperties}" + } + + class Target + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + ) : this(id, email, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Target]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Target]. */ + class Builder internal constructor() { + + private var id: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(target: Target) = apply { + id = target.id + email = target.email + additionalProperties = target.additionalProperties.toMutableMap() + } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Target]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Target = Target(id, email, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Target = apply { + if (validated) { + return@apply + } + + id() + email() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + (if (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Target && + id == other.id && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, email, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Target{id=$id, email=$email, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuditEvent && + auditEventId == other.auditEventId && + source == other.source && + timestamp == other.timestamp && + type == other.type && + actor == other.actor && + target == other.target && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(auditEventId, source, timestamp, type, actor, target, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuditEvent{auditEventId=$auditEventId, source=$source, timestamp=$timestamp, type=$type, actor=$actor, target=$target, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt new file mode 100644 index 00000000..4ae23645 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch the list of audit events */ +class AuditEventListParams +private constructor( + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** A unique identifier that allows for fetching the next set of audit events. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AuditEventListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AuditEventListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuditEventListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(auditEventListParams: AuditEventListParams) = apply { + cursor = auditEventListParams.cursor + additionalHeaders = auditEventListParams.additionalHeaders.toBuilder() + additionalQueryParams = auditEventListParams.additionalQueryParams.toBuilder() + } + + /** A unique identifier that allows for fetching the next set of audit events. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AuditEventListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AuditEventListParams = + AuditEventListParams(cursor, additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuditEventListParams && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AuditEventListParams{cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt new file mode 100644 index 00000000..d5382159 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt @@ -0,0 +1,226 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class AuditEventListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val paging: JsonField, + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + ) : this(paging, results, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AuditEventListResponse]. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuditEventListResponse]. */ + class Builder internal constructor() { + + private var paging: JsonField? = null + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(auditEventListResponse: AuditEventListResponse) = apply { + paging = auditEventListResponse.paging + results = auditEventListResponse.results.map { it.toMutableList() } + additionalProperties = auditEventListResponse.additionalProperties.toMutableMap() + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [AuditEvent] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: AuditEvent) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AuditEventListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AuditEventListResponse = + AuditEventListResponse( + checkRequired("paging", paging), + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AuditEventListResponse = apply { + if (validated) { + return@apply + } + + paging().validate() + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuditEventListResponse && + paging == other.paging && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuditEventListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt new file mode 100644 index 00000000..cfe342b4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch a specific audit event by ID. */ +class AuditEventRetrieveParams +private constructor( + private val auditEventId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun auditEventId(): Optional = Optional.ofNullable(auditEventId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AuditEventRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AuditEventRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuditEventRetrieveParams]. */ + class Builder internal constructor() { + + private var auditEventId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(auditEventRetrieveParams: AuditEventRetrieveParams) = apply { + auditEventId = auditEventRetrieveParams.auditEventId + additionalHeaders = auditEventRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = auditEventRetrieveParams.additionalQueryParams.toBuilder() + } + + fun auditEventId(auditEventId: String?) = apply { this.auditEventId = auditEventId } + + /** Alias for calling [Builder.auditEventId] with `auditEventId.orElse(null)`. */ + fun auditEventId(auditEventId: Optional) = auditEventId(auditEventId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AuditEventRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AuditEventRetrieveParams = + AuditEventRetrieveParams( + auditEventId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> auditEventId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuditEventRetrieveParams && + auditEventId == other.auditEventId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(auditEventId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AuditEventRetrieveParams{auditEventId=$auditEventId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt new file mode 100644 index 00000000..ac7bae84 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt @@ -0,0 +1,676 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auth + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Returns a new access token. */ +class AuthIssueTokenParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expiresIn(): String = body.expiresIn() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scope(): Scope = body.scope() + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _expiresIn(): JsonField = body._expiresIn() + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _scope(): JsonField = body._scope() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AuthIssueTokenParams]. + * + * The following fields are required: + * ```java + * .expiresIn() + * .scope() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthIssueTokenParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(authIssueTokenParams: AuthIssueTokenParams) = apply { + body = authIssueTokenParams.body.toBuilder() + additionalHeaders = authIssueTokenParams.additionalHeaders.toBuilder() + additionalQueryParams = authIssueTokenParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [expiresIn] + * - [scope] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun expiresIn(expiresIn: String) = apply { body.expiresIn(expiresIn) } + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expiresIn(expiresIn: JsonField) = apply { body.expiresIn(expiresIn) } + + fun scope(scope: Scope) = apply { body.scope(scope) } + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun scope(scope: JsonField) = apply { body.scope(scope) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AuthIssueTokenParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expiresIn() + * .scope() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AuthIssueTokenParams = + AuthIssueTokenParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expiresIn: JsonField, + private val scope: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expires_in") + @ExcludeMissing + expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("scope") @ExcludeMissing scope: JsonField = JsonMissing.of(), + ) : this(expiresIn, scope, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expiresIn(): String = expiresIn.getRequired("expires_in") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun scope(): Scope = scope.getRequired("scope") + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .expiresIn() + * .scope() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var expiresIn: JsonField? = null + private var scope: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + expiresIn = body.expiresIn + scope = body.scope + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun expiresIn(expiresIn: String) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + fun scope(scope: Scope) = scope(JsonField.of(scope)) + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scope(scope: JsonField) = apply { this.scope = scope } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expiresIn() + * .scope() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("expiresIn", expiresIn), + checkRequired("scope", scope), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + expiresIn() + scope().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (scope.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + expiresIn == other.expiresIn && + scope == other.scope && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(expiresIn, scope, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{expiresIn=$expiresIn, scope=$scope, additionalProperties=$additionalProperties}" + } + + class Scope @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val READ_PREFERENCES = of("read:preferences") + + @JvmField val WRITE_PREFERENCES = of("write:preferences") + + @JvmField val READ_USER_TOKENS = of("read:user-tokens") + + @JvmField val WRITE_USER_TOKENS = of("write:user-tokens") + + @JvmField val READ_BRANDS = of("read:brands") + + @JvmField val WRITE_BRANDS = of("write:brands") + + @JvmField val READ_BRANDS_ID = of("read:brands{:id}") + + @JvmField val WRITE_BRANDS_ID = of("write:brands{:id}") + + @JvmField val WRITE_TRACK = of("write:track") + + @JvmField val INBOX_READ_MESSAGES = of("inbox:read:messages") + + @JvmField val INBOX_WRITE_MESSAGES = of("inbox:write:messages") + + @JvmField val INBOX_WRITE_EVENT = of("inbox:write:event") + + @JvmField val INBOX_WRITE_EVENTS = of("inbox:write:events") + + @JvmField val USER_ID_YOUR_USER_ID = of("user_id:\$YOUR_USER_ID") + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + /** An enum containing [Scope]'s known values. */ + enum class Known { + READ_PREFERENCES, + WRITE_PREFERENCES, + READ_USER_TOKENS, + WRITE_USER_TOKENS, + READ_BRANDS, + WRITE_BRANDS, + READ_BRANDS_ID, + WRITE_BRANDS_ID, + WRITE_TRACK, + INBOX_READ_MESSAGES, + INBOX_WRITE_MESSAGES, + INBOX_WRITE_EVENT, + INBOX_WRITE_EVENTS, + USER_ID_YOUR_USER_ID, + } + + /** + * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Scope] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + READ_PREFERENCES, + WRITE_PREFERENCES, + READ_USER_TOKENS, + WRITE_USER_TOKENS, + READ_BRANDS, + WRITE_BRANDS, + READ_BRANDS_ID, + WRITE_BRANDS_ID, + WRITE_TRACK, + INBOX_READ_MESSAGES, + INBOX_WRITE_MESSAGES, + INBOX_WRITE_EVENT, + INBOX_WRITE_EVENTS, + USER_ID_YOUR_USER_ID, + /** An enum member indicating that [Scope] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + READ_PREFERENCES -> Value.READ_PREFERENCES + WRITE_PREFERENCES -> Value.WRITE_PREFERENCES + READ_USER_TOKENS -> Value.READ_USER_TOKENS + WRITE_USER_TOKENS -> Value.WRITE_USER_TOKENS + READ_BRANDS -> Value.READ_BRANDS + WRITE_BRANDS -> Value.WRITE_BRANDS + READ_BRANDS_ID -> Value.READ_BRANDS_ID + WRITE_BRANDS_ID -> Value.WRITE_BRANDS_ID + WRITE_TRACK -> Value.WRITE_TRACK + INBOX_READ_MESSAGES -> Value.INBOX_READ_MESSAGES + INBOX_WRITE_MESSAGES -> Value.INBOX_WRITE_MESSAGES + INBOX_WRITE_EVENT -> Value.INBOX_WRITE_EVENT + INBOX_WRITE_EVENTS -> Value.INBOX_WRITE_EVENTS + USER_ID_YOUR_USER_ID -> Value.USER_ID_YOUR_USER_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + READ_PREFERENCES -> Known.READ_PREFERENCES + WRITE_PREFERENCES -> Known.WRITE_PREFERENCES + READ_USER_TOKENS -> Known.READ_USER_TOKENS + WRITE_USER_TOKENS -> Known.WRITE_USER_TOKENS + READ_BRANDS -> Known.READ_BRANDS + WRITE_BRANDS -> Known.WRITE_BRANDS + READ_BRANDS_ID -> Known.READ_BRANDS_ID + WRITE_BRANDS_ID -> Known.WRITE_BRANDS_ID + WRITE_TRACK -> Known.WRITE_TRACK + INBOX_READ_MESSAGES -> Known.INBOX_READ_MESSAGES + INBOX_WRITE_MESSAGES -> Known.INBOX_WRITE_MESSAGES + INBOX_WRITE_EVENT -> Known.INBOX_WRITE_EVENT + INBOX_WRITE_EVENTS -> Known.INBOX_WRITE_EVENTS + USER_ID_YOUR_USER_ID -> Known.USER_ID_YOUR_USER_ID + else -> throw CourierInvalidDataException("Unknown Scope: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Scope = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthIssueTokenParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AuthIssueTokenParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt new file mode 100644 index 00000000..eed08cfb --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auth + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AuthIssueTokenResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val token: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of() + ) : this(token, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AuthIssueTokenResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AuthIssueTokenResponse]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authIssueTokenResponse: AuthIssueTokenResponse) = apply { + token = authIssueTokenResponse.token + additionalProperties = authIssueTokenResponse.additionalProperties.toMutableMap() + } + + fun token(token: String?) = token(JsonField.ofNullable(token)) + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AuthIssueTokenResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AuthIssueTokenResponse = + AuthIssueTokenResponse(token, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AuthIssueTokenResponse = apply { + if (validated) { + return@apply + } + + token() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AuthIssueTokenResponse && + token == other.token && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(token, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthIssueTokenResponse{token=$token, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt new file mode 100644 index 00000000..19dc6816 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt @@ -0,0 +1,9460 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.automations.invoke.AutomationInvokeParams +import com.courier.api.models.automations.invoke.AutomationStep +import com.courier.api.models.automations.invoke.MergeAlgorithm +import com.courier.api.models.send.Message +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation + * steps. For information about what steps are available, checkout the ad hoc automation guide + * [here](https://www.courier.com/docs/automations/steps/). + */ +class AutomationInvokeAdHocParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brand(): Optional = body.brand() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = body.data() + + fun _profile(): JsonValue = body._profile() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recipient(): Optional = body.recipient() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun template(): Optional = body.template() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun automation(): Automation = body.automation() + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _brand(): JsonField = body._brand() + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _data(): JsonField = body._data() + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _recipient(): JsonField = body._recipient() + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _template(): JsonField = body._template() + + /** + * Returns the raw JSON value of [automation]. + * + * Unlike [automation], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _automation(): JsonField = body._automation() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutomationInvokeAdHocParams]. + * + * The following fields are required: + * ```java + * .automation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationInvokeAdHocParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(automationInvokeAdHocParams: AutomationInvokeAdHocParams) = apply { + body = automationInvokeAdHocParams.body.toBuilder() + additionalHeaders = automationInvokeAdHocParams.additionalHeaders.toBuilder() + additionalQueryParams = automationInvokeAdHocParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [brand] + * - [data] + * - [profile] + * - [recipient] + * - [template] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun brand(brand: String?) = apply { body.brand(brand) } + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brand(brand: JsonField) = apply { body.brand(brand) } + + fun data(data: AutomationInvokeParams.Data?) = apply { body.data(data) } + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [AutomationInvokeParams.Data] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField) = apply { body.data(data) } + + fun profile(profile: JsonValue) = apply { body.profile(profile) } + + fun recipient(recipient: String?) = apply { body.recipient(recipient) } + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipient(recipient: JsonField) = apply { body.recipient(recipient) } + + fun template(template: String?) = apply { body.template(template) } + + /** Alias for calling [Builder.template] with `template.orElse(null)`. */ + fun template(template: Optional) = template(template.getOrNull()) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun template(template: JsonField) = apply { body.template(template) } + + fun automation(automation: Automation) = apply { body.automation(automation) } + + /** + * Sets [Builder.automation] to an arbitrary JSON value. + * + * You should usually call [Builder.automation] with a well-typed [Automation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automation(automation: JsonField) = apply { body.automation(automation) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AutomationInvokeAdHocParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .automation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationInvokeAdHocParams = + AutomationInvokeAdHocParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brand: JsonField, + private val data: JsonField, + private val profile: JsonValue, + private val recipient: JsonField, + private val template: JsonField, + private val automation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), + @JsonProperty("recipient") + @ExcludeMissing + recipient: JsonField = JsonMissing.of(), + @JsonProperty("template") + @ExcludeMissing + template: JsonField = JsonMissing.of(), + @JsonProperty("automation") + @ExcludeMissing + automation: JsonField = JsonMissing.of(), + ) : this(brand, data, profile, recipient, template, automation, mutableMapOf()) + + fun toAutomationInvokeParams(): AutomationInvokeParams = + AutomationInvokeParams.builder() + .brand(brand) + .data(data) + .profile(profile) + .recipient(recipient) + .template(template) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brand(): Optional = brand.getOptional("brand") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recipient(): Optional = recipient.getOptional("recipient") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun template(): Optional = template.getOptional("template") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun automation(): Automation = automation.getRequired("automation") + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") + @ExcludeMissing + fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template + + /** + * Returns the raw JSON value of [automation]. + * + * Unlike [automation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("automation") + @ExcludeMissing + fun _automation(): JsonField = automation + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .automation() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var brand: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var profile: JsonValue = JsonMissing.of() + private var recipient: JsonField = JsonMissing.of() + private var template: JsonField = JsonMissing.of() + private var automation: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + brand = body.brand + data = body.data + profile = body.profile + recipient = body.recipient + template = body.template + automation = body.automation + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brand(brand: JsonField) = apply { this.brand = brand } + + fun data(data: AutomationInvokeParams.Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed + * [AutomationInvokeParams.Data] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun profile(profile: JsonValue) = apply { this.profile = profile } + + fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + fun template(template: String?) = template(JsonField.ofNullable(template)) + + /** Alias for calling [Builder.template] with `template.orElse(null)`. */ + fun template(template: Optional) = template(template.getOrNull()) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun automation(automation: Automation) = automation(JsonField.of(automation)) + + /** + * Sets [Builder.automation] to an arbitrary JSON value. + * + * You should usually call [Builder.automation] with a well-typed [Automation] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun automation(automation: JsonField) = apply { + this.automation = automation + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .automation() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + brand, + data, + profile, + recipient, + template, + checkRequired("automation", automation), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + brand() + data().ifPresent { it.validate() } + recipient() + template() + automation().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brand.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (if (template.asKnown().isPresent) 1 else 0) + + (automation.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + brand == other.brand && + data == other.data && + profile == other.profile && + recipient == other.recipient && + template == other.template && + automation == other.automation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brand, + data, + profile, + recipient, + template, + automation, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{brand=$brand, data=$data, profile=$profile, recipient=$recipient, template=$template, automation=$automation, additionalProperties=$additionalProperties}" + } + + class Automation + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val steps: JsonField>, + private val cancelationToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("steps") @ExcludeMissing steps: JsonField> = JsonMissing.of(), + @JsonProperty("cancelation_token") + @ExcludeMissing + cancelationToken: JsonField = JsonMissing.of(), + ) : this(steps, cancelationToken, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun steps(): List = steps.getRequired("steps") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cancelationToken(): Optional = cancelationToken.getOptional("cancelation_token") + + /** + * Returns the raw JSON value of [steps]. + * + * Unlike [steps], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("steps") @ExcludeMissing fun _steps(): JsonField> = steps + + /** + * Returns the raw JSON value of [cancelationToken]. + * + * Unlike [cancelationToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("cancelation_token") + @ExcludeMissing + fun _cancelationToken(): JsonField = cancelationToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Automation]. + * + * The following fields are required: + * ```java + * .steps() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Automation]. */ + class Builder internal constructor() { + + private var steps: JsonField>? = null + private var cancelationToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automation: Automation) = apply { + steps = automation.steps.map { it.toMutableList() } + cancelationToken = automation.cancelationToken + additionalProperties = automation.additionalProperties.toMutableMap() + } + + fun steps(steps: List) = steps(JsonField.of(steps)) + + /** + * Sets [Builder.steps] to an arbitrary JSON value. + * + * You should usually call [Builder.steps] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun steps(steps: JsonField>) = apply { + this.steps = steps.map { it.toMutableList() } + } + + /** + * Adds a single [Step] to [steps]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStep(step: Step) = apply { + steps = + (steps ?: JsonField.of(mutableListOf())).also { + checkKnown("steps", it).add(step) + } + } + + /** + * Alias for calling [addStep] with + * `Step.ofAutomationAddToDigest(automationAddToDigest)`. + */ + fun addStep(automationAddToDigest: Step.AutomationAddToDigestStep) = + addStep(Step.ofAutomationAddToDigest(automationAddToDigest)) + + /** + * Alias for calling [addStep] with `Step.ofAutomationAddToBatch(automationAddToBatch)`. + */ + fun addStep(automationAddToBatch: Step.AutomationAddToBatchStep) = + addStep(Step.ofAutomationAddToBatch(automationAddToBatch)) + + /** Alias for calling [addStep] with `Step.ofAutomationThrottle(automationThrottle)`. */ + fun addStep(automationThrottle: Step.AutomationThrottleStep) = + addStep(Step.ofAutomationThrottle(automationThrottle)) + + /** Alias for calling [addStep] with `Step.ofAutomationCancel(automationCancel)`. */ + fun addStep(automationCancel: Step.AutomationCancelStep) = + addStep(Step.ofAutomationCancel(automationCancel)) + + /** Alias for calling [addStep] with `Step.ofAutomationDelay(automationDelay)`. */ + fun addStep(automationDelay: Step.AutomationDelayStep) = + addStep(Step.ofAutomationDelay(automationDelay)) + + /** + * Alias for calling [addStep] with `Step.ofAutomationFetchData(automationFetchData)`. + */ + fun addStep(automationFetchData: Step.AutomationFetchDataStep) = + addStep(Step.ofAutomationFetchData(automationFetchData)) + + /** Alias for calling [addStep] with `Step.ofAutomationInvoke(automationInvoke)`. */ + fun addStep(automationInvoke: Step.AutomationInvokeStep) = + addStep(Step.ofAutomationInvoke(automationInvoke)) + + /** Alias for calling [addStep] with `Step.ofAutomationSend(automationSend)`. */ + fun addStep(automationSend: Step.AutomationSendStep) = + addStep(Step.ofAutomationSend(automationSend)) + + /** Alias for calling [addStep] with `Step.ofAutomationV2Send(automationV2Send)`. */ + fun addStep(automationV2Send: Step.AutomationV2SendStep) = + addStep(Step.ofAutomationV2Send(automationV2Send)) + + /** Alias for calling [addStep] with `Step.ofAutomationSendList(automationSendList)`. */ + fun addStep(automationSendList: Step.AutomationSendListStep) = + addStep(Step.ofAutomationSendList(automationSendList)) + + /** + * Alias for calling [addStep] with + * `Step.ofAutomationUpdateProfile(automationUpdateProfile)`. + */ + fun addStep(automationUpdateProfile: Step.AutomationUpdateProfileStep) = + addStep(Step.ofAutomationUpdateProfile(automationUpdateProfile)) + + fun cancelationToken(cancelationToken: String?) = + cancelationToken(JsonField.ofNullable(cancelationToken)) + + /** + * Alias for calling [Builder.cancelationToken] with `cancelationToken.orElse(null)`. + */ + fun cancelationToken(cancelationToken: Optional) = + cancelationToken(cancelationToken.getOrNull()) + + /** + * Sets [Builder.cancelationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cancelationToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cancelationToken(cancelationToken: JsonField) = apply { + this.cancelationToken = cancelationToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Automation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .steps() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Automation = + Automation( + checkRequired("steps", steps).map { it.toImmutable() }, + cancelationToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Automation = apply { + if (validated) { + return@apply + } + + steps().forEach { it.validate() } + cancelationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (steps.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (cancelationToken.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Step.Deserializer::class) + @JsonSerialize(using = Step.Serializer::class) + class Step + private constructor( + private val automationAddToDigest: AutomationAddToDigestStep? = null, + private val automationAddToBatch: AutomationAddToBatchStep? = null, + private val automationThrottle: AutomationThrottleStep? = null, + private val automationCancel: AutomationCancelStep? = null, + private val automationDelay: AutomationDelayStep? = null, + private val automationFetchData: AutomationFetchDataStep? = null, + private val automationInvoke: AutomationInvokeStep? = null, + private val automationSend: AutomationSendStep? = null, + private val automationV2Send: AutomationV2SendStep? = null, + private val automationSendList: AutomationSendListStep? = null, + private val automationUpdateProfile: AutomationUpdateProfileStep? = null, + private val _json: JsonValue? = null, + ) { + + fun automationAddToDigest(): Optional = + Optional.ofNullable(automationAddToDigest) + + fun automationAddToBatch(): Optional = + Optional.ofNullable(automationAddToBatch) + + fun automationThrottle(): Optional = + Optional.ofNullable(automationThrottle) + + fun automationCancel(): Optional = + Optional.ofNullable(automationCancel) + + fun automationDelay(): Optional = + Optional.ofNullable(automationDelay) + + fun automationFetchData(): Optional = + Optional.ofNullable(automationFetchData) + + fun automationInvoke(): Optional = + Optional.ofNullable(automationInvoke) + + fun automationSend(): Optional = Optional.ofNullable(automationSend) + + fun automationV2Send(): Optional = + Optional.ofNullable(automationV2Send) + + fun automationSendList(): Optional = + Optional.ofNullable(automationSendList) + + fun automationUpdateProfile(): Optional = + Optional.ofNullable(automationUpdateProfile) + + fun isAutomationAddToDigest(): Boolean = automationAddToDigest != null + + fun isAutomationAddToBatch(): Boolean = automationAddToBatch != null + + fun isAutomationThrottle(): Boolean = automationThrottle != null + + fun isAutomationCancel(): Boolean = automationCancel != null + + fun isAutomationDelay(): Boolean = automationDelay != null + + fun isAutomationFetchData(): Boolean = automationFetchData != null + + fun isAutomationInvoke(): Boolean = automationInvoke != null + + fun isAutomationSend(): Boolean = automationSend != null + + fun isAutomationV2Send(): Boolean = automationV2Send != null + + fun isAutomationSendList(): Boolean = automationSendList != null + + fun isAutomationUpdateProfile(): Boolean = automationUpdateProfile != null + + fun asAutomationAddToDigest(): AutomationAddToDigestStep = + automationAddToDigest.getOrThrow("automationAddToDigest") + + fun asAutomationAddToBatch(): AutomationAddToBatchStep = + automationAddToBatch.getOrThrow("automationAddToBatch") + + fun asAutomationThrottle(): AutomationThrottleStep = + automationThrottle.getOrThrow("automationThrottle") + + fun asAutomationCancel(): AutomationCancelStep = + automationCancel.getOrThrow("automationCancel") + + fun asAutomationDelay(): AutomationDelayStep = + automationDelay.getOrThrow("automationDelay") + + fun asAutomationFetchData(): AutomationFetchDataStep = + automationFetchData.getOrThrow("automationFetchData") + + fun asAutomationInvoke(): AutomationInvokeStep = + automationInvoke.getOrThrow("automationInvoke") + + fun asAutomationSend(): AutomationSendStep = automationSend.getOrThrow("automationSend") + + fun asAutomationV2Send(): AutomationV2SendStep = + automationV2Send.getOrThrow("automationV2Send") + + fun asAutomationSendList(): AutomationSendListStep = + automationSendList.getOrThrow("automationSendList") + + fun asAutomationUpdateProfile(): AutomationUpdateProfileStep = + automationUpdateProfile.getOrThrow("automationUpdateProfile") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + automationAddToDigest != null -> + visitor.visitAutomationAddToDigest(automationAddToDigest) + automationAddToBatch != null -> + visitor.visitAutomationAddToBatch(automationAddToBatch) + automationThrottle != null -> + visitor.visitAutomationThrottle(automationThrottle) + automationCancel != null -> visitor.visitAutomationCancel(automationCancel) + automationDelay != null -> visitor.visitAutomationDelay(automationDelay) + automationFetchData != null -> + visitor.visitAutomationFetchData(automationFetchData) + automationInvoke != null -> visitor.visitAutomationInvoke(automationInvoke) + automationSend != null -> visitor.visitAutomationSend(automationSend) + automationV2Send != null -> visitor.visitAutomationV2Send(automationV2Send) + automationSendList != null -> + visitor.visitAutomationSendList(automationSendList) + automationUpdateProfile != null -> + visitor.visitAutomationUpdateProfile(automationUpdateProfile) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Step = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAutomationAddToDigest( + automationAddToDigest: AutomationAddToDigestStep + ) { + automationAddToDigest.validate() + } + + override fun visitAutomationAddToBatch( + automationAddToBatch: AutomationAddToBatchStep + ) { + automationAddToBatch.validate() + } + + override fun visitAutomationThrottle( + automationThrottle: AutomationThrottleStep + ) { + automationThrottle.validate() + } + + override fun visitAutomationCancel(automationCancel: AutomationCancelStep) { + automationCancel.validate() + } + + override fun visitAutomationDelay(automationDelay: AutomationDelayStep) { + automationDelay.validate() + } + + override fun visitAutomationFetchData( + automationFetchData: AutomationFetchDataStep + ) { + automationFetchData.validate() + } + + override fun visitAutomationInvoke(automationInvoke: AutomationInvokeStep) { + automationInvoke.validate() + } + + override fun visitAutomationSend(automationSend: AutomationSendStep) { + automationSend.validate() + } + + override fun visitAutomationV2Send(automationV2Send: AutomationV2SendStep) { + automationV2Send.validate() + } + + override fun visitAutomationSendList( + automationSendList: AutomationSendListStep + ) { + automationSendList.validate() + } + + override fun visitAutomationUpdateProfile( + automationUpdateProfile: AutomationUpdateProfileStep + ) { + automationUpdateProfile.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAutomationAddToDigest( + automationAddToDigest: AutomationAddToDigestStep + ) = automationAddToDigest.validity() + + override fun visitAutomationAddToBatch( + automationAddToBatch: AutomationAddToBatchStep + ) = automationAddToBatch.validity() + + override fun visitAutomationThrottle( + automationThrottle: AutomationThrottleStep + ) = automationThrottle.validity() + + override fun visitAutomationCancel(automationCancel: AutomationCancelStep) = + automationCancel.validity() + + override fun visitAutomationDelay(automationDelay: AutomationDelayStep) = + automationDelay.validity() + + override fun visitAutomationFetchData( + automationFetchData: AutomationFetchDataStep + ) = automationFetchData.validity() + + override fun visitAutomationInvoke(automationInvoke: AutomationInvokeStep) = + automationInvoke.validity() + + override fun visitAutomationSend(automationSend: AutomationSendStep) = + automationSend.validity() + + override fun visitAutomationV2Send(automationV2Send: AutomationV2SendStep) = + automationV2Send.validity() + + override fun visitAutomationSendList( + automationSendList: AutomationSendListStep + ) = automationSendList.validity() + + override fun visitAutomationUpdateProfile( + automationUpdateProfile: AutomationUpdateProfileStep + ) = automationUpdateProfile.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Step && + automationAddToDigest == other.automationAddToDigest && + automationAddToBatch == other.automationAddToBatch && + automationThrottle == other.automationThrottle && + automationCancel == other.automationCancel && + automationDelay == other.automationDelay && + automationFetchData == other.automationFetchData && + automationInvoke == other.automationInvoke && + automationSend == other.automationSend && + automationV2Send == other.automationV2Send && + automationSendList == other.automationSendList && + automationUpdateProfile == other.automationUpdateProfile + } + + override fun hashCode(): Int = + Objects.hash( + automationAddToDigest, + automationAddToBatch, + automationThrottle, + automationCancel, + automationDelay, + automationFetchData, + automationInvoke, + automationSend, + automationV2Send, + automationSendList, + automationUpdateProfile, + ) + + override fun toString(): String = + when { + automationAddToDigest != null -> + "Step{automationAddToDigest=$automationAddToDigest}" + automationAddToBatch != null -> + "Step{automationAddToBatch=$automationAddToBatch}" + automationThrottle != null -> "Step{automationThrottle=$automationThrottle}" + automationCancel != null -> "Step{automationCancel=$automationCancel}" + automationDelay != null -> "Step{automationDelay=$automationDelay}" + automationFetchData != null -> "Step{automationFetchData=$automationFetchData}" + automationInvoke != null -> "Step{automationInvoke=$automationInvoke}" + automationSend != null -> "Step{automationSend=$automationSend}" + automationV2Send != null -> "Step{automationV2Send=$automationV2Send}" + automationSendList != null -> "Step{automationSendList=$automationSendList}" + automationUpdateProfile != null -> + "Step{automationUpdateProfile=$automationUpdateProfile}" + _json != null -> "Step{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Step") + } + + companion object { + + @JvmStatic + fun ofAutomationAddToDigest(automationAddToDigest: AutomationAddToDigestStep) = + Step(automationAddToDigest = automationAddToDigest) + + @JvmStatic + fun ofAutomationAddToBatch(automationAddToBatch: AutomationAddToBatchStep) = + Step(automationAddToBatch = automationAddToBatch) + + @JvmStatic + fun ofAutomationThrottle(automationThrottle: AutomationThrottleStep) = + Step(automationThrottle = automationThrottle) + + @JvmStatic + fun ofAutomationCancel(automationCancel: AutomationCancelStep) = + Step(automationCancel = automationCancel) + + @JvmStatic + fun ofAutomationDelay(automationDelay: AutomationDelayStep) = + Step(automationDelay = automationDelay) + + @JvmStatic + fun ofAutomationFetchData(automationFetchData: AutomationFetchDataStep) = + Step(automationFetchData = automationFetchData) + + @JvmStatic + fun ofAutomationInvoke(automationInvoke: AutomationInvokeStep) = + Step(automationInvoke = automationInvoke) + + @JvmStatic + fun ofAutomationSend(automationSend: AutomationSendStep) = + Step(automationSend = automationSend) + + @JvmStatic + fun ofAutomationV2Send(automationV2Send: AutomationV2SendStep) = + Step(automationV2Send = automationV2Send) + + @JvmStatic + fun ofAutomationSendList(automationSendList: AutomationSendListStep) = + Step(automationSendList = automationSendList) + + @JvmStatic + fun ofAutomationUpdateProfile( + automationUpdateProfile: AutomationUpdateProfileStep + ) = Step(automationUpdateProfile = automationUpdateProfile) + } + + /** + * An interface that defines how to map each variant of [Step] to a value of type [T]. + */ + interface Visitor { + + fun visitAutomationAddToDigest(automationAddToDigest: AutomationAddToDigestStep): T + + fun visitAutomationAddToBatch(automationAddToBatch: AutomationAddToBatchStep): T + + fun visitAutomationThrottle(automationThrottle: AutomationThrottleStep): T + + fun visitAutomationCancel(automationCancel: AutomationCancelStep): T + + fun visitAutomationDelay(automationDelay: AutomationDelayStep): T + + fun visitAutomationFetchData(automationFetchData: AutomationFetchDataStep): T + + fun visitAutomationInvoke(automationInvoke: AutomationInvokeStep): T + + fun visitAutomationSend(automationSend: AutomationSendStep): T + + fun visitAutomationV2Send(automationV2Send: AutomationV2SendStep): T + + fun visitAutomationSendList(automationSendList: AutomationSendListStep): T + + fun visitAutomationUpdateProfile( + automationUpdateProfile: AutomationUpdateProfileStep + ): T + + /** + * Maps an unknown variant of [Step] to a value of type [T]. + * + * An instance of [Step] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Step: $json") + } + } + + internal class Deserializer : BaseDeserializer(Step::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Step { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Step(automationAddToDigest = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Step(automationAddToBatch = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Step(automationThrottle = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Step(automationCancel = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Step(automationDelay = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Step(automationFetchData = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Step(automationInvoke = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Step(automationSend = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Step(automationV2Send = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Step(automationSendList = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Step(automationUpdateProfile = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Step(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Step::class) { + + override fun serialize( + value: Step, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.automationAddToDigest != null -> + generator.writeObject(value.automationAddToDigest) + value.automationAddToBatch != null -> + generator.writeObject(value.automationAddToBatch) + value.automationThrottle != null -> + generator.writeObject(value.automationThrottle) + value.automationCancel != null -> + generator.writeObject(value.automationCancel) + value.automationDelay != null -> + generator.writeObject(value.automationDelay) + value.automationFetchData != null -> + generator.writeObject(value.automationFetchData) + value.automationInvoke != null -> + generator.writeObject(value.automationInvoke) + value.automationSend != null -> generator.writeObject(value.automationSend) + value.automationV2Send != null -> + generator.writeObject(value.automationV2Send) + value.automationSendList != null -> + generator.writeObject(value.automationSendList) + value.automationUpdateProfile != null -> + generator.writeObject(value.automationUpdateProfile) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Step") + } + } + } + + class AutomationAddToDigestStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val subscriptionTopicId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("subscription_topic_id") + @ExcludeMissing + subscriptionTopicId: JsonField = JsonMissing.of(), + ) : this(if_, ref, action, subscriptionTopicId, mutableMapOf()) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The subscription topic that has digests enabled + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun subscriptionTopicId(): String = + subscriptionTopicId.getRequired("subscription_topic_id") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [subscriptionTopicId]. + * + * Unlike [subscriptionTopicId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_topic_id") + @ExcludeMissing + fun _subscriptionTopicId(): JsonField = subscriptionTopicId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationAddToDigestStep]. + * + * The following fields are required: + * ```java + * .action() + * .subscriptionTopicId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationAddToDigestStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var subscriptionTopicId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationAddToDigestStep: AutomationAddToDigestStep) = + apply { + if_ = automationAddToDigestStep.if_ + ref = automationAddToDigestStep.ref + action = automationAddToDigestStep.action + subscriptionTopicId = automationAddToDigestStep.subscriptionTopicId + additionalProperties = + automationAddToDigestStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** The subscription topic that has digests enabled */ + fun subscriptionTopicId(subscriptionTopicId: String) = + subscriptionTopicId(JsonField.of(subscriptionTopicId)) + + /** + * Sets [Builder.subscriptionTopicId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionTopicId] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun subscriptionTopicId(subscriptionTopicId: JsonField) = apply { + this.subscriptionTopicId = subscriptionTopicId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationAddToDigestStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .subscriptionTopicId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationAddToDigestStep = + AutomationAddToDigestStep( + if_, + ref, + checkRequired("action", action), + checkRequired("subscriptionTopicId", subscriptionTopicId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationAddToDigestStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + subscriptionTopicId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (subscriptionTopicId.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ADD_TO_DIGEST = of("add-to-digest") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + ADD_TO_DIGEST + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ADD_TO_DIGEST, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ADD_TO_DIGEST -> Value.ADD_TO_DIGEST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ADD_TO_DIGEST -> Known.ADD_TO_DIGEST + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationAddToDigestStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + subscriptionTopicId == other.subscriptionTopicId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(if_, ref, action, subscriptionTopicId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationAddToDigestStep{if_=$if_, ref=$ref, action=$action, subscriptionTopicId=$subscriptionTopicId, additionalProperties=$additionalProperties}" + } + + class AutomationAddToBatchStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val maxWaitPeriod: JsonField, + private val retain: JsonField, + private val waitPeriod: JsonField, + private val batchId: JsonField, + private val batchKey: JsonField, + private val categoryKey: JsonField, + private val maxItems: JsonField, + private val scope: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("max_wait_period") + @ExcludeMissing + maxWaitPeriod: JsonField = JsonMissing.of(), + @JsonProperty("retain") + @ExcludeMissing + retain: JsonField = JsonMissing.of(), + @JsonProperty("wait_period") + @ExcludeMissing + waitPeriod: JsonField = JsonMissing.of(), + @JsonProperty("batch_id") + @ExcludeMissing + batchId: JsonField = JsonMissing.of(), + @JsonProperty("batch_key") + @ExcludeMissing + batchKey: JsonField = JsonMissing.of(), + @JsonProperty("category_key") + @ExcludeMissing + categoryKey: JsonField = JsonMissing.of(), + @JsonProperty("max_items") + @ExcludeMissing + maxItems: JsonField = JsonMissing.of(), + @JsonProperty("scope") + @ExcludeMissing + scope: JsonField = JsonMissing.of(), + ) : this( + if_, + ref, + action, + maxWaitPeriod, + retain, + waitPeriod, + batchId, + batchKey, + categoryKey, + maxItems, + scope, + mutableMapOf(), + ) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * Defines the maximum wait time before the batch should be released. Must be less + * than wait period. Maximum of 60 days. Specified as an + * [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxWaitPeriod(): String = maxWaitPeriod.getRequired("max_wait_period") + + /** + * Defines what items should be retained and passed along to the next steps when the + * batch is released + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun retain(): Retain = retain.getRequired("retain") + + /** + * Defines the period of inactivity before the batch is released. Specified as an + * [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun waitPeriod(): String = waitPeriod.getRequired("wait_period") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun batchId(): Optional = batchId.getOptional("batch_id") + + /** + * If using scope=dynamic, provide the key or a reference (e.g., + * refs.data.batch_key) + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun batchKey(): Optional = batchKey.getOptional("batch_key") + + /** + * Defines the field of the data object the batch is set to when complete. Defaults + * to `batch` + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun categoryKey(): Optional = categoryKey.getOptional("category_key") + + /** + * If specified, the batch will release as soon as this number is reached + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun maxItems(): Optional = maxItems.getOptional("max_items") + + /** + * Determine the scope of the batching. If user, chosen in this order: recipient, + * profile.user_id, data.user_id, data.userId. If dynamic, then specify where the + * batch_key or a reference to the batch_key + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun scope(): Optional = scope.getOptional("scope") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [maxWaitPeriod]. + * + * Unlike [maxWaitPeriod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_wait_period") + @ExcludeMissing + fun _maxWaitPeriod(): JsonField = maxWaitPeriod + + /** + * Returns the raw JSON value of [retain]. + * + * Unlike [retain], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("retain") @ExcludeMissing fun _retain(): JsonField = retain + + /** + * Returns the raw JSON value of [waitPeriod]. + * + * Unlike [waitPeriod], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("wait_period") + @ExcludeMissing + fun _waitPeriod(): JsonField = waitPeriod + + /** + * Returns the raw JSON value of [batchId]. + * + * Unlike [batchId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("batch_id") + @ExcludeMissing + fun _batchId(): JsonField = batchId + + /** + * Returns the raw JSON value of [batchKey]. + * + * Unlike [batchKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("batch_key") + @ExcludeMissing + fun _batchKey(): JsonField = batchKey + + /** + * Returns the raw JSON value of [categoryKey]. + * + * Unlike [categoryKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("category_key") + @ExcludeMissing + fun _categoryKey(): JsonField = categoryKey + + /** + * Returns the raw JSON value of [maxItems]. + * + * Unlike [maxItems], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("max_items") + @ExcludeMissing + fun _maxItems(): JsonField = maxItems + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationAddToBatchStep]. + * + * The following fields are required: + * ```java + * .action() + * .maxWaitPeriod() + * .retain() + * .waitPeriod() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationAddToBatchStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var maxWaitPeriod: JsonField? = null + private var retain: JsonField? = null + private var waitPeriod: JsonField? = null + private var batchId: JsonField = JsonMissing.of() + private var batchKey: JsonField = JsonMissing.of() + private var categoryKey: JsonField = JsonMissing.of() + private var maxItems: JsonField = JsonMissing.of() + private var scope: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationAddToBatchStep: AutomationAddToBatchStep) = apply { + if_ = automationAddToBatchStep.if_ + ref = automationAddToBatchStep.ref + action = automationAddToBatchStep.action + maxWaitPeriod = automationAddToBatchStep.maxWaitPeriod + retain = automationAddToBatchStep.retain + waitPeriod = automationAddToBatchStep.waitPeriod + batchId = automationAddToBatchStep.batchId + batchKey = automationAddToBatchStep.batchKey + categoryKey = automationAddToBatchStep.categoryKey + maxItems = automationAddToBatchStep.maxItems + scope = automationAddToBatchStep.scope + additionalProperties = + automationAddToBatchStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** + * Defines the maximum wait time before the batch should be released. Must be + * less than wait period. Maximum of 60 days. Specified as an + * [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + */ + fun maxWaitPeriod(maxWaitPeriod: String) = + maxWaitPeriod(JsonField.of(maxWaitPeriod)) + + /** + * Sets [Builder.maxWaitPeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.maxWaitPeriod] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun maxWaitPeriod(maxWaitPeriod: JsonField) = apply { + this.maxWaitPeriod = maxWaitPeriod + } + + /** + * Defines what items should be retained and passed along to the next steps when + * the batch is released + */ + fun retain(retain: Retain) = retain(JsonField.of(retain)) + + /** + * Sets [Builder.retain] to an arbitrary JSON value. + * + * You should usually call [Builder.retain] with a well-typed [Retain] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun retain(retain: JsonField) = apply { this.retain = retain } + + /** + * Defines the period of inactivity before the batch is released. Specified as + * an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + */ + fun waitPeriod(waitPeriod: String) = waitPeriod(JsonField.of(waitPeriod)) + + /** + * Sets [Builder.waitPeriod] to an arbitrary JSON value. + * + * You should usually call [Builder.waitPeriod] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun waitPeriod(waitPeriod: JsonField) = apply { + this.waitPeriod = waitPeriod + } + + fun batchId(batchId: String?) = batchId(JsonField.ofNullable(batchId)) + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) + + /** + * Sets [Builder.batchId] to an arbitrary JSON value. + * + * You should usually call [Builder.batchId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun batchId(batchId: JsonField) = apply { this.batchId = batchId } + + /** + * If using scope=dynamic, provide the key or a reference (e.g., + * refs.data.batch_key) + */ + fun batchKey(batchKey: String?) = batchKey(JsonField.ofNullable(batchKey)) + + /** Alias for calling [Builder.batchKey] with `batchKey.orElse(null)`. */ + fun batchKey(batchKey: Optional) = batchKey(batchKey.getOrNull()) + + /** + * Sets [Builder.batchKey] to an arbitrary JSON value. + * + * You should usually call [Builder.batchKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun batchKey(batchKey: JsonField) = apply { this.batchKey = batchKey } + + /** + * Defines the field of the data object the batch is set to when complete. + * Defaults to `batch` + */ + fun categoryKey(categoryKey: String?) = + categoryKey(JsonField.ofNullable(categoryKey)) + + /** Alias for calling [Builder.categoryKey] with `categoryKey.orElse(null)`. */ + fun categoryKey(categoryKey: Optional) = + categoryKey(categoryKey.getOrNull()) + + /** + * Sets [Builder.categoryKey] to an arbitrary JSON value. + * + * You should usually call [Builder.categoryKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun categoryKey(categoryKey: JsonField) = apply { + this.categoryKey = categoryKey + } + + /** If specified, the batch will release as soon as this number is reached */ + fun maxItems(maxItems: MaxItems?) = maxItems(JsonField.ofNullable(maxItems)) + + /** Alias for calling [Builder.maxItems] with `maxItems.orElse(null)`. */ + fun maxItems(maxItems: Optional) = maxItems(maxItems.getOrNull()) + + /** + * Sets [Builder.maxItems] to an arbitrary JSON value. + * + * You should usually call [Builder.maxItems] with a well-typed [MaxItems] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maxItems(maxItems: JsonField) = apply { this.maxItems = maxItems } + + /** Alias for calling [maxItems] with `MaxItems.ofString(string)`. */ + fun maxItems(string: String) = maxItems(MaxItems.ofString(string)) + + /** Alias for calling [maxItems] with `MaxItems.ofInteger(integer)`. */ + fun maxItems(integer: Long) = maxItems(MaxItems.ofInteger(integer)) + + /** + * Determine the scope of the batching. If user, chosen in this order: + * recipient, profile.user_id, data.user_id, data.userId. If dynamic, then + * specify where the batch_key or a reference to the batch_key + */ + fun scope(scope: Scope?) = scope(JsonField.ofNullable(scope)) + + /** Alias for calling [Builder.scope] with `scope.orElse(null)`. */ + fun scope(scope: Optional) = scope(scope.getOrNull()) + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scope(scope: JsonField) = apply { this.scope = scope } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationAddToBatchStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .maxWaitPeriod() + * .retain() + * .waitPeriod() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationAddToBatchStep = + AutomationAddToBatchStep( + if_, + ref, + checkRequired("action", action), + checkRequired("maxWaitPeriod", maxWaitPeriod), + checkRequired("retain", retain), + checkRequired("waitPeriod", waitPeriod), + batchId, + batchKey, + categoryKey, + maxItems, + scope, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationAddToBatchStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + maxWaitPeriod() + retain().validate() + waitPeriod() + batchId() + batchKey() + categoryKey() + maxItems().ifPresent { it.validate() } + scope().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxWaitPeriod.asKnown().isPresent) 1 else 0) + + (retain.asKnown().getOrNull()?.validity() ?: 0) + + (if (waitPeriod.asKnown().isPresent) 1 else 0) + + (if (batchId.asKnown().isPresent) 1 else 0) + + (if (batchKey.asKnown().isPresent) 1 else 0) + + (if (categoryKey.asKnown().isPresent) 1 else 0) + + (maxItems.asKnown().getOrNull()?.validity() ?: 0) + + (scope.asKnown().getOrNull()?.validity() ?: 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ADD_TO_BATCH = of("add-to-batch") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + ADD_TO_BATCH + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ADD_TO_BATCH, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ADD_TO_BATCH -> Value.ADD_TO_BATCH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ADD_TO_BATCH -> Known.ADD_TO_BATCH + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Defines what items should be retained and passed along to the next steps when the + * batch is released + */ + class Retain + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val count: JsonField, + private val type: JsonField, + private val sortKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("count") + @ExcludeMissing + count: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("sort_key") + @ExcludeMissing + sortKey: JsonField = JsonMissing.of(), + ) : this(count, type, sortKey, mutableMapOf()) + + /** + * The number of records to keep in batch. Default is 10 and only configurable + * by requesting from support. When configurable minimum is 2 and maximum + * is 100. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun count(): Long = count.getRequired("count") + + /** + * Keep N number of notifications based on the type. First/Last N based on + * notification received. highest/lowest based on a scoring key providing in the + * data accessed by sort_key + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Defines the data value data[sort_key] that is used to sort the stored items. + * Required when type is set to highest or lowest. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun sortKey(): Optional = sortKey.getOptional("sort_key") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [sortKey]. + * + * Unlike [sortKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sort_key") + @ExcludeMissing + fun _sortKey(): JsonField = sortKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Retain]. + * + * The following fields are required: + * ```java + * .count() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Retain]. */ + class Builder internal constructor() { + + private var count: JsonField? = null + private var type: JsonField? = null + private var sortKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(retain: Retain) = apply { + count = retain.count + type = retain.type + sortKey = retain.sortKey + additionalProperties = retain.additionalProperties.toMutableMap() + } + + /** + * The number of records to keep in batch. Default is 10 and only + * configurable by requesting from support. When configurable minimum is 2 + * and maximum is 100. + */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + /** + * Keep N number of notifications based on the type. First/Last N based on + * notification received. highest/lowest based on a scoring key providing in + * the data accessed by sort_key + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** + * Defines the data value data[sort_key] that is used to sort the stored + * items. Required when type is set to highest or lowest. + */ + fun sortKey(sortKey: String?) = sortKey(JsonField.ofNullable(sortKey)) + + /** Alias for calling [Builder.sortKey] with `sortKey.orElse(null)`. */ + fun sortKey(sortKey: Optional) = sortKey(sortKey.getOrNull()) + + /** + * Sets [Builder.sortKey] to an arbitrary JSON value. + * + * You should usually call [Builder.sortKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun sortKey(sortKey: JsonField) = apply { this.sortKey = sortKey } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Retain]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .count() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Retain = + Retain( + checkRequired("count", count), + checkRequired("type", type), + sortKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Retain = apply { + if (validated) { + return@apply + } + + count() + type().validate() + sortKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (sortKey.asKnown().isPresent) 1 else 0) + + /** + * Keep N number of notifications based on the type. First/Last N based on + * notification received. highest/lowest based on a scoring key providing in the + * data accessed by sort_key + */ + class Type + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val FIRST = of("first") + + @JvmField val LAST = of("last") + + @JvmField val HIGHEST = of("highest") + + @JvmField val LOWEST = of("lowest") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FIRST, + LAST, + HIGHEST, + LOWEST, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FIRST, + LAST, + HIGHEST, + LOWEST, + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FIRST -> Value.FIRST + LAST -> Value.LAST + HIGHEST -> Value.HIGHEST + LOWEST -> Value.LOWEST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + FIRST -> Known.FIRST + LAST -> Known.LAST + HIGHEST -> Known.HIGHEST + LOWEST -> Known.LOWEST + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Retain && + count == other.count && + type == other.type && + sortKey == other.sortKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(count, type, sortKey, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Retain{count=$count, type=$type, sortKey=$sortKey, additionalProperties=$additionalProperties}" + } + + /** If specified, the batch will release as soon as this number is reached */ + @JsonDeserialize(using = MaxItems.Deserializer::class) + @JsonSerialize(using = MaxItems.Serializer::class) + class MaxItems + private constructor( + private val string: String? = null, + private val integer: Long? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun integer(): Optional = Optional.ofNullable(integer) + + fun isString(): Boolean = string != null + + fun isInteger(): Boolean = integer != null + + fun asString(): String = string.getOrThrow("string") + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + integer != null -> visitor.visitInteger(integer) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MaxItems = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitInteger(integer: Long) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MaxItems && + string == other.string && + integer == other.integer + } + + override fun hashCode(): Int = Objects.hash(string, integer) + + override fun toString(): String = + when { + string != null -> "MaxItems{string=$string}" + integer != null -> "MaxItems{integer=$integer}" + _json != null -> "MaxItems{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MaxItems") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MaxItems(string = string) + + @JvmStatic fun ofInteger(integer: Long) = MaxItems(integer = integer) + } + + /** + * An interface that defines how to map each variant of [MaxItems] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitInteger(integer: Long): T + + /** + * Maps an unknown variant of [MaxItems] to a value of type [T]. + * + * An instance of [MaxItems] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, + * if the SDK is on an older version than the API, then the API may respond + * with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown MaxItems: $json") + } + } + + internal class Deserializer : BaseDeserializer(MaxItems::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MaxItems { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MaxItems(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MaxItems(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing + // from object). + 0 -> MaxItems(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then + // use the first completely valid match, or simply the first match + // if none are completely valid. + else -> + bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MaxItems::class) { + + override fun serialize( + value: MaxItems, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.integer != null -> generator.writeObject(value.integer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MaxItems") + } + } + } + } + + /** + * Determine the scope of the batching. If user, chosen in this order: recipient, + * profile.user_id, data.user_id, data.userId. If dynamic, then specify where the + * batch_key or a reference to the batch_key + */ + class Scope @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USER = of("user") + + @JvmField val GLOBAL = of("global") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + /** An enum containing [Scope]'s known values. */ + enum class Known { + USER, + GLOBAL, + DYNAMIC, + } + + /** + * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Scope] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USER, + GLOBAL, + DYNAMIC, + /** + * An enum member indicating that [Scope] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER -> Value.USER + GLOBAL -> Value.GLOBAL + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USER -> Known.USER + GLOBAL -> Known.GLOBAL + DYNAMIC -> Known.DYNAMIC + else -> throw CourierInvalidDataException("Unknown Scope: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Scope = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationAddToBatchStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + maxWaitPeriod == other.maxWaitPeriod && + retain == other.retain && + waitPeriod == other.waitPeriod && + batchId == other.batchId && + batchKey == other.batchKey && + categoryKey == other.categoryKey && + maxItems == other.maxItems && + scope == other.scope && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + if_, + ref, + action, + maxWaitPeriod, + retain, + waitPeriod, + batchId, + batchKey, + categoryKey, + maxItems, + scope, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationAddToBatchStep{if_=$if_, ref=$ref, action=$action, maxWaitPeriod=$maxWaitPeriod, retain=$retain, waitPeriod=$waitPeriod, batchId=$batchId, batchKey=$batchKey, categoryKey=$categoryKey, maxItems=$maxItems, scope=$scope, additionalProperties=$additionalProperties}" + } + + class AutomationThrottleStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val maxAllowed: JsonField, + private val onThrottle: JsonField, + private val period: JsonField, + private val scope: JsonField, + private val shouldAlert: JsonField, + private val throttleKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("max_allowed") + @ExcludeMissing + maxAllowed: JsonField = JsonMissing.of(), + @JsonProperty("on_throttle") + @ExcludeMissing + onThrottle: JsonField = JsonMissing.of(), + @JsonProperty("period") + @ExcludeMissing + period: JsonField = JsonMissing.of(), + @JsonProperty("scope") + @ExcludeMissing + scope: JsonField = JsonMissing.of(), + @JsonProperty("should_alert") + @ExcludeMissing + shouldAlert: JsonField = JsonMissing.of(), + @JsonProperty("throttle_key") + @ExcludeMissing + throttleKey: JsonField = JsonMissing.of(), + ) : this( + if_, + ref, + action, + maxAllowed, + onThrottle, + period, + scope, + shouldAlert, + throttleKey, + mutableMapOf(), + ) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * Maximum number of allowed notifications in that timeframe + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun maxAllowed(): Long = maxAllowed.getRequired("max_allowed") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun onThrottle(): OnThrottle = onThrottle.getRequired("on_throttle") + + /** + * Defines the throttle period which corresponds to the max_allowed. Specified as an + * ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun period(): String = period.getRequired("period") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun scope(): Scope = scope.getRequired("scope") + + /** + * Value must be true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun shouldAlert(): Boolean = shouldAlert.getRequired("should_alert") + + /** + * If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) to + * the how the throttle should be identified + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun throttleKey(): Optional = throttleKey.getOptional("throttle_key") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [maxAllowed]. + * + * Unlike [maxAllowed], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("max_allowed") + @ExcludeMissing + fun _maxAllowed(): JsonField = maxAllowed + + /** + * Returns the raw JSON value of [onThrottle]. + * + * Unlike [onThrottle], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("on_throttle") + @ExcludeMissing + fun _onThrottle(): JsonField = onThrottle + + /** + * Returns the raw JSON value of [period]. + * + * Unlike [period], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("period") @ExcludeMissing fun _period(): JsonField = period + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + + /** + * Returns the raw JSON value of [shouldAlert]. + * + * Unlike [shouldAlert], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("should_alert") + @ExcludeMissing + fun _shouldAlert(): JsonField = shouldAlert + + /** + * Returns the raw JSON value of [throttleKey]. + * + * Unlike [throttleKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("throttle_key") + @ExcludeMissing + fun _throttleKey(): JsonField = throttleKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationThrottleStep]. + * + * The following fields are required: + * ```java + * .action() + * .maxAllowed() + * .onThrottle() + * .period() + * .scope() + * .shouldAlert() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationThrottleStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var maxAllowed: JsonField? = null + private var onThrottle: JsonField? = null + private var period: JsonField? = null + private var scope: JsonField? = null + private var shouldAlert: JsonField? = null + private var throttleKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationThrottleStep: AutomationThrottleStep) = apply { + if_ = automationThrottleStep.if_ + ref = automationThrottleStep.ref + action = automationThrottleStep.action + maxAllowed = automationThrottleStep.maxAllowed + onThrottle = automationThrottleStep.onThrottle + period = automationThrottleStep.period + scope = automationThrottleStep.scope + shouldAlert = automationThrottleStep.shouldAlert + throttleKey = automationThrottleStep.throttleKey + additionalProperties = + automationThrottleStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** Maximum number of allowed notifications in that timeframe */ + fun maxAllowed(maxAllowed: Long) = maxAllowed(JsonField.of(maxAllowed)) + + /** + * Sets [Builder.maxAllowed] to an arbitrary JSON value. + * + * You should usually call [Builder.maxAllowed] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun maxAllowed(maxAllowed: JsonField) = apply { + this.maxAllowed = maxAllowed + } + + fun onThrottle(onThrottle: OnThrottle) = onThrottle(JsonField.of(onThrottle)) + + /** + * Sets [Builder.onThrottle] to an arbitrary JSON value. + * + * You should usually call [Builder.onThrottle] with a well-typed [OnThrottle] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun onThrottle(onThrottle: JsonField) = apply { + this.onThrottle = onThrottle + } + + /** + * Defines the throttle period which corresponds to the max_allowed. Specified + * as an ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations + */ + fun period(period: String) = period(JsonField.of(period)) + + /** + * Sets [Builder.period] to an arbitrary JSON value. + * + * You should usually call [Builder.period] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun period(period: JsonField) = apply { this.period = period } + + fun scope(scope: Scope) = scope(JsonField.of(scope)) + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scope(scope: JsonField) = apply { this.scope = scope } + + /** Value must be true */ + fun shouldAlert(shouldAlert: Boolean) = shouldAlert(JsonField.of(shouldAlert)) + + /** + * Sets [Builder.shouldAlert] to an arbitrary JSON value. + * + * You should usually call [Builder.shouldAlert] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun shouldAlert(shouldAlert: JsonField) = apply { + this.shouldAlert = shouldAlert + } + + /** + * If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) + * to the how the throttle should be identified + */ + fun throttleKey(throttleKey: String?) = + throttleKey(JsonField.ofNullable(throttleKey)) + + /** Alias for calling [Builder.throttleKey] with `throttleKey.orElse(null)`. */ + fun throttleKey(throttleKey: Optional) = + throttleKey(throttleKey.getOrNull()) + + /** + * Sets [Builder.throttleKey] to an arbitrary JSON value. + * + * You should usually call [Builder.throttleKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun throttleKey(throttleKey: JsonField) = apply { + this.throttleKey = throttleKey + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationThrottleStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .maxAllowed() + * .onThrottle() + * .period() + * .scope() + * .shouldAlert() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationThrottleStep = + AutomationThrottleStep( + if_, + ref, + checkRequired("action", action), + checkRequired("maxAllowed", maxAllowed), + checkRequired("onThrottle", onThrottle), + checkRequired("period", period), + checkRequired("scope", scope), + checkRequired("shouldAlert", shouldAlert), + throttleKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationThrottleStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + maxAllowed() + onThrottle().validate() + period() + scope().validate() + shouldAlert() + throttleKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (maxAllowed.asKnown().isPresent) 1 else 0) + + (onThrottle.asKnown().getOrNull()?.validity() ?: 0) + + (if (period.asKnown().isPresent) 1 else 0) + + (scope.asKnown().getOrNull()?.validity() ?: 0) + + (if (shouldAlert.asKnown().isPresent) 1 else 0) + + (if (throttleKey.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val THROTTLE = of("throttle") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + THROTTLE + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THROTTLE, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THROTTLE -> Value.THROTTLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + THROTTLE -> Known.THROTTLE + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class OnThrottle + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val nodeId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("\$node_id") + @ExcludeMissing + nodeId: JsonField = JsonMissing.of() + ) : this(nodeId, mutableMapOf()) + + /** + * The node to go to if the request is throttled + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun nodeId(): String = nodeId.getRequired("\$node_id") + + /** + * Returns the raw JSON value of [nodeId]. + * + * Unlike [nodeId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("\$node_id") + @ExcludeMissing + fun _nodeId(): JsonField = nodeId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [OnThrottle]. + * + * The following fields are required: + * ```java + * .nodeId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [OnThrottle]. */ + class Builder internal constructor() { + + private var nodeId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(onThrottle: OnThrottle) = apply { + nodeId = onThrottle.nodeId + additionalProperties = onThrottle.additionalProperties.toMutableMap() + } + + /** The node to go to if the request is throttled */ + fun nodeId(nodeId: String) = nodeId(JsonField.of(nodeId)) + + /** + * Sets [Builder.nodeId] to an arbitrary JSON value. + * + * You should usually call [Builder.nodeId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun nodeId(nodeId: JsonField) = apply { this.nodeId = nodeId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [OnThrottle]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .nodeId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): OnThrottle = + OnThrottle( + checkRequired("nodeId", nodeId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): OnThrottle = apply { + if (validated) { + return@apply + } + + nodeId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (nodeId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is OnThrottle && + nodeId == other.nodeId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(nodeId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "OnThrottle{nodeId=$nodeId, additionalProperties=$additionalProperties}" + } + + class Scope @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val USER = of("user") + + @JvmField val GLOBAL = of("global") + + @JvmField val DYNAMIC = of("dynamic") + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + /** An enum containing [Scope]'s known values. */ + enum class Known { + USER, + GLOBAL, + DYNAMIC, + } + + /** + * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Scope] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USER, + GLOBAL, + DYNAMIC, + /** + * An enum member indicating that [Scope] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER -> Value.USER + GLOBAL -> Value.GLOBAL + DYNAMIC -> Value.DYNAMIC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + USER -> Known.USER + GLOBAL -> Known.GLOBAL + DYNAMIC -> Known.DYNAMIC + else -> throw CourierInvalidDataException("Unknown Scope: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Scope = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Scope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationThrottleStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + maxAllowed == other.maxAllowed && + onThrottle == other.onThrottle && + period == other.period && + scope == other.scope && + shouldAlert == other.shouldAlert && + throttleKey == other.throttleKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + if_, + ref, + action, + maxAllowed, + onThrottle, + period, + scope, + shouldAlert, + throttleKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationThrottleStep{if_=$if_, ref=$ref, action=$action, maxAllowed=$maxAllowed, onThrottle=$onThrottle, period=$period, scope=$scope, shouldAlert=$shouldAlert, throttleKey=$throttleKey, additionalProperties=$additionalProperties}" + } + + class AutomationCancelStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val cancelationToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("cancelation_token") + @ExcludeMissing + cancelationToken: JsonField = JsonMissing.of(), + ) : this(if_, ref, action, cancelationToken, mutableMapOf()) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun cancelationToken(): Optional = + cancelationToken.getOptional("cancelation_token") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [cancelationToken]. + * + * Unlike [cancelationToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("cancelation_token") + @ExcludeMissing + fun _cancelationToken(): JsonField = cancelationToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationCancelStep]. + * + * The following fields are required: + * ```java + * .action() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationCancelStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var cancelationToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationCancelStep: AutomationCancelStep) = apply { + if_ = automationCancelStep.if_ + ref = automationCancelStep.ref + action = automationCancelStep.action + cancelationToken = automationCancelStep.cancelationToken + additionalProperties = + automationCancelStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + fun cancelationToken(cancelationToken: String?) = + cancelationToken(JsonField.ofNullable(cancelationToken)) + + /** + * Alias for calling [Builder.cancelationToken] with + * `cancelationToken.orElse(null)`. + */ + fun cancelationToken(cancelationToken: Optional) = + cancelationToken(cancelationToken.getOrNull()) + + /** + * Sets [Builder.cancelationToken] to an arbitrary JSON value. + * + * You should usually call [Builder.cancelationToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun cancelationToken(cancelationToken: JsonField) = apply { + this.cancelationToken = cancelationToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationCancelStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationCancelStep = + AutomationCancelStep( + if_, + ref, + checkRequired("action", action), + cancelationToken, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationCancelStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + cancelationToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (cancelationToken.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val CANCEL = of("cancel") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + CANCEL + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCEL, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCEL -> Value.CANCEL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CANCEL -> Known.CANCEL + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationCancelStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + cancelationToken == other.cancelationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(if_, ref, action, cancelationToken, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationCancelStep{if_=$if_, ref=$ref, action=$action, cancelationToken=$cancelationToken, additionalProperties=$additionalProperties}" + } + + class AutomationDelayStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val duration: JsonField, + private val until: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("until") + @ExcludeMissing + until: JsonField = JsonMissing.of(), + ) : this(if_, ref, action, duration, until, mutableMapOf()) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string + * for how long to delay for + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * The ISO 8601 timestamp for when the delay should end + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun until(): Optional = until.getOptional("until") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [until]. + * + * Unlike [until], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationDelayStep]. + * + * The following fields are required: + * ```java + * .action() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationDelayStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var duration: JsonField = JsonMissing.of() + private var until: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationDelayStep: AutomationDelayStep) = apply { + if_ = automationDelayStep.if_ + ref = automationDelayStep.ref + action = automationDelayStep.action + duration = automationDelayStep.duration + until = automationDelayStep.until + additionalProperties = + automationDelayStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** + * The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) + * string for how long to delay for + */ + fun duration(duration: String?) = duration(JsonField.ofNullable(duration)) + + /** Alias for calling [Builder.duration] with `duration.orElse(null)`. */ + fun duration(duration: Optional) = duration(duration.getOrNull()) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The ISO 8601 timestamp for when the delay should end */ + fun until(until: String?) = until(JsonField.ofNullable(until)) + + /** Alias for calling [Builder.until] with `until.orElse(null)`. */ + fun until(until: Optional) = until(until.getOrNull()) + + /** + * Sets [Builder.until] to an arbitrary JSON value. + * + * You should usually call [Builder.until] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun until(until: JsonField) = apply { this.until = until } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationDelayStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationDelayStep = + AutomationDelayStep( + if_, + ref, + checkRequired("action", action), + duration, + until, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationDelayStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + duration() + until() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (duration.asKnown().isPresent) 1 else 0) + + (if (until.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val DELAY = of("delay") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + DELAY + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DELAY, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DELAY -> Value.DELAY + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DELAY -> Known.DELAY + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationDelayStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + duration == other.duration && + until == other.until && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(if_, ref, action, duration, until, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationDelayStep{if_=$if_, ref=$ref, action=$action, duration=$duration, until=$until, additionalProperties=$additionalProperties}" + } + + class AutomationFetchDataStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val mergeStrategy: JsonField, + private val webhook: JsonField, + private val idempotencyExpiry: JsonField, + private val idempotencyKey: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("merge_strategy") + @ExcludeMissing + mergeStrategy: JsonField = JsonMissing.of(), + @JsonProperty("webhook") + @ExcludeMissing + webhook: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_expiry") + @ExcludeMissing + idempotencyExpiry: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_key") + @ExcludeMissing + idempotencyKey: JsonField = JsonMissing.of(), + ) : this( + if_, + ref, + action, + mergeStrategy, + webhook, + idempotencyExpiry, + idempotencyKey, + mutableMapOf(), + ) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun mergeStrategy(): MergeAlgorithm = mergeStrategy.getRequired("merge_strategy") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun webhook(): Webhook = webhook.getRequired("webhook") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun idempotencyExpiry(): Optional = + idempotencyExpiry.getOptional("idempotency_expiry") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun idempotencyKey(): Optional = + idempotencyKey.getOptional("idempotency_key") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [mergeStrategy]. + * + * Unlike [mergeStrategy], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merge_strategy") + @ExcludeMissing + fun _mergeStrategy(): JsonField = mergeStrategy + + /** + * Returns the raw JSON value of [webhook]. + * + * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook") + @ExcludeMissing + fun _webhook(): JsonField = webhook + + /** + * Returns the raw JSON value of [idempotencyExpiry]. + * + * Unlike [idempotencyExpiry], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("idempotency_expiry") + @ExcludeMissing + fun _idempotencyExpiry(): JsonField = idempotencyExpiry + + /** + * Returns the raw JSON value of [idempotencyKey]. + * + * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("idempotency_key") + @ExcludeMissing + fun _idempotencyKey(): JsonField = idempotencyKey + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationFetchDataStep]. + * + * The following fields are required: + * ```java + * .action() + * .mergeStrategy() + * .webhook() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationFetchDataStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var mergeStrategy: JsonField? = null + private var webhook: JsonField? = null + private var idempotencyExpiry: JsonField = JsonMissing.of() + private var idempotencyKey: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationFetchDataStep: AutomationFetchDataStep) = apply { + if_ = automationFetchDataStep.if_ + ref = automationFetchDataStep.ref + action = automationFetchDataStep.action + mergeStrategy = automationFetchDataStep.mergeStrategy + webhook = automationFetchDataStep.webhook + idempotencyExpiry = automationFetchDataStep.idempotencyExpiry + idempotencyKey = automationFetchDataStep.idempotencyKey + additionalProperties = + automationFetchDataStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + fun mergeStrategy(mergeStrategy: MergeAlgorithm) = + mergeStrategy(JsonField.of(mergeStrategy)) + + /** + * Sets [Builder.mergeStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.mergeStrategy] with a well-typed + * [MergeAlgorithm] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun mergeStrategy(mergeStrategy: JsonField) = apply { + this.mergeStrategy = mergeStrategy + } + + fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) + + /** + * Sets [Builder.webhook] to an arbitrary JSON value. + * + * You should usually call [Builder.webhook] with a well-typed [Webhook] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhook(webhook: JsonField) = apply { this.webhook = webhook } + + fun idempotencyExpiry(idempotencyExpiry: String?) = + idempotencyExpiry(JsonField.ofNullable(idempotencyExpiry)) + + /** + * Alias for calling [Builder.idempotencyExpiry] with + * `idempotencyExpiry.orElse(null)`. + */ + fun idempotencyExpiry(idempotencyExpiry: Optional) = + idempotencyExpiry(idempotencyExpiry.getOrNull()) + + /** + * Sets [Builder.idempotencyExpiry] to an arbitrary JSON value. + * + * You should usually call [Builder.idempotencyExpiry] with a well-typed + * [String] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun idempotencyExpiry(idempotencyExpiry: JsonField) = apply { + this.idempotencyExpiry = idempotencyExpiry + } + + fun idempotencyKey(idempotencyKey: String?) = + idempotencyKey(JsonField.ofNullable(idempotencyKey)) + + /** + * Alias for calling [Builder.idempotencyKey] with + * `idempotencyKey.orElse(null)`. + */ + fun idempotencyKey(idempotencyKey: Optional) = + idempotencyKey(idempotencyKey.getOrNull()) + + /** + * Sets [Builder.idempotencyKey] to an arbitrary JSON value. + * + * You should usually call [Builder.idempotencyKey] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun idempotencyKey(idempotencyKey: JsonField) = apply { + this.idempotencyKey = idempotencyKey + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationFetchDataStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .mergeStrategy() + * .webhook() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationFetchDataStep = + AutomationFetchDataStep( + if_, + ref, + checkRequired("action", action), + checkRequired("mergeStrategy", mergeStrategy), + checkRequired("webhook", webhook), + idempotencyExpiry, + idempotencyKey, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationFetchDataStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + mergeStrategy().validate() + webhook().validate() + idempotencyExpiry() + idempotencyKey() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (mergeStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (webhook.asKnown().getOrNull()?.validity() ?: 0) + + (if (idempotencyExpiry.asKnown().isPresent) 1 else 0) + + (if (idempotencyKey.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val FETCH_DATA = of("fetch-data") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + FETCH_DATA + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FETCH_DATA, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FETCH_DATA -> Value.FETCH_DATA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + FETCH_DATA -> Known.FETCH_DATA + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Webhook + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val method: JsonField, + private val url: JsonField, + private val body: JsonField, + private val headers: JsonField, + private val params: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("url") + @ExcludeMissing + url: JsonField = JsonMissing.of(), + @JsonProperty("body") + @ExcludeMissing + body: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("params") + @ExcludeMissing + params: JsonField = JsonMissing.of(), + ) : this(method, url, body, headers, params, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun method(): Method = method.getRequired("method") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun body(): Optional = body.getOptional("body") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun params(): Optional = params.getOptional("params") + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("method") + @ExcludeMissing + fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [body]. + * + * Unlike [body], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("headers") + @ExcludeMissing + fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [params]. + * + * Unlike [params], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("params") + @ExcludeMissing + fun _params(): JsonField = params + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Webhook]. + * + * The following fields are required: + * ```java + * .method() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Webhook]. */ + class Builder internal constructor() { + + private var method: JsonField? = null + private var url: JsonField? = null + private var body: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var params: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(webhook: Webhook) = apply { + method = webhook.method + url = webhook.url + body = webhook.body + headers = webhook.headers + params = webhook.params + additionalProperties = webhook.additionalProperties.toMutableMap() + } + + fun method(method: Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun body(body: Body?) = body(JsonField.ofNullable(body)) + + /** Alias for calling [Builder.body] with `body.orElse(null)`. */ + fun body(body: Optional) = body(body.getOrNull()) + + /** + * Sets [Builder.body] to an arbitrary JSON value. + * + * You should usually call [Builder.body] with a well-typed [Body] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun body(body: JsonField) = apply { this.body = body } + + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + fun params(params: Params?) = params(JsonField.ofNullable(params)) + + /** Alias for calling [Builder.params] with `params.orElse(null)`. */ + fun params(params: Optional) = params(params.getOrNull()) + + /** + * Sets [Builder.params] to an arbitrary JSON value. + * + * You should usually call [Builder.params] with a well-typed [Params] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun params(params: JsonField) = apply { this.params = params } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Webhook]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .method() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Webhook = + Webhook( + checkRequired("method", method), + checkRequired("url", url), + body, + headers, + params, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Webhook = apply { + if (validated) { + return@apply + } + + method().validate() + url() + body().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + params().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (method.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (body.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (params.asKnown().getOrNull()?.validity() ?: 0) + + class Method + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val GET = of("GET") + + @JvmField val POST = of("POST") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + GET, + POST, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Method] can contain an unknown value in a couple of + * cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GET, + POST, + /** + * An enum member indicating that [Method] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GET -> Value.GET + POST -> Value.POST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + GET -> Known.GET + POST -> Known.POST + else -> throw CourierInvalidDataException("Unknown Method: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Method && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Body + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Body = Body(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{additionalProperties=$additionalProperties}" + } + + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Headers]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Headers{additionalProperties=$additionalProperties}" + } + + class Params + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Params]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Params]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(params: Params) = apply { + additionalProperties = params.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Params]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Params = Params(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Params = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Params && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Params{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Webhook && + method == other.method && + url == other.url && + body == other.body && + headers == other.headers && + params == other.params && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(method, url, body, headers, params, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Webhook{method=$method, url=$url, body=$body, headers=$headers, params=$params, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationFetchDataStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + mergeStrategy == other.mergeStrategy && + webhook == other.webhook && + idempotencyExpiry == other.idempotencyExpiry && + idempotencyKey == other.idempotencyKey && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + if_, + ref, + action, + mergeStrategy, + webhook, + idempotencyExpiry, + idempotencyKey, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationFetchDataStep{if_=$if_, ref=$ref, action=$action, mergeStrategy=$mergeStrategy, webhook=$webhook, idempotencyExpiry=$idempotencyExpiry, idempotencyKey=$idempotencyKey, additionalProperties=$additionalProperties}" + } + + class AutomationInvokeStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val template: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("template") + @ExcludeMissing + template: JsonField = JsonMissing.of(), + ) : this(if_, ref, action, template, mutableMapOf()) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun template(): String = template.getRequired("template") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template") + @ExcludeMissing + fun _template(): JsonField = template + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationInvokeStep]. + * + * The following fields are required: + * ```java + * .action() + * .template() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationInvokeStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var template: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationInvokeStep: AutomationInvokeStep) = apply { + if_ = automationInvokeStep.if_ + ref = automationInvokeStep.ref + action = automationInvokeStep.action + template = automationInvokeStep.template + additionalProperties = + automationInvokeStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + fun template(template: String) = template(JsonField.of(template)) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationInvokeStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .template() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationInvokeStep = + AutomationInvokeStep( + if_, + ref, + checkRequired("action", action), + checkRequired("template", template), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationInvokeStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + template() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (template.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val INVOKE = of("invoke") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + INVOKE + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + INVOKE, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + INVOKE -> Value.INVOKE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + INVOKE -> Known.INVOKE + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationInvokeStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + template == other.template && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(if_, ref, action, template, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationInvokeStep{if_=$if_, ref=$ref, action=$action, template=$template, additionalProperties=$additionalProperties}" + } + + class AutomationSendStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val brand: JsonField, + private val data: JsonField, + private val override: JsonField, + private val profile: JsonValue, + private val recipient: JsonField, + private val template: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("brand") + @ExcludeMissing + brand: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("override") + @ExcludeMissing + override: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), + @JsonProperty("recipient") + @ExcludeMissing + recipient: JsonField = JsonMissing.of(), + @JsonProperty("template") + @ExcludeMissing + template: JsonField = JsonMissing.of(), + ) : this( + if_, + ref, + action, + brand, + data, + override, + profile, + recipient, + template, + mutableMapOf(), + ) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun brand(): Optional = brand.getOptional("brand") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun override(): Optional = override.getOptional("override") + + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun recipient(): Optional = recipient.getOptional("recipient") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun template(): Optional = template.getOptional("template") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [override]. + * + * Unlike [override], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("override") + @ExcludeMissing + fun _override(): JsonField = override + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("recipient") + @ExcludeMissing + fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template") + @ExcludeMissing + fun _template(): JsonField = template + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationSendStep]. + * + * The following fields are required: + * ```java + * .action() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationSendStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var brand: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var override: JsonField = JsonMissing.of() + private var profile: JsonValue = JsonMissing.of() + private var recipient: JsonField = JsonMissing.of() + private var template: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationSendStep: AutomationSendStep) = apply { + if_ = automationSendStep.if_ + ref = automationSendStep.ref + action = automationSendStep.action + brand = automationSendStep.brand + data = automationSendStep.data + override = automationSendStep.override + profile = automationSendStep.profile + recipient = automationSendStep.recipient + template = automationSendStep.template + additionalProperties = + automationSendStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun brand(brand: JsonField) = apply { this.brand = brand } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun override(override: Override?) = override(JsonField.ofNullable(override)) + + /** Alias for calling [Builder.override] with `override.orElse(null)`. */ + fun override(override: Optional) = override(override.getOrNull()) + + /** + * Sets [Builder.override] to an arbitrary JSON value. + * + * You should usually call [Builder.override] with a well-typed [Override] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun override(override: JsonField) = apply { this.override = override } + + fun profile(profile: JsonValue) = apply { this.profile = profile } + + fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun recipient(recipient: JsonField) = apply { + this.recipient = recipient + } + + fun template(template: String?) = template(JsonField.ofNullable(template)) + + /** Alias for calling [Builder.template] with `template.orElse(null)`. */ + fun template(template: Optional) = template(template.getOrNull()) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationSendStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationSendStep = + AutomationSendStep( + if_, + ref, + checkRequired("action", action), + brand, + data, + override, + profile, + recipient, + template, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationSendStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + brand() + data().ifPresent { it.validate() } + override().ifPresent { it.validate() } + recipient() + template() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (brand.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (override.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (if (template.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val SEND = of("send") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + SEND + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SEND, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SEND -> Value.SEND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SEND -> Known.SEND + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Override + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Override]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Override]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(override: Override) = apply { + additionalProperties = override.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Override]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Override = Override(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Override = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Override && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Override{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationSendStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + brand == other.brand && + data == other.data && + override == other.override && + profile == other.profile && + recipient == other.recipient && + template == other.template && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + if_, + ref, + action, + brand, + data, + override, + profile, + recipient, + template, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationSendStep{if_=$if_, ref=$ref, action=$action, brand=$brand, data=$data, override=$override, profile=$profile, recipient=$recipient, template=$template, additionalProperties=$additionalProperties}" + } + + class AutomationV2SendStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val message: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + ) : this(if_, ref, action, message, mutableMapOf()) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * Describes the content of the message in a way that will work for email, push, + * chat, or any channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("message") + @ExcludeMissing + fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationV2SendStep]. + * + * The following fields are required: + * ```java + * .action() + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationV2SendStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var message: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationV2SendStep: AutomationV2SendStep) = apply { + if_ = automationV2SendStep.if_ + ref = automationV2SendStep.ref + action = automationV2SendStep.action + message = automationV2SendStep.message + additionalProperties = + automationV2SendStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + /** + * Describes the content of the message in a way that will work for email, push, + * chat, or any channel. + */ + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** Alias for calling [message] with `Message.ofContent(content)`. */ + fun message(content: Message.ContentMessage) = + message(Message.ofContent(content)) + + /** Alias for calling [message] with `Message.ofTemplate(template)`. */ + fun message(template: Message.TemplateMessage) = + message(Message.ofTemplate(template)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationV2SendStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationV2SendStep = + AutomationV2SendStep( + if_, + ref, + checkRequired("action", action), + checkRequired("message", message), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationV2SendStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + message().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (message.asKnown().getOrNull()?.validity() ?: 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val SEND = of("send") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + SEND + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SEND, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SEND -> Value.SEND + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SEND -> Known.SEND + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationV2SendStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(if_, ref, action, message, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationV2SendStep{if_=$if_, ref=$ref, action=$action, message=$message, additionalProperties=$additionalProperties}" + } + + class AutomationSendListStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val action: JsonField, + private val list: JsonField, + private val brand: JsonField, + private val data: JsonField, + private val override: JsonField, + private val template: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("list") + @ExcludeMissing + list: JsonField = JsonMissing.of(), + @JsonProperty("brand") + @ExcludeMissing + brand: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("override") + @ExcludeMissing + override: JsonField = JsonMissing.of(), + @JsonProperty("template") + @ExcludeMissing + template: JsonField = JsonMissing.of(), + ) : this(if_, ref, action, list, brand, data, override, template, mutableMapOf()) + + fun toAutomationStep(): AutomationStep = + AutomationStep.builder().if_(if_).ref(ref).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun list(): String = list.getRequired("list") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun brand(): Optional = brand.getOptional("brand") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun override(): Optional = override.getOptional("override") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun template(): Optional = template.getOptional("template") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [list]. + * + * Unlike [list], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("list") @ExcludeMissing fun _list(): JsonField = list + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [override]. + * + * Unlike [override], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("override") + @ExcludeMissing + fun _override(): JsonField = override + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template") + @ExcludeMissing + fun _template(): JsonField = template + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationSendListStep]. + * + * The following fields are required: + * ```java + * .action() + * .list() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationSendListStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var action: JsonField? = null + private var list: JsonField? = null + private var brand: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var override: JsonField = JsonMissing.of() + private var template: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationSendListStep: AutomationSendListStep) = apply { + if_ = automationSendListStep.if_ + ref = automationSendListStep.ref + action = automationSendListStep.action + list = automationSendListStep.list + brand = automationSendListStep.brand + data = automationSendListStep.data + override = automationSendListStep.override + template = automationSendListStep.template + additionalProperties = + automationSendListStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + fun list(list: String) = list(JsonField.of(list)) + + /** + * Sets [Builder.list] to an arbitrary JSON value. + * + * You should usually call [Builder.list] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun list(list: JsonField) = apply { this.list = list } + + fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun brand(brand: JsonField) = apply { this.brand = brand } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun override(override: Override?) = override(JsonField.ofNullable(override)) + + /** Alias for calling [Builder.override] with `override.orElse(null)`. */ + fun override(override: Optional) = override(override.getOrNull()) + + /** + * Sets [Builder.override] to an arbitrary JSON value. + * + * You should usually call [Builder.override] with a well-typed [Override] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun override(override: JsonField) = apply { this.override = override } + + fun template(template: String?) = template(JsonField.ofNullable(template)) + + /** Alias for calling [Builder.template] with `template.orElse(null)`. */ + fun template(template: Optional) = template(template.getOrNull()) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationSendListStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .list() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationSendListStep = + AutomationSendListStep( + if_, + ref, + checkRequired("action", action), + checkRequired("list", list), + brand, + data, + override, + template, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationSendListStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + action().validate() + list() + brand() + data().ifPresent { it.validate() } + override().ifPresent { it.validate() } + template() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (action.asKnown().getOrNull()?.validity() ?: 0) + + (if (list.asKnown().isPresent) 1 else 0) + + (if (brand.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (override.asKnown().getOrNull()?.validity() ?: 0) + + (if (template.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val SEND_LIST = of("send-list") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + SEND_LIST + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SEND_LIST, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SEND_LIST -> Value.SEND_LIST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SEND_LIST -> Known.SEND_LIST + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Override + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Override]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Override]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(override: Override) = apply { + additionalProperties = override.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Override]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Override = Override(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Override = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Override && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Override{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationSendListStep && + if_ == other.if_ && + ref == other.ref && + action == other.action && + list == other.list && + brand == other.brand && + data == other.data && + override == other.override && + template == other.template && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + if_, + ref, + action, + list, + brand, + data, + override, + template, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationSendListStep{if_=$if_, ref=$ref, action=$action, list=$list, brand=$brand, data=$data, override=$override, template=$template, additionalProperties=$additionalProperties}" + } + + class AutomationUpdateProfileStep + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val action: JsonField, + private val merge: JsonField, + private val profile: JsonValue, + private val recipientId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("action") + @ExcludeMissing + action: JsonField = JsonMissing.of(), + @JsonProperty("merge") + @ExcludeMissing + merge: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), + @JsonProperty("recipient_id") + @ExcludeMissing + recipientId: JsonField = JsonMissing.of(), + ) : this(action, merge, profile, recipientId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun action(): Action = action.getRequired("action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun merge(): MergeAlgorithm = merge.getRequired("merge") + + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun recipientId(): String = recipientId.getRequired("recipient_id") + + /** + * Returns the raw JSON value of [action]. + * + * Unlike [action], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action + + /** + * Returns the raw JSON value of [merge]. + * + * Unlike [merge], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merge") + @ExcludeMissing + fun _merge(): JsonField = merge + + /** + * Returns the raw JSON value of [recipientId]. + * + * Unlike [recipientId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("recipient_id") + @ExcludeMissing + fun _recipientId(): JsonField = recipientId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationUpdateProfileStep]. + * + * The following fields are required: + * ```java + * .action() + * .merge() + * .profile() + * .recipientId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationUpdateProfileStep]. */ + class Builder internal constructor() { + + private var action: JsonField? = null + private var merge: JsonField? = null + private var profile: JsonValue? = null + private var recipientId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationUpdateProfileStep: AutomationUpdateProfileStep) = + apply { + action = automationUpdateProfileStep.action + merge = automationUpdateProfileStep.merge + profile = automationUpdateProfileStep.profile + recipientId = automationUpdateProfileStep.recipientId + additionalProperties = + automationUpdateProfileStep.additionalProperties.toMutableMap() + } + + fun action(action: Action) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [Action] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun action(action: JsonField) = apply { this.action = action } + + fun merge(merge: MergeAlgorithm) = merge(JsonField.of(merge)) + + /** + * Sets [Builder.merge] to an arbitrary JSON value. + * + * You should usually call [Builder.merge] with a well-typed [MergeAlgorithm] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun merge(merge: JsonField) = apply { this.merge = merge } + + fun profile(profile: JsonValue) = apply { this.profile = profile } + + fun recipientId(recipientId: String) = recipientId(JsonField.of(recipientId)) + + /** + * Sets [Builder.recipientId] to an arbitrary JSON value. + * + * You should usually call [Builder.recipientId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun recipientId(recipientId: JsonField) = apply { + this.recipientId = recipientId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationUpdateProfileStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .action() + * .merge() + * .profile() + * .recipientId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationUpdateProfileStep = + AutomationUpdateProfileStep( + checkRequired("action", action), + checkRequired("merge", merge), + checkRequired("profile", profile), + checkRequired("recipientId", recipientId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationUpdateProfileStep = apply { + if (validated) { + return@apply + } + + action().validate() + merge().validate() + recipientId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (action.asKnown().getOrNull()?.validity() ?: 0) + + (merge.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipientId.asKnown().isPresent) 1 else 0) + + class Action + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val UPDATE_PROFILE = of("update-profile") + + @JvmStatic fun of(value: String) = Action(JsonField.of(value)) + } + + /** An enum containing [Action]'s known values. */ + enum class Known { + UPDATE_PROFILE + } + + /** + * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Action] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + UPDATE_PROFILE, + /** + * An enum member indicating that [Action] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + UPDATE_PROFILE -> Value.UPDATE_PROFILE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + UPDATE_PROFILE -> Known.UPDATE_PROFILE + else -> throw CourierInvalidDataException("Unknown Action: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Action = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationUpdateProfileStep && + action == other.action && + merge == other.merge && + profile == other.profile && + recipientId == other.recipientId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(action, merge, profile, recipientId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationUpdateProfileStep{action=$action, merge=$merge, profile=$profile, recipientId=$recipientId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Automation && + steps == other.steps && + cancelationToken == other.cancelationToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(steps, cancelationToken, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Automation{steps=$steps, cancelationToken=$cancelationToken, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationInvokeAdHocParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AutomationInvokeAdHocParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt new file mode 100644 index 00000000..77213618 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.models.automations.invoke.AutomationInvokeParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Invoke an automation run from an automation template. */ +class AutomationInvokeByTemplateParams +private constructor( + private val templateId: String?, + private val automationInvokeParams: AutomationInvokeParams, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun templateId(): Optional = Optional.ofNullable(templateId) + + fun automationInvokeParams(): AutomationInvokeParams = automationInvokeParams + + fun _additionalBodyProperties(): Map = + automationInvokeParams._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AutomationInvokeByTemplateParams]. + * + * The following fields are required: + * ```java + * .automationInvokeParams() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationInvokeByTemplateParams]. */ + class Builder internal constructor() { + + private var templateId: String? = null + private var automationInvokeParams: AutomationInvokeParams? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(automationInvokeByTemplateParams: AutomationInvokeByTemplateParams) = + apply { + templateId = automationInvokeByTemplateParams.templateId + automationInvokeParams = automationInvokeByTemplateParams.automationInvokeParams + additionalHeaders = automationInvokeByTemplateParams.additionalHeaders.toBuilder() + additionalQueryParams = + automationInvokeByTemplateParams.additionalQueryParams.toBuilder() + } + + fun templateId(templateId: String?) = apply { this.templateId = templateId } + + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) + + fun automationInvokeParams(automationInvokeParams: AutomationInvokeParams) = apply { + this.automationInvokeParams = automationInvokeParams + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AutomationInvokeByTemplateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .automationInvokeParams() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationInvokeByTemplateParams = + AutomationInvokeByTemplateParams( + templateId, + checkRequired("automationInvokeParams", automationInvokeParams), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): AutomationInvokeParams = automationInvokeParams + + fun _pathParam(index: Int): String = + when (index) { + 0 -> templateId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationInvokeByTemplateParams && + templateId == other.templateId && + automationInvokeParams == other.automationInvokeParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(templateId, automationInvokeParams, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AutomationInvokeByTemplateParams{templateId=$templateId, automationInvokeParams=$automationInvokeParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt new file mode 100644 index 00000000..99d31750 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt @@ -0,0 +1,377 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AutomationInvokeParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val brand: JsonField, + private val data: JsonField, + private val profile: JsonValue, + private val recipient: JsonField, + private val template: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), + @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), + @JsonProperty("template") @ExcludeMissing template: JsonField = JsonMissing.of(), + ) : this(brand, data, profile, recipient, template, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brand(): Optional = brand.getOptional("brand") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recipient(): Optional = recipient.getOptional("recipient") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun template(): Optional = template.getOptional("template") + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AutomationInvokeParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationInvokeParams]. */ + class Builder internal constructor() { + + private var brand: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var profile: JsonValue = JsonMissing.of() + private var recipient: JsonField = JsonMissing.of() + private var template: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationInvokeParams: AutomationInvokeParams) = apply { + brand = automationInvokeParams.brand + data = automationInvokeParams.data + profile = automationInvokeParams.profile + recipient = automationInvokeParams.recipient + template = automationInvokeParams.template + additionalProperties = automationInvokeParams.additionalProperties.toMutableMap() + } + + fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brand(brand: JsonField) = apply { this.brand = brand } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun profile(profile: JsonValue) = apply { this.profile = profile } + + fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + fun template(template: String?) = template(JsonField.ofNullable(template)) + + /** Alias for calling [Builder.template] with `template.orElse(null)`. */ + fun template(template: Optional) = template(template.getOrNull()) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationInvokeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AutomationInvokeParams = + AutomationInvokeParams( + brand, + data, + profile, + recipient, + template, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationInvokeParams = apply { + if (validated) { + return@apply + } + + brand() + data().ifPresent { it.validate() } + recipient() + template() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brand.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (if (template.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationInvokeParams && + brand == other.brand && + data == other.data && + profile == other.profile && + recipient == other.recipient && + template == other.template && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(brand, data, profile, recipient, template, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationInvokeParams{brand=$brand, data=$data, profile=$profile, recipient=$recipient, template=$template, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt new file mode 100644 index 00000000..716707c1 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class AutomationInvokeResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val runId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("runId") @ExcludeMissing runId: JsonField = JsonMissing.of() + ) : this(runId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun runId(): String = runId.getRequired("runId") + + /** + * Returns the raw JSON value of [runId]. + * + * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("runId") @ExcludeMissing fun _runId(): JsonField = runId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AutomationInvokeResponse]. + * + * The following fields are required: + * ```java + * .runId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationInvokeResponse]. */ + class Builder internal constructor() { + + private var runId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationInvokeResponse: AutomationInvokeResponse) = apply { + runId = automationInvokeResponse.runId + additionalProperties = automationInvokeResponse.additionalProperties.toMutableMap() + } + + fun runId(runId: String) = runId(JsonField.of(runId)) + + /** + * Sets [Builder.runId] to an arbitrary JSON value. + * + * You should usually call [Builder.runId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun runId(runId: JsonField) = apply { this.runId = runId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationInvokeResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .runId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AutomationInvokeResponse = + AutomationInvokeResponse( + checkRequired("runId", runId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AutomationInvokeResponse = apply { + if (validated) { + return@apply + } + + runId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (runId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationInvokeResponse && + runId == other.runId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(runId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationInvokeResponse{runId=$runId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt new file mode 100644 index 00000000..40a0fce5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class AutomationStep +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val if_: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(if_, ref, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AutomationStep]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AutomationStep]. */ + class Builder internal constructor() { + + private var if_: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(automationStep: AutomationStep) = apply { + if_ = automationStep.if_ + ref = automationStep.ref + additionalProperties = automationStep.additionalProperties.toMutableMap() + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AutomationStep]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AutomationStep = AutomationStep(if_, ref, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): AutomationStep = apply { + if (validated) { + return@apply + } + + if_() + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (if_.asKnown().isPresent) 1 else 0) + (if (ref.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AutomationStep && + if_ == other.if_ && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(if_, ref, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AutomationStep{if_=$if_, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt new file mode 100644 index 00000000..b6dce81e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.Enum +import com.courier.api.core.JsonField +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +class MergeAlgorithm @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val REPLACE = of("replace") + + @JvmField val NONE = of("none") + + @JvmField val OVERWRITE = of("overwrite") + + @JvmField val SOFT_MERGE = of("soft-merge") + + @JvmStatic fun of(value: String) = MergeAlgorithm(JsonField.of(value)) + } + + /** An enum containing [MergeAlgorithm]'s known values. */ + enum class Known { + REPLACE, + NONE, + OVERWRITE, + SOFT_MERGE, + } + + /** + * An enum containing [MergeAlgorithm]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [MergeAlgorithm] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + REPLACE, + NONE, + OVERWRITE, + SOFT_MERGE, + /** + * An enum member indicating that [MergeAlgorithm] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + REPLACE -> Value.REPLACE + NONE -> Value.NONE + OVERWRITE -> Value.OVERWRITE + SOFT_MERGE -> Value.SOFT_MERGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + REPLACE -> Known.REPLACE + NONE -> Known.NONE + OVERWRITE -> Known.OVERWRITE + SOFT_MERGE -> Known.SOFT_MERGE + else -> throw CourierInvalidDataException("Unknown MergeAlgorithm: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): MergeAlgorithm = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MergeAlgorithm && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt new file mode 100644 index 00000000..5bfec748 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt @@ -0,0 +1,452 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Brand +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val created: JsonField, + private val name: JsonField, + private val published: JsonField, + private val settings: JsonField, + private val updated: JsonField, + private val version: JsonField, + private val id: JsonField, + private val snippets: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("published") @ExcludeMissing published: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + settings: JsonField = JsonMissing.of(), + @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("snippets") + @ExcludeMissing + snippets: JsonField = JsonMissing.of(), + ) : this(created, name, published, settings, updated, version, id, snippets, mutableMapOf()) + + /** + * The date/time of when the brand was created. Represented in milliseconds since Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): Long = created.getRequired("created") + + /** + * Brand name + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The date/time of when the brand was published. Represented in milliseconds since Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun published(): Long = published.getRequired("published") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settings(): BrandSettings = settings.getRequired("settings") + + /** + * The date/time of when the brand was updated. Represented in milliseconds since Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): Long = updated.getRequired("updated") + + /** + * The version identifier for the brand + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + /** + * Brand Identifier + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun snippets(): Optional = snippets.getOptional("snippets") + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [published]. + * + * Unlike [published], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("published") @ExcludeMissing fun _published(): JsonField = published + + /** + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [snippets]. + * + * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("snippets") @ExcludeMissing fun _snippets(): JsonField = snippets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Brand]. + * + * The following fields are required: + * ```java + * .created() + * .name() + * .published() + * .settings() + * .updated() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Brand]. */ + class Builder internal constructor() { + + private var created: JsonField? = null + private var name: JsonField? = null + private var published: JsonField? = null + private var settings: JsonField? = null + private var updated: JsonField? = null + private var version: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var snippets: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brand: Brand) = apply { + created = brand.created + name = brand.name + published = brand.published + settings = brand.settings + updated = brand.updated + version = brand.version + id = brand.id + snippets = brand.snippets + additionalProperties = brand.additionalProperties.toMutableMap() + } + + /** + * The date/time of when the brand was created. Represented in milliseconds since Unix + * epoch. + */ + fun created(created: Long) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** Brand name */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The date/time of when the brand was published. Represented in milliseconds since Unix + * epoch. + */ + fun published(published: Long) = published(JsonField.of(published)) + + /** + * Sets [Builder.published] to an arbitrary JSON value. + * + * You should usually call [Builder.published] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun published(published: JsonField) = apply { this.published = published } + + fun settings(settings: BrandSettings) = settings(JsonField.of(settings)) + + /** + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [BrandSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settings(settings: JsonField) = apply { this.settings = settings } + + /** + * The date/time of when the brand was updated. Represented in milliseconds since Unix + * epoch. + */ + fun updated(updated: Long) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + /** The version identifier for the brand */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + /** Brand Identifier */ + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun snippets(snippets: BrandSnippets?) = snippets(JsonField.ofNullable(snippets)) + + /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ + fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) + + /** + * Sets [Builder.snippets] to an arbitrary JSON value. + * + * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun snippets(snippets: JsonField) = apply { this.snippets = snippets } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Brand]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .created() + * .name() + * .published() + * .settings() + * .updated() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Brand = + Brand( + checkRequired("created", created), + checkRequired("name", name), + checkRequired("published", published), + checkRequired("settings", settings), + checkRequired("updated", updated), + checkRequired("version", version), + id, + snippets, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Brand = apply { + if (validated) { + return@apply + } + + created() + name() + published() + settings().validate() + updated() + version() + id() + snippets().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (created.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (published.asKnown().isPresent) 1 else 0) + + (settings.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (snippets.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Brand && + created == other.created && + name == other.name && + published == other.published && + settings == other.settings && + updated == other.updated && + version == other.version && + id == other.id && + snippets == other.snippets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + created, + name, + published, + settings, + updated, + version, + id, + snippets, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Brand{created=$created, name=$name, published=$published, settings=$settings, updated=$updated, version=$version, id=$id, snippets=$snippets, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt new file mode 100644 index 00000000..0590a1d8 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt @@ -0,0 +1,618 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create a new brand */ +class BrandCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The name of the brand. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settings(): BrandSettings = body.settings() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = body.id() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun snippets(): Optional = body.snippets() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _settings(): JsonField = body._settings() + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _id(): JsonField = body._id() + + /** + * Returns the raw JSON value of [snippets]. + * + * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _snippets(): JsonField = body._snippets() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandCreateParams]. + * + * The following fields are required: + * ```java + * .name() + * .settings() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandCreateParams: BrandCreateParams) = apply { + body = brandCreateParams.body.toBuilder() + additionalHeaders = brandCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = brandCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [settings] + * - [id] + * - [snippets] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The name of the brand. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun settings(settings: BrandSettings) = apply { body.settings(settings) } + + /** + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [BrandSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settings(settings: JsonField) = apply { body.settings(settings) } + + fun id(id: String?) = apply { body.id(id) } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { body.id(id) } + + fun snippets(snippets: BrandSnippets?) = apply { body.snippets(snippets) } + + /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ + fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) + + /** + * Sets [Builder.snippets] to an arbitrary JSON value. + * + * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun snippets(snippets: JsonField) = apply { body.snippets(snippets) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .settings() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandCreateParams = + BrandCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val settings: JsonField, + private val id: JsonField, + private val snippets: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + settings: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("snippets") + @ExcludeMissing + snippets: JsonField = JsonMissing.of(), + ) : this(name, settings, id, snippets, mutableMapOf()) + + /** + * The name of the brand. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun settings(): BrandSettings = settings.getRequired("settings") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun id(): Optional = id.getOptional("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun snippets(): Optional = snippets.getOptional("snippets") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settings") + @ExcludeMissing + fun _settings(): JsonField = settings + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [snippets]. + * + * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("snippets") + @ExcludeMissing + fun _snippets(): JsonField = snippets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * .settings() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var settings: JsonField? = null + private var id: JsonField = JsonMissing.of() + private var snippets: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + settings = body.settings + id = body.id + snippets = body.snippets + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The name of the brand. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun settings(settings: BrandSettings) = settings(JsonField.of(settings)) + + /** + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [BrandSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settings(settings: JsonField) = apply { this.settings = settings } + + fun id(id: String?) = id(JsonField.ofNullable(id)) + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun snippets(snippets: BrandSnippets?) = snippets(JsonField.ofNullable(snippets)) + + /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ + fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) + + /** + * Sets [Builder.snippets] to an arbitrary JSON value. + * + * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun snippets(snippets: JsonField) = apply { this.snippets = snippets } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * .settings() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + checkRequired("settings", settings), + id, + snippets, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + settings().validate() + id() + snippets().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (settings.asKnown().getOrNull()?.validity() ?: 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (snippets.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + settings == other.settings && + id == other.id && + snippets == other.snippets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, settings, id, snippets, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, settings=$settings, id=$id, snippets=$snippets, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BrandCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt new file mode 100644 index 00000000..bc296c46 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a brand by brand ID. */ +class BrandDeleteParams +private constructor( + private val brandId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun brandId(): Optional = Optional.ofNullable(brandId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BrandDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BrandDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandDeleteParams]. */ + class Builder internal constructor() { + + private var brandId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandDeleteParams: BrandDeleteParams) = apply { + brandId = brandDeleteParams.brandId + additionalHeaders = brandDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = brandDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = brandDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun brandId(brandId: String?) = apply { this.brandId = brandId } + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [BrandDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandDeleteParams = + BrandDeleteParams( + brandId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> brandId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandDeleteParams && + brandId == other.brandId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(brandId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "BrandDeleteParams{brandId=$brandId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt new file mode 100644 index 00000000..6146a079 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the list of brands. */ +class BrandListParams +private constructor( + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** A unique identifier that allows for fetching the next set of brands. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BrandListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BrandListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandListParams: BrandListParams) = apply { + cursor = brandListParams.cursor + additionalHeaders = brandListParams.additionalHeaders.toBuilder() + additionalQueryParams = brandListParams.additionalQueryParams.toBuilder() + } + + /** A unique identifier that allows for fetching the next set of brands. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandListParams = + BrandListParams(cursor, additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandListParams && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BrandListParams{cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt new file mode 100644 index 00000000..05cb87ae --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class BrandListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val paging: JsonField, + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of(), + ) : this(paging, results, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandListResponse]. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandListResponse]. */ + class Builder internal constructor() { + + private var paging: JsonField? = null + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandListResponse: BrandListResponse) = apply { + paging = brandListResponse.paging + results = brandListResponse.results.map { it.toMutableList() } + additionalProperties = brandListResponse.additionalProperties.toMutableMap() + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Brand] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Brand) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandListResponse = + BrandListResponse( + checkRequired("paging", paging), + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrandListResponse = apply { + if (validated) { + return@apply + } + + paging().validate() + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandListResponse && + paging == other.paging && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt new file mode 100644 index 00000000..22323e2b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch a specific brand by brand ID. */ +class BrandRetrieveParams +private constructor( + private val brandId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun brandId(): Optional = Optional.ofNullable(brandId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BrandRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BrandRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandRetrieveParams]. */ + class Builder internal constructor() { + + private var brandId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandRetrieveParams: BrandRetrieveParams) = apply { + brandId = brandRetrieveParams.brandId + additionalHeaders = brandRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = brandRetrieveParams.additionalQueryParams.toBuilder() + } + + fun brandId(brandId: String?) = apply { this.brandId = brandId } + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandRetrieveParams = + BrandRetrieveParams(brandId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> brandId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandRetrieveParams && + brandId == other.brandId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(brandId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BrandRetrieveParams{brandId=$brandId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt new file mode 100644 index 00000000..06adac2c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt @@ -0,0 +1,565 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BrandSettings +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val colors: JsonField, + private val email: JsonField, + private val inapp: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("colors") @ExcludeMissing colors: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("inapp") @ExcludeMissing inapp: JsonValue = JsonMissing.of(), + ) : this(colors, email, inapp, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun colors(): Optional = colors.getOptional("colors") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + @JsonProperty("inapp") @ExcludeMissing fun _inapp(): JsonValue = inapp + + /** + * Returns the raw JSON value of [colors]. + * + * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField = colors + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BrandSettings]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandSettings]. */ + class Builder internal constructor() { + + private var colors: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var inapp: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandSettings: BrandSettings) = apply { + colors = brandSettings.colors + email = brandSettings.email + inapp = brandSettings.inapp + additionalProperties = brandSettings.additionalProperties.toMutableMap() + } + + fun colors(colors: Colors?) = colors(JsonField.ofNullable(colors)) + + /** Alias for calling [Builder.colors] with `colors.orElse(null)`. */ + fun colors(colors: Optional) = colors(colors.getOrNull()) + + /** + * Sets [Builder.colors] to an arbitrary JSON value. + * + * You should usually call [Builder.colors] with a well-typed [Colors] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun colors(colors: JsonField) = apply { this.colors = colors } + + fun email(email: Email?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [Email] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun inapp(inapp: JsonValue) = apply { this.inapp = inapp } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandSettings]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandSettings = + BrandSettings(colors, email, inapp, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BrandSettings = apply { + if (validated) { + return@apply + } + + colors().ifPresent { it.validate() } + email().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (colors.asKnown().getOrNull()?.validity() ?: 0) + + (email.asKnown().getOrNull()?.validity() ?: 0) + + class Colors + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val primary: JsonField, + private val secondary: JsonField, + private val tertiary: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("primary") @ExcludeMissing primary: JsonField = JsonMissing.of(), + @JsonProperty("secondary") + @ExcludeMissing + secondary: JsonField = JsonMissing.of(), + @JsonProperty("tertiary") @ExcludeMissing tertiary: JsonField = JsonMissing.of(), + ) : this(primary, secondary, tertiary, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun primary(): Optional = primary.getOptional("primary") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondary(): Optional = secondary.getOptional("secondary") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tertiary(): Optional = tertiary.getOptional("tertiary") + + /** + * Returns the raw JSON value of [primary]. + * + * Unlike [primary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("primary") @ExcludeMissing fun _primary(): JsonField = primary + + /** + * Returns the raw JSON value of [secondary]. + * + * Unlike [secondary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secondary") @ExcludeMissing fun _secondary(): JsonField = secondary + + /** + * Returns the raw JSON value of [tertiary]. + * + * Unlike [tertiary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tertiary") @ExcludeMissing fun _tertiary(): JsonField = tertiary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Colors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Colors]. */ + class Builder internal constructor() { + + private var primary: JsonField = JsonMissing.of() + private var secondary: JsonField = JsonMissing.of() + private var tertiary: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(colors: Colors) = apply { + primary = colors.primary + secondary = colors.secondary + tertiary = colors.tertiary + additionalProperties = colors.additionalProperties.toMutableMap() + } + + fun primary(primary: String?) = primary(JsonField.ofNullable(primary)) + + /** Alias for calling [Builder.primary] with `primary.orElse(null)`. */ + fun primary(primary: Optional) = primary(primary.getOrNull()) + + /** + * Sets [Builder.primary] to an arbitrary JSON value. + * + * You should usually call [Builder.primary] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun primary(primary: JsonField) = apply { this.primary = primary } + + fun secondary(secondary: String?) = secondary(JsonField.ofNullable(secondary)) + + /** Alias for calling [Builder.secondary] with `secondary.orElse(null)`. */ + fun secondary(secondary: Optional) = secondary(secondary.getOrNull()) + + /** + * Sets [Builder.secondary] to an arbitrary JSON value. + * + * You should usually call [Builder.secondary] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun secondary(secondary: JsonField) = apply { this.secondary = secondary } + + fun tertiary(tertiary: String?) = tertiary(JsonField.ofNullable(tertiary)) + + /** Alias for calling [Builder.tertiary] with `tertiary.orElse(null)`. */ + fun tertiary(tertiary: Optional) = tertiary(tertiary.getOrNull()) + + /** + * Sets [Builder.tertiary] to an arbitrary JSON value. + * + * You should usually call [Builder.tertiary] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tertiary(tertiary: JsonField) = apply { this.tertiary = tertiary } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Colors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Colors = + Colors(primary, secondary, tertiary, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Colors = apply { + if (validated) { + return@apply + } + + primary() + secondary() + tertiary() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (primary.asKnown().isPresent) 1 else 0) + + (if (secondary.asKnown().isPresent) 1 else 0) + + (if (tertiary.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Colors && + primary == other.primary && + secondary == other.secondary && + tertiary == other.tertiary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(primary, secondary, tertiary, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Colors{primary=$primary, secondary=$secondary, tertiary=$tertiary, additionalProperties=$additionalProperties}" + } + + class Email + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val footer: JsonValue, + private val header: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("footer") @ExcludeMissing footer: JsonValue = JsonMissing.of(), + @JsonProperty("header") @ExcludeMissing header: JsonValue = JsonMissing.of(), + ) : this(footer, header, mutableMapOf()) + + @JsonProperty("footer") @ExcludeMissing fun _footer(): JsonValue = footer + + @JsonProperty("header") @ExcludeMissing fun _header(): JsonValue = header + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Email]. + * + * The following fields are required: + * ```java + * .footer() + * .header() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Email]. */ + class Builder internal constructor() { + + private var footer: JsonValue? = null + private var header: JsonValue? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(email: Email) = apply { + footer = email.footer + header = email.header + additionalProperties = email.additionalProperties.toMutableMap() + } + + fun footer(footer: JsonValue) = apply { this.footer = footer } + + fun header(header: JsonValue) = apply { this.header = header } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Email]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .footer() + * .header() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Email = + Email( + checkRequired("footer", footer), + checkRequired("header", header), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Email = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Email && + footer == other.footer && + header == other.header && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(footer, header, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Email{footer=$footer, header=$header, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandSettings && + colors == other.colors && + email == other.email && + inapp == other.inapp && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(colors, email, inapp, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandSettings{colors=$colors, email=$email, inapp=$inapp, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt new file mode 100644 index 00000000..730c58c8 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt @@ -0,0 +1,540 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class BrandSnippets +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandSnippets]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandSnippets]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandSnippets: BrandSnippets) = apply { + items = brandSnippets.items.map { it.toMutableList() } + additionalProperties = brandSnippets.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandSnippets]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandSnippets = + BrandSnippets( + checkRequired("items", items).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrandSnippets = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val format: JsonField, + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(format, name, value, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun format(): Format = format.getRequired("format") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .format() + * .name() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var format: JsonField? = null + private var name: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + format = item.format + name = item.name + value = item.value + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .format() + * .name() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("format", format), + checkRequired("name", name), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + format().validate() + name() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Format @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HANDLEBARS = of("handlebars") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + HANDLEBARS + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HANDLEBARS, + /** + * An enum member indicating that [Format] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HANDLEBARS -> Value.HANDLEBARS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + HANDLEBARS -> Known.HANDLEBARS + else -> throw CourierInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + format == other.format && + name == other.name && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(format, name, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{format=$format, name=$name, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandSnippets && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandSnippets{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt new file mode 100644 index 00000000..491dbdd5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt @@ -0,0 +1,577 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Replace an existing brand with the supplied values. */ +class BrandUpdateParams +private constructor( + private val brandId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun brandId(): Optional = Optional.ofNullable(brandId) + + /** + * The name of the brand. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settings(): Optional = body.settings() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun snippets(): Optional = body.snippets() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _settings(): JsonField = body._settings() + + /** + * Returns the raw JSON value of [snippets]. + * + * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _snippets(): JsonField = body._snippets() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandUpdateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandUpdateParams]. */ + class Builder internal constructor() { + + private var brandId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(brandUpdateParams: BrandUpdateParams) = apply { + brandId = brandUpdateParams.brandId + body = brandUpdateParams.body.toBuilder() + additionalHeaders = brandUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = brandUpdateParams.additionalQueryParams.toBuilder() + } + + fun brandId(brandId: String?) = apply { this.brandId = brandId } + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [settings] + * - [snippets] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The name of the brand. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun settings(settings: BrandSettings?) = apply { body.settings(settings) } + + /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ + fun settings(settings: Optional) = settings(settings.getOrNull()) + + /** + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [BrandSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settings(settings: JsonField) = apply { body.settings(settings) } + + fun snippets(snippets: BrandSnippets?) = apply { body.snippets(snippets) } + + /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ + fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) + + /** + * Sets [Builder.snippets] to an arbitrary JSON value. + * + * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun snippets(snippets: JsonField) = apply { body.snippets(snippets) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BrandUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandUpdateParams = + BrandUpdateParams( + brandId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> brandId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val settings: JsonField, + private val snippets: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("settings") + @ExcludeMissing + settings: JsonField = JsonMissing.of(), + @JsonProperty("snippets") + @ExcludeMissing + snippets: JsonField = JsonMissing.of(), + ) : this(name, settings, snippets, mutableMapOf()) + + /** + * The name of the brand. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun settings(): Optional = settings.getOptional("settings") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun snippets(): Optional = snippets.getOptional("snippets") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [settings]. + * + * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("settings") + @ExcludeMissing + fun _settings(): JsonField = settings + + /** + * Returns the raw JSON value of [snippets]. + * + * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("snippets") + @ExcludeMissing + fun _snippets(): JsonField = snippets + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var settings: JsonField = JsonMissing.of() + private var snippets: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + settings = body.settings + snippets = body.snippets + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The name of the brand. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun settings(settings: BrandSettings?) = settings(JsonField.ofNullable(settings)) + + /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ + fun settings(settings: Optional) = settings(settings.getOrNull()) + + /** + * Sets [Builder.settings] to an arbitrary JSON value. + * + * You should usually call [Builder.settings] with a well-typed [BrandSettings] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun settings(settings: JsonField) = apply { this.settings = settings } + + fun snippets(snippets: BrandSnippets?) = snippets(JsonField.ofNullable(snippets)) + + /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ + fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) + + /** + * Sets [Builder.snippets] to an arbitrary JSON value. + * + * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun snippets(snippets: JsonField) = apply { this.snippets = snippets } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + settings, + snippets, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + settings().ifPresent { it.validate() } + snippets().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (settings.asKnown().getOrNull()?.validity() ?: 0) + + (snippets.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + settings == other.settings && + snippets == other.snippets && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(name, settings, snippets, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, settings=$settings, snippets=$snippets, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandUpdateParams && + brandId == other.brandId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(brandId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BrandUpdateParams{brandId=$brandId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt new file mode 100644 index 00000000..8dcca0d7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt @@ -0,0 +1,462 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Ingest user data into a Bulk Job */ +class BulkAddUsersParams +private constructor( + private val jobId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun jobId(): Optional = Optional.ofNullable(jobId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun users(): List = body.users() + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _users(): JsonField> = body._users() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkAddUsersParams]. + * + * The following fields are required: + * ```java + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkAddUsersParams]. */ + class Builder internal constructor() { + + private var jobId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkAddUsersParams: BulkAddUsersParams) = apply { + jobId = bulkAddUsersParams.jobId + body = bulkAddUsersParams.body.toBuilder() + additionalHeaders = bulkAddUsersParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkAddUsersParams.additionalQueryParams.toBuilder() + } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [users] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun users(users: List) = apply { body.users(users) } + + /** + * Sets [Builder.users] to an arbitrary JSON value. + * + * You should usually call [Builder.users] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun users(users: JsonField>) = apply { body.users(users) } + + /** + * Adds a single [InboundBulkMessageUser] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: InboundBulkMessageUser) = apply { body.addUser(user) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkAddUsersParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkAddUsersParams = + BulkAddUsersParams( + jobId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val users: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("users") + @ExcludeMissing + users: JsonField> = JsonMissing.of() + ) : this(users, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun users(): List = users.getRequired("users") + + /** + * Returns the raw JSON value of [users]. + * + * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("users") + @ExcludeMissing + fun _users(): JsonField> = users + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .users() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var users: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + users = body.users.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun users(users: List) = users(JsonField.of(users)) + + /** + * Sets [Builder.users] to an arbitrary JSON value. + * + * You should usually call [Builder.users] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun users(users: JsonField>) = apply { + this.users = users.map { it.toMutableList() } + } + + /** + * Adds a single [InboundBulkMessageUser] to [users]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addUser(user: InboundBulkMessageUser) = apply { + users = + (users ?: JsonField.of(mutableListOf())).also { + checkKnown("users", it).add(user) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .users() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("users", users).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + users().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + users == other.users && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(users, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{users=$users, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkAddUsersParams && + jobId == other.jobId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(jobId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkAddUsersParams{jobId=$jobId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt new file mode 100644 index 00000000..e859ea4a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt @@ -0,0 +1,416 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Create a bulk job */ +class BulkCreateJobParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): InboundBulkMessage = body.message() + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _message(): JsonField = body._message() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkCreateJobParams]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkCreateJobParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkCreateJobParams: BulkCreateJobParams) = apply { + body = bulkCreateJobParams.body.toBuilder() + additionalHeaders = bulkCreateJobParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkCreateJobParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [message] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun message(message: InboundBulkMessage) = apply { body.message(message) } + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [InboundBulkMessage] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { body.message(message) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkCreateJobParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkCreateJobParams = + BulkCreateJobParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val message: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of() + ) : this(message, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): InboundBulkMessage = message.getRequired("message") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") + @ExcludeMissing + fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + message = body.message + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun message(message: InboundBulkMessage) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [InboundBulkMessage] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("message", message), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + message().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (message.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{message=$message, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkCreateJobParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkCreateJobParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt new file mode 100644 index 00000000..d3535854 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class BulkCreateJobResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of() + ) : this(jobId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun jobId(): String = jobId.getRequired("jobId") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkCreateJobResponse]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkCreateJobResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkCreateJobResponse: BulkCreateJobResponse) = apply { + jobId = bulkCreateJobResponse.jobId + additionalProperties = bulkCreateJobResponse.additionalProperties.toMutableMap() + } + + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkCreateJobResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkCreateJobResponse = + BulkCreateJobResponse( + checkRequired("jobId", jobId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkCreateJobResponse = apply { + if (validated) { + return@apply + } + + jobId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkCreateJobResponse && + jobId == other.jobId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkCreateJobResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt new file mode 100644 index 00000000..dbfe2ab0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Bulk Job Users */ +class BulkListUsersParams +private constructor( + private val jobId: String?, + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun jobId(): Optional = Optional.ofNullable(jobId) + + /** A unique identifier that allows for fetching the next set of users added to the bulk job */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkListUsersParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BulkListUsersParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkListUsersParams]. */ + class Builder internal constructor() { + + private var jobId: String? = null + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkListUsersParams: BulkListUsersParams) = apply { + jobId = bulkListUsersParams.jobId + cursor = bulkListUsersParams.cursor + additionalHeaders = bulkListUsersParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkListUsersParams.additionalQueryParams.toBuilder() + } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + + /** + * A unique identifier that allows for fetching the next set of users added to the bulk job + */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkListUsersParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkListUsersParams = + BulkListUsersParams( + jobId, + cursor, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkListUsersParams && + jobId == other.jobId && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(jobId, cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkListUsersParams{jobId=$jobId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt new file mode 100644 index 00000000..7647e244 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt @@ -0,0 +1,710 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BulkListUsersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkListUsersResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkListUsersResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkListUsersResponse: BulkListUsersResponse) = apply { + items = bulkListUsersResponse.items.map { it.toMutableList() } + paging = bulkListUsersResponse.paging + additionalProperties = bulkListUsersResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkListUsersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkListUsersResponse = + BulkListUsersResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BulkListUsersResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonValue, + private val preferences: JsonField, + private val profile: JsonValue, + private val recipient: JsonField, + private val to: JsonField, + private val status: JsonField, + private val messageId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), + @JsonProperty("recipient") + @ExcludeMissing + recipient: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("messageId") + @ExcludeMissing + messageId: JsonField = JsonMissing.of(), + ) : this(data, preferences, profile, recipient, to, status, messageId, mutableMapOf()) + + fun toInboundBulkMessageUser(): InboundBulkMessageUser = + InboundBulkMessageUser.builder() + .data(data) + .preferences(preferences) + .profile(profile) + .recipient(recipient) + .to(to) + .build() + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recipient(): Optional = recipient.getOptional("recipient") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun messageId(): Optional = messageId.getOptional("messageId") + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [messageId]. + * + * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var data: JsonValue = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var profile: JsonValue = JsonMissing.of() + private var recipient: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() + private var status: JsonField? = null + private var messageId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + data = item.data + preferences = item.preferences + profile = item.profile + recipient = item.recipient + to = item.to + status = item.status + messageId = item.messageId + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun data(data: JsonValue) = apply { this.data = data } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [RecipientPreferences] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun profile(profile: JsonValue) = apply { this.profile = profile } + + fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + fun to(to: UserRecipient?) = to(JsonField.ofNullable(to)) + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.getOrNull()) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [UserRecipient] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun to(to: JsonField) = apply { this.to = to } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun messageId(messageId: String?) = messageId(JsonField.ofNullable(messageId)) + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + /** + * Sets [Builder.messageId] to an arbitrary JSON value. + * + * You should usually call [Builder.messageId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messageId(messageId: JsonField) = apply { this.messageId = messageId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + data, + preferences, + profile, + recipient, + to, + checkRequired("status", status), + messageId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + preferences().ifPresent { it.validate() } + recipient() + to().ifPresent { it.validate() } + status().validate() + messageId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (to.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (messageId.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PENDING = of("PENDING") + + @JvmField val ENQUEUED = of("ENQUEUED") + + @JvmField val ERROR = of("ERROR") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + PENDING, + ENQUEUED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PENDING, + ENQUEUED, + ERROR, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PENDING -> Value.PENDING + ENQUEUED -> Value.ENQUEUED + ERROR -> Value.ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PENDING -> Known.PENDING + ENQUEUED -> Known.ENQUEUED + ERROR -> Known.ERROR + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + data == other.data && + preferences == other.preferences && + profile == other.profile && + recipient == other.recipient && + to == other.to && + status == other.status && + messageId == other.messageId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + data, + preferences, + profile, + recipient, + to, + status, + messageId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{data=$data, preferences=$preferences, profile=$profile, recipient=$recipient, to=$to, status=$status, messageId=$messageId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkListUsersResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkListUsersResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt new file mode 100644 index 00000000..f828a7c6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a bulk job */ +class BulkRetrieveJobParams +private constructor( + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun jobId(): Optional = Optional.ofNullable(jobId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkRetrieveJobParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BulkRetrieveJobParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRetrieveJobParams]. */ + class Builder internal constructor() { + + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(bulkRetrieveJobParams: BulkRetrieveJobParams) = apply { + jobId = bulkRetrieveJobParams.jobId + additionalHeaders = bulkRetrieveJobParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkRetrieveJobParams.additionalQueryParams.toBuilder() + } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BulkRetrieveJobParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkRetrieveJobParams = + BulkRetrieveJobParams(jobId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRetrieveJobParams && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BulkRetrieveJobParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt new file mode 100644 index 00000000..977d30b0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt @@ -0,0 +1,612 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class BulkRetrieveJobResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val job: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() + ) : this(job, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun job(): Job = job.getRequired("job") + + /** + * Returns the raw JSON value of [job]. + * + * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BulkRetrieveJobResponse]. + * + * The following fields are required: + * ```java + * .job() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRetrieveJobResponse]. */ + class Builder internal constructor() { + + private var job: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkRetrieveJobResponse: BulkRetrieveJobResponse) = apply { + job = bulkRetrieveJobResponse.job + additionalProperties = bulkRetrieveJobResponse.additionalProperties.toMutableMap() + } + + fun job(job: Job) = job(JsonField.of(job)) + + /** + * Sets [Builder.job] to an arbitrary JSON value. + * + * You should usually call [Builder.job] with a well-typed [Job] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun job(job: JsonField) = apply { this.job = job } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BulkRetrieveJobResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .job() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BulkRetrieveJobResponse = + BulkRetrieveJobResponse(checkRequired("job", job), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BulkRetrieveJobResponse = apply { + if (validated) { + return@apply + } + + job().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (job.asKnown().getOrNull()?.validity() ?: 0) + + class Job + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val definition: JsonField, + private val enqueued: JsonField, + private val failures: JsonField, + private val received: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("definition") + @ExcludeMissing + definition: JsonField = JsonMissing.of(), + @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), + @JsonProperty("failures") @ExcludeMissing failures: JsonField = JsonMissing.of(), + @JsonProperty("received") @ExcludeMissing received: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(definition, enqueued, failures, received, status, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun definition(): InboundBulkMessage = definition.getRequired("definition") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun enqueued(): Long = enqueued.getRequired("enqueued") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun failures(): Long = failures.getRequired("failures") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun received(): Long = received.getRequired("received") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [definition]. + * + * Unlike [definition], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("definition") + @ExcludeMissing + fun _definition(): JsonField = definition + + /** + * Returns the raw JSON value of [enqueued]. + * + * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued + + /** + * Returns the raw JSON value of [failures]. + * + * Unlike [failures], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("failures") @ExcludeMissing fun _failures(): JsonField = failures + + /** + * Returns the raw JSON value of [received]. + * + * Unlike [received], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("received") @ExcludeMissing fun _received(): JsonField = received + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Job]. + * + * The following fields are required: + * ```java + * .definition() + * .enqueued() + * .failures() + * .received() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Job]. */ + class Builder internal constructor() { + + private var definition: JsonField? = null + private var enqueued: JsonField? = null + private var failures: JsonField? = null + private var received: JsonField? = null + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(job: Job) = apply { + definition = job.definition + enqueued = job.enqueued + failures = job.failures + received = job.received + status = job.status + additionalProperties = job.additionalProperties.toMutableMap() + } + + fun definition(definition: InboundBulkMessage) = definition(JsonField.of(definition)) + + /** + * Sets [Builder.definition] to an arbitrary JSON value. + * + * You should usually call [Builder.definition] with a well-typed [InboundBulkMessage] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun definition(definition: JsonField) = apply { + this.definition = definition + } + + fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) + + /** + * Sets [Builder.enqueued] to an arbitrary JSON value. + * + * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } + + fun failures(failures: Long) = failures(JsonField.of(failures)) + + /** + * Sets [Builder.failures] to an arbitrary JSON value. + * + * You should usually call [Builder.failures] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun failures(failures: JsonField) = apply { this.failures = failures } + + fun received(received: Long) = received(JsonField.of(received)) + + /** + * Sets [Builder.received] to an arbitrary JSON value. + * + * You should usually call [Builder.received] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun received(received: JsonField) = apply { this.received = received } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Job]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .definition() + * .enqueued() + * .failures() + * .received() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Job = + Job( + checkRequired("definition", definition), + checkRequired("enqueued", enqueued), + checkRequired("failures", failures), + checkRequired("received", received), + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Job = apply { + if (validated) { + return@apply + } + + definition().validate() + enqueued() + failures() + received() + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (definition.asKnown().getOrNull()?.validity() ?: 0) + + (if (enqueued.asKnown().isPresent) 1 else 0) + + (if (failures.asKnown().isPresent) 1 else 0) + + (if (received.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CREATED = of("CREATED") + + @JvmField val PROCESSING = of("PROCESSING") + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val ERROR = of("ERROR") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CREATED, + PROCESSING, + COMPLETED, + ERROR, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED, + PROCESSING, + COMPLETED, + ERROR, + /** + * An enum member indicating that [Status] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED -> Value.CREATED + PROCESSING -> Value.PROCESSING + COMPLETED -> Value.COMPLETED + ERROR -> Value.ERROR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED -> Known.CREATED + PROCESSING -> Known.PROCESSING + COMPLETED -> Known.COMPLETED + ERROR -> Known.ERROR + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Job && + definition == other.definition && + enqueued == other.enqueued && + failures == other.failures && + received == other.received && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(definition, enqueued, failures, received, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Job{definition=$definition, enqueued=$enqueued, failures=$failures, received=$received, status=$status, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRetrieveJobResponse && + job == other.job && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BulkRetrieveJobResponse{job=$job, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt new file mode 100644 index 00000000..4c90666c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Run a bulk job */ +class BulkRunJobParams +private constructor( + private val jobId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun jobId(): Optional = Optional.ofNullable(jobId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): BulkRunJobParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BulkRunJobParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BulkRunJobParams]. */ + class Builder internal constructor() { + + private var jobId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(bulkRunJobParams: BulkRunJobParams) = apply { + jobId = bulkRunJobParams.jobId + additionalHeaders = bulkRunJobParams.additionalHeaders.toBuilder() + additionalQueryParams = bulkRunJobParams.additionalQueryParams.toBuilder() + additionalBodyProperties = bulkRunJobParams.additionalBodyProperties.toMutableMap() + } + + fun jobId(jobId: String?) = apply { this.jobId = jobId } + + /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ + fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [BulkRunJobParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BulkRunJobParams = + BulkRunJobParams( + jobId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> jobId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BulkRunJobParams && + jobId == other.jobId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(jobId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "BulkRunJobParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt new file mode 100644 index 00000000..966be3c5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt @@ -0,0 +1,2294 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.Content +import com.courier.api.models.send.MessageContext +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InboundBulkMessage +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val brand: JsonField, + private val data: JsonField, + private val event: JsonField, + private val locale: JsonField, + private val message: JsonField, + private val override: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("locale") @ExcludeMissing locale: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("override") @ExcludeMissing override: JsonValue = JsonMissing.of(), + ) : this(brand, data, event, locale, message, override, mutableMapOf()) + + /** + * A unique identifier that represents the brand that should be used for rendering the + * notification. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brand(): Optional = brand.getOptional("brand") + + /** + * JSON that includes any data you want to pass to a message template. The data will populate + * the corresponding template variables. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun event(): Optional = event.getOptional("event") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locale(): Optional = locale.getOptional("locale") + + /** + * Describes the content of the message in a way that will work for email, push, chat, or any + * channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun message(): Optional = message.getOptional("message") + + /** + * JSON that is merged into the request sent by Courier to the provider to override properties + * or to gain access to features in the provider API that are not natively supported by Courier. + */ + @JsonProperty("override") @ExcludeMissing fun _override(): JsonValue = override + + /** + * Returns the raw JSON value of [brand]. + * + * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [locale]. + * + * Unlike [locale], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InboundBulkMessage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundBulkMessage]. */ + class Builder internal constructor() { + + private var brand: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var event: JsonField = JsonMissing.of() + private var locale: JsonField = JsonMissing.of() + private var message: JsonField = JsonMissing.of() + private var override: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundBulkMessage: InboundBulkMessage) = apply { + brand = inboundBulkMessage.brand + data = inboundBulkMessage.data + event = inboundBulkMessage.event + locale = inboundBulkMessage.locale + message = inboundBulkMessage.message + override = inboundBulkMessage.override + additionalProperties = inboundBulkMessage.additionalProperties.toMutableMap() + } + + /** + * A unique identifier that represents the brand that should be used for rendering the + * notification. + */ + fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) + + /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ + fun brand(brand: Optional) = brand(brand.getOrNull()) + + /** + * Sets [Builder.brand] to an arbitrary JSON value. + * + * You should usually call [Builder.brand] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brand(brand: JsonField) = apply { this.brand = brand } + + /** + * JSON that includes any data you want to pass to a message template. The data will + * populate the corresponding template variables. + */ + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun event(event: String?) = event(JsonField.ofNullable(event)) + + /** Alias for calling [Builder.event] with `event.orElse(null)`. */ + fun event(event: Optional) = event(event.getOrNull()) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + fun locale(locale: Locale?) = locale(JsonField.ofNullable(locale)) + + /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ + fun locale(locale: Optional) = locale(locale.getOrNull()) + + /** + * Sets [Builder.locale] to an arbitrary JSON value. + * + * You should usually call [Builder.locale] with a well-typed [Locale] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun locale(locale: JsonField) = apply { this.locale = locale } + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. + */ + fun message(message: Message?) = message(JsonField.ofNullable(message)) + + /** Alias for calling [Builder.message] with `message.orElse(null)`. */ + fun message(message: Optional) = message(message.getOrNull()) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** + * Alias for calling [message] with `Message.ofInboundBulkTemplate(inboundBulkTemplate)`. + */ + fun message(inboundBulkTemplate: Message.InboundBulkTemplateMessage) = + message(Message.ofInboundBulkTemplate(inboundBulkTemplate)) + + /** Alias for calling [message] with `Message.ofInboundBulkContent(inboundBulkContent)`. */ + fun message(inboundBulkContent: Message.InboundBulkContentMessage) = + message(Message.ofInboundBulkContent(inboundBulkContent)) + + /** + * JSON that is merged into the request sent by Courier to the provider to override + * properties or to gain access to features in the provider API that are not natively + * supported by Courier. + */ + fun override(override: JsonValue) = apply { this.override = override } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundBulkMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundBulkMessage = + InboundBulkMessage( + brand, + data, + event, + locale, + message, + override, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundBulkMessage = apply { + if (validated) { + return@apply + } + + brand() + data().ifPresent { it.validate() } + event() + locale().ifPresent { it.validate() } + message().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brand.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (event.asKnown().isPresent) 1 else 0) + + (locale.asKnown().getOrNull()?.validity() ?: 0) + + (message.asKnown().getOrNull()?.validity() ?: 0) + + /** + * JSON that includes any data you want to pass to a message template. The data will populate + * the corresponding template variables. + */ + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Locale + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Locale]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Locale]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(locale: Locale) = apply { + additionalProperties = locale.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Locale]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Locale = Locale(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Locale = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Locale && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Locale{additionalProperties=$additionalProperties}" + } + + /** + * Describes the content of the message in a way that will work for email, push, chat, or any + * channel. + */ + @JsonDeserialize(using = Message.Deserializer::class) + @JsonSerialize(using = Message.Serializer::class) + class Message + private constructor( + private val inboundBulkTemplate: InboundBulkTemplateMessage? = null, + private val inboundBulkContent: InboundBulkContentMessage? = null, + private val _json: JsonValue? = null, + ) { + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. + */ + fun inboundBulkTemplate(): Optional = + Optional.ofNullable(inboundBulkTemplate) + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + fun inboundBulkContent(): Optional = + Optional.ofNullable(inboundBulkContent) + + fun isInboundBulkTemplate(): Boolean = inboundBulkTemplate != null + + fun isInboundBulkContent(): Boolean = inboundBulkContent != null + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. + */ + fun asInboundBulkTemplate(): InboundBulkTemplateMessage = + inboundBulkTemplate.getOrThrow("inboundBulkTemplate") + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + fun asInboundBulkContent(): InboundBulkContentMessage = + inboundBulkContent.getOrThrow("inboundBulkContent") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + inboundBulkTemplate != null -> visitor.visitInboundBulkTemplate(inboundBulkTemplate) + inboundBulkContent != null -> visitor.visitInboundBulkContent(inboundBulkContent) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitInboundBulkTemplate( + inboundBulkTemplate: InboundBulkTemplateMessage + ) { + inboundBulkTemplate.validate() + } + + override fun visitInboundBulkContent( + inboundBulkContent: InboundBulkContentMessage + ) { + inboundBulkContent.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitInboundBulkTemplate( + inboundBulkTemplate: InboundBulkTemplateMessage + ) = inboundBulkTemplate.validity() + + override fun visitInboundBulkContent( + inboundBulkContent: InboundBulkContentMessage + ) = inboundBulkContent.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Message && + inboundBulkTemplate == other.inboundBulkTemplate && + inboundBulkContent == other.inboundBulkContent + } + + override fun hashCode(): Int = Objects.hash(inboundBulkTemplate, inboundBulkContent) + + override fun toString(): String = + when { + inboundBulkTemplate != null -> "Message{inboundBulkTemplate=$inboundBulkTemplate}" + inboundBulkContent != null -> "Message{inboundBulkContent=$inboundBulkContent}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + + companion object { + + /** + * Describes the content of the message in a way that will work for email, push, chat, + * or any channel. + */ + @JvmStatic + fun ofInboundBulkTemplate(inboundBulkTemplate: InboundBulkTemplateMessage) = + Message(inboundBulkTemplate = inboundBulkTemplate) + + /** + * A template for a type of message that can be sent more than once. For example, you + * might create an "Appointment Reminder" Notification or “Reset Password” + * Notifications. + */ + @JvmStatic + fun ofInboundBulkContent(inboundBulkContent: InboundBulkContentMessage) = + Message(inboundBulkContent = inboundBulkContent) + } + + /** + * An interface that defines how to map each variant of [Message] to a value of type [T]. + */ + interface Visitor { + + /** + * Describes the content of the message in a way that will work for email, push, chat, + * or any channel. + */ + fun visitInboundBulkTemplate(inboundBulkTemplate: InboundBulkTemplateMessage): T + + /** + * A template for a type of message that can be sent more than once. For example, you + * might create an "Appointment Reminder" Notification or “Reset Password” + * Notifications. + */ + fun visitInboundBulkContent(inboundBulkContent: InboundBulkContentMessage): T + + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Message: $json") + } + } + + internal class Deserializer : BaseDeserializer(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Message(inboundBulkTemplate = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Message(inboundBulkContent = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Message(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.inboundBulkTemplate != null -> + generator.writeObject(value.inboundBulkTemplate) + value.inboundBulkContent != null -> + generator.writeObject(value.inboundBulkContent) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. + */ + class InboundBulkTemplateMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brandId: JsonField, + private val channels: JsonField, + private val context: JsonField, + private val data: JsonField, + private val delay: JsonField, + private val expiry: JsonField, + private val metadata: JsonField, + private val preferences: JsonField, + private val providers: JsonField, + private val routing: JsonField, + private val timeout: JsonField, + private val template: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brand_id") + @ExcludeMissing + brandId: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("delay") + @ExcludeMissing + delay: JsonField = JsonMissing.of(), + @JsonProperty("expiry") + @ExcludeMissing + expiry: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + @JsonProperty("routing") + @ExcludeMissing + routing: JsonField = JsonMissing.of(), + @JsonProperty("timeout") + @ExcludeMissing + timeout: JsonField = JsonMissing.of(), + @JsonProperty("template") + @ExcludeMissing + template: JsonField = JsonMissing.of(), + ) : this( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + template, + mutableMapOf(), + ) + + fun toBaseMessage(): BaseMessage = + BaseMessage.builder() + .brandId(brandId) + .channels(channels) + .context(context) + .data(data) + .delay(delay) + .expiry(expiry) + .metadata(metadata) + .preferences(preferences) + .providers(providers) + .routing(routing) + .timeout(timeout) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * "Define run-time configuration for one or more channels. If you don't specify + * channels, the default configuration for each channel will be used. Valid ChannelId's + * are: email, sms, push, inbox, direct_message, banner, and webhook." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * Context to load with this recipient. Will override any context set on + * message.context. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * An arbitrary object that includes any data you want to pass to the message. The data + * will populate the corresponding template or elements variables. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an + * ISO 8601 timestamp that specifies when it should be delivered. Until with an + * OpenStreetMap opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun delay(): Optional = delay.getOptional("delay") + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. + * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiry(): Optional = expiry.getOptional("expiry") + + /** + * Metadata such as utm tracking attached with the notification through this channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun preferences(): Optional = + preferences.getOptional("preferences") + + /** + * An object whose keys are valid provider identifiers which map to an object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the + * message. If no routing key is specified, Courier will use the default routing + * configuration or routing defined by the template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun routing(): Optional = routing.getOptional("routing") + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * The id of the notification template to be rendered and sent to the recipient(s). This + * field or the content field must be supplied. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun template(): String = template.getRequired("template") + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [delay]. + * + * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delay") + @ExcludeMissing + fun _delay(): JsonField = delay + + /** + * Returns the raw JSON value of [expiry]. + * + * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry") + @ExcludeMissing + fun _expiry(): JsonField = expiry + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField = providers + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") + @ExcludeMissing + fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") + @ExcludeMissing + fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InboundBulkTemplateMessage]. + * + * The following fields are required: + * ```java + * .template() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundBulkTemplateMessage]. */ + class Builder internal constructor() { + + private var brandId: JsonField = JsonMissing.of() + private var channels: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var delay: JsonField = JsonMissing.of() + private var expiry: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var routing: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var template: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundBulkTemplateMessage: InboundBulkTemplateMessage) = apply { + brandId = inboundBulkTemplateMessage.brandId + channels = inboundBulkTemplateMessage.channels + context = inboundBulkTemplateMessage.context + data = inboundBulkTemplateMessage.data + delay = inboundBulkTemplateMessage.delay + expiry = inboundBulkTemplateMessage.expiry + metadata = inboundBulkTemplateMessage.metadata + preferences = inboundBulkTemplateMessage.preferences + providers = inboundBulkTemplateMessage.providers + routing = inboundBulkTemplateMessage.routing + timeout = inboundBulkTemplateMessage.timeout + template = inboundBulkTemplateMessage.template + additionalProperties = + inboundBulkTemplateMessage.additionalProperties.toMutableMap() + } + + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * "Define run-time configuration for one or more channels. If you don't specify + * channels, the default configuration for each channel will be used. Valid + * ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." + */ + fun channels(channels: BaseMessage.Channels?) = + channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional) = + channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed + * [BaseMessage.Channels] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun channels(channels: JsonField) = apply { + this.channels = channels + } + + /** + * Context to load with this recipient. Will override any context set on + * message.context. + */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + /** + * An arbitrary object that includes any data you want to pass to the message. The + * data will populate the corresponding template or elements variables. + */ + fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** + * Defines the time to wait before delivering the message. You can specify one of + * the following options. Duration with the number of milliseconds to delay. Until + * with an ISO 8601 timestamp that specifies when it should be delivered. Until with + * an OpenStreetMap opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) + + /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ + fun delay(delay: Optional) = delay(delay.getOrNull()) + + /** + * Sets [Builder.delay] to an arbitrary JSON value. + * + * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun delay(delay: JsonField) = apply { this.delay = delay } + + /** + * "Expiry allows you to set an absolute or relative time in which a message + * expires. Note: This is only valid for the Courier Inbox channel as of + * 12-08-2022." + */ + fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) + + /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ + fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) + + /** + * Sets [Builder.expiry] to an arbitrary JSON value. + * + * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun expiry(expiry: JsonField) = apply { this.expiry = expiry } + + /** + * Metadata such as utm tracking attached with the notification through this + * channel. + */ + fun metadata(metadata: BaseMessage.Metadata?) = + metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = + metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed + * [BaseMessage.Metadata] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun preferences(preferences: BaseMessage.Preferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [BaseMessage.Preferences] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** An object whose keys are valid provider identifiers which map to an object. */ + fun providers(providers: BaseMessage.Providers?) = + providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = + providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed + * [BaseMessage.Providers] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun providers(providers: JsonField) = apply { + this.providers = providers + } + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the + * message. If no routing key is specified, Courier will use the default routing + * configuration or routing defined by the template. + */ + fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) + + /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ + fun routing(routing: Optional) = routing(routing.getOrNull()) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun routing(routing: JsonField) = apply { + this.routing = routing + } + + /** + * Time in ms to attempt the channel before failing over to the next available + * channel. + */ + fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { + this.timeout = timeout + } + + /** + * The id of the notification template to be rendered and sent to the recipient(s). + * This field or the content field must be supplied. + */ + fun template(template: String) = template(JsonField.of(template)) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundBulkTemplateMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .template() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboundBulkTemplateMessage = + InboundBulkTemplateMessage( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + checkRequired("template", template), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundBulkTemplateMessage = apply { + if (validated) { + return@apply + } + + brandId() + channels().ifPresent { it.validate() } + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + delay().ifPresent { it.validate() } + expiry().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + preferences().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + routing().ifPresent { it.validate() } + timeout().ifPresent { it.validate() } + template() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brandId.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (delay.asKnown().getOrNull()?.validity() ?: 0) + + (expiry.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (if (template.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundBulkTemplateMessage && + brandId == other.brandId && + channels == other.channels && + context == other.context && + data == other.data && + delay == other.delay && + expiry == other.expiry && + metadata == other.metadata && + preferences == other.preferences && + providers == other.providers && + routing == other.routing && + timeout == other.timeout && + template == other.template && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + template, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundBulkTemplateMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, template=$template, additionalProperties=$additionalProperties}" + } + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + class InboundBulkContentMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brandId: JsonField, + private val channels: JsonField, + private val context: JsonField, + private val data: JsonField, + private val delay: JsonField, + private val expiry: JsonField, + private val metadata: JsonField, + private val preferences: JsonField, + private val providers: JsonField, + private val routing: JsonField, + private val timeout: JsonField, + private val content: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brand_id") + @ExcludeMissing + brandId: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("delay") + @ExcludeMissing + delay: JsonField = JsonMissing.of(), + @JsonProperty("expiry") + @ExcludeMissing + expiry: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + @JsonProperty("routing") + @ExcludeMissing + routing: JsonField = JsonMissing.of(), + @JsonProperty("timeout") + @ExcludeMissing + timeout: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + ) : this( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + content, + mutableMapOf(), + ) + + fun toBaseMessage(): BaseMessage = + BaseMessage.builder() + .brandId(brandId) + .channels(channels) + .context(context) + .data(data) + .delay(delay) + .expiry(expiry) + .metadata(metadata) + .preferences(preferences) + .providers(providers) + .routing(routing) + .timeout(timeout) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * "Define run-time configuration for one or more channels. If you don't specify + * channels, the default configuration for each channel will be used. Valid ChannelId's + * are: email, sms, push, inbox, direct_message, banner, and webhook." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * Context to load with this recipient. Will override any context set on + * message.context. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * An arbitrary object that includes any data you want to pass to the message. The data + * will populate the corresponding template or elements variables. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an + * ISO 8601 timestamp that specifies when it should be delivered. Until with an + * OpenStreetMap opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun delay(): Optional = delay.getOptional("delay") + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. + * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiry(): Optional = expiry.getOptional("expiry") + + /** + * Metadata such as utm tracking attached with the notification through this channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun preferences(): Optional = + preferences.getOptional("preferences") + + /** + * An object whose keys are valid provider identifiers which map to an object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the + * message. If no routing key is specified, Courier will use the default routing + * configuration or routing defined by the template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun routing(): Optional = routing.getOptional("routing") + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * Describes the content of the message in a way that will work for email, push, chat, + * or any channel. Either this or template must be specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [delay]. + * + * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delay") + @ExcludeMissing + fun _delay(): JsonField = delay + + /** + * Returns the raw JSON value of [expiry]. + * + * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry") + @ExcludeMissing + fun _expiry(): JsonField = expiry + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField = providers + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") + @ExcludeMissing + fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") + @ExcludeMissing + fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InboundBulkContentMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundBulkContentMessage]. */ + class Builder internal constructor() { + + private var brandId: JsonField = JsonMissing.of() + private var channels: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var delay: JsonField = JsonMissing.of() + private var expiry: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var routing: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var content: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundBulkContentMessage: InboundBulkContentMessage) = apply { + brandId = inboundBulkContentMessage.brandId + channels = inboundBulkContentMessage.channels + context = inboundBulkContentMessage.context + data = inboundBulkContentMessage.data + delay = inboundBulkContentMessage.delay + expiry = inboundBulkContentMessage.expiry + metadata = inboundBulkContentMessage.metadata + preferences = inboundBulkContentMessage.preferences + providers = inboundBulkContentMessage.providers + routing = inboundBulkContentMessage.routing + timeout = inboundBulkContentMessage.timeout + content = inboundBulkContentMessage.content + additionalProperties = + inboundBulkContentMessage.additionalProperties.toMutableMap() + } + + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * "Define run-time configuration for one or more channels. If you don't specify + * channels, the default configuration for each channel will be used. Valid + * ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." + */ + fun channels(channels: BaseMessage.Channels?) = + channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional) = + channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed + * [BaseMessage.Channels] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun channels(channels: JsonField) = apply { + this.channels = channels + } + + /** + * Context to load with this recipient. Will override any context set on + * message.context. + */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + /** + * An arbitrary object that includes any data you want to pass to the message. The + * data will populate the corresponding template or elements variables. + */ + fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** + * Defines the time to wait before delivering the message. You can specify one of + * the following options. Duration with the number of milliseconds to delay. Until + * with an ISO 8601 timestamp that specifies when it should be delivered. Until with + * an OpenStreetMap opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) + + /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ + fun delay(delay: Optional) = delay(delay.getOrNull()) + + /** + * Sets [Builder.delay] to an arbitrary JSON value. + * + * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun delay(delay: JsonField) = apply { this.delay = delay } + + /** + * "Expiry allows you to set an absolute or relative time in which a message + * expires. Note: This is only valid for the Courier Inbox channel as of + * 12-08-2022." + */ + fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) + + /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ + fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) + + /** + * Sets [Builder.expiry] to an arbitrary JSON value. + * + * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun expiry(expiry: JsonField) = apply { this.expiry = expiry } + + /** + * Metadata such as utm tracking attached with the notification through this + * channel. + */ + fun metadata(metadata: BaseMessage.Metadata?) = + metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = + metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed + * [BaseMessage.Metadata] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun preferences(preferences: BaseMessage.Preferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [BaseMessage.Preferences] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** An object whose keys are valid provider identifiers which map to an object. */ + fun providers(providers: BaseMessage.Providers?) = + providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = + providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed + * [BaseMessage.Providers] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun providers(providers: JsonField) = apply { + this.providers = providers + } + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the + * message. If no routing key is specified, Courier will use the default routing + * configuration or routing defined by the template. + */ + fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) + + /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ + fun routing(routing: Optional) = routing(routing.getOrNull()) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun routing(routing: JsonField) = apply { + this.routing = routing + } + + /** + * Time in ms to attempt the channel before failing over to the next available + * channel. + */ + fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { + this.timeout = timeout + } + + /** + * Describes the content of the message in a way that will work for email, push, + * chat, or any channel. Either this or template must be specified. + */ + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ + fun content(elemental: Content.ElementalContent) = + content(Content.ofElemental(elemental)) + + /** + * Alias for calling [content] with + * `Content.ofElementalContentSugar(elementalContentSugar)`. + */ + fun content(elementalContentSugar: Content.ElementalContentSugar) = + content(Content.ofElementalContentSugar(elementalContentSugar)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundBulkContentMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboundBulkContentMessage = + InboundBulkContentMessage( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + checkRequired("content", content), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundBulkContentMessage = apply { + if (validated) { + return@apply + } + + brandId() + channels().ifPresent { it.validate() } + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + delay().ifPresent { it.validate() } + expiry().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + preferences().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + routing().ifPresent { it.validate() } + timeout().ifPresent { it.validate() } + content().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brandId.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (delay.asKnown().getOrNull()?.validity() ?: 0) + + (expiry.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundBulkContentMessage && + brandId == other.brandId && + channels == other.channels && + context == other.context && + data == other.data && + delay == other.delay && + expiry == other.expiry && + metadata == other.metadata && + preferences == other.preferences && + providers == other.providers && + routing == other.routing && + timeout == other.timeout && + content == other.content && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + content, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundBulkContentMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, content=$content, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundBulkMessage && + brand == other.brand && + data == other.data && + event == other.event && + locale == other.locale && + message == other.message && + override == other.override && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(brand, data, event, locale, message, override, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundBulkMessage{brand=$brand, data=$data, event=$event, locale=$locale, message=$message, override=$override, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt new file mode 100644 index 00000000..2ebcd6da --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt @@ -0,0 +1,264 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InboundBulkMessageUser +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonValue, + private val preferences: JsonField, + private val profile: JsonValue, + private val recipient: JsonField, + private val to: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), + @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this(data, preferences, profile, recipient, to, mutableMapOf()) + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun recipient(): Optional = recipient.getOptional("recipient") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [InboundBulkMessageUser]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundBulkMessageUser]. */ + class Builder internal constructor() { + + private var data: JsonValue = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var profile: JsonValue = JsonMissing.of() + private var recipient: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundBulkMessageUser: InboundBulkMessageUser) = apply { + data = inboundBulkMessageUser.data + preferences = inboundBulkMessageUser.preferences + profile = inboundBulkMessageUser.profile + recipient = inboundBulkMessageUser.recipient + to = inboundBulkMessageUser.to + additionalProperties = inboundBulkMessageUser.additionalProperties.toMutableMap() + } + + fun data(data: JsonValue) = apply { this.data = data } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun profile(profile: JsonValue) = apply { this.profile = profile } + + fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + fun to(to: UserRecipient?) = to(JsonField.ofNullable(to)) + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.getOrNull()) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [UserRecipient] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun to(to: JsonField) = apply { this.to = to } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundBulkMessageUser]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboundBulkMessageUser = + InboundBulkMessageUser( + data, + preferences, + profile, + recipient, + to, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundBulkMessageUser = apply { + if (validated) { + return@apply + } + + preferences().ifPresent { it.validate() } + recipient() + to().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (to.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundBulkMessageUser && + data == other.data && + preferences == other.preferences && + profile == other.profile && + recipient == other.recipient && + to == other.to && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, preferences, profile, recipient, to, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundBulkMessageUser{data=$data, preferences=$preferences, profile=$profile, recipient=$recipient, to=$to, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt new file mode 100644 index 00000000..4514b207 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt @@ -0,0 +1,1046 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.send.MessageContext +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UserRecipient +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accountId: JsonField, + private val context: JsonField, + private val data: JsonField, + private val email: JsonField, + private val locale: JsonField, + private val phoneNumber: JsonField, + private val preferences: JsonField, + private val tenantId: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("locale") @ExcludeMissing locale: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + ) : this( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + mutableMapOf(), + ) + + /** + * Use `tenant_id` instad. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountId(): Optional = accountId.getOptional("account_id") + + /** + * Context information such as tenant_id to send the notification with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * The user's preferred ISO 639-1 language code. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locale(): Optional = locale.getOptional("locale") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * An id of a tenant, [see tenants api docs](https://www.courier.com/docs/reference/tenants). + * Will load brand, default preferences and any other base context data associated with this + * tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tenantId(): Optional = tenantId.getOptional("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("user_id") + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [locale]. + * + * Unlike [locale], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UserRecipient]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserRecipient]. */ + class Builder internal constructor() { + + private var accountId: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var locale: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var tenantId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userRecipient: UserRecipient) = apply { + accountId = userRecipient.accountId + context = userRecipient.context + data = userRecipient.data + email = userRecipient.email + locale = userRecipient.locale + phoneNumber = userRecipient.phoneNumber + preferences = userRecipient.preferences + tenantId = userRecipient.tenantId + userId = userRecipient.userId + additionalProperties = userRecipient.additionalProperties.toMutableMap() + } + + /** Use `tenant_id` instad. */ + fun accountId(accountId: String?) = accountId(JsonField.ofNullable(accountId)) + + /** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */ + fun accountId(accountId: Optional) = accountId(accountId.getOrNull()) + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountId(accountId: JsonField) = apply { this.accountId = accountId } + + /** Context information such as tenant_id to send the notification with. */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** The user's preferred ISO 639-1 language code. */ + fun locale(locale: String?) = locale(JsonField.ofNullable(locale)) + + /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ + fun locale(locale: Optional) = locale(locale.getOrNull()) + + /** + * Sets [Builder.locale] to an arbitrary JSON value. + * + * You should usually call [Builder.locale] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun locale(locale: JsonField) = apply { this.locale = locale } + + fun phoneNumber(phoneNumber: String?) = phoneNumber(JsonField.ofNullable(phoneNumber)) + + /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ + fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.getOrNull()) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } + + fun preferences(preferences: Preferences?) = preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [Preferences] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** + * An id of a tenant, + * [see tenants api docs](https://www.courier.com/docs/reference/tenants). Will load brand, + * default preferences and any other base context data associated with this tenant. + */ + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserRecipient = + UserRecipient( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserRecipient = apply { + if (validated) { + return@apply + } + + accountId() + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + email() + locale() + phoneNumber() + preferences().ifPresent { it.validate() } + tenantId() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountId.asKnown().isPresent) 1 else 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (locale.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Preferences + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val notifications: JsonField, + private val categories: JsonField, + private val templateId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("notifications") + @ExcludeMissing + notifications: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField = JsonMissing.of(), + @JsonProperty("templateId") + @ExcludeMissing + templateId: JsonField = JsonMissing.of(), + ) : this(notifications, categories, templateId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun notifications(): Notifications = notifications.getRequired("notifications") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun categories(): Optional = categories.getOptional("categories") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun templateId(): Optional = templateId.getOptional("templateId") + + /** + * Returns the raw JSON value of [notifications]. + * + * Unlike [notifications], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("notifications") + @ExcludeMissing + fun _notifications(): JsonField = notifications + + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories + + /** + * Returns the raw JSON value of [templateId]. + * + * Unlike [templateId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("templateId") + @ExcludeMissing + fun _templateId(): JsonField = templateId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Preferences]. + * + * The following fields are required: + * ```java + * .notifications() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Preferences]. */ + class Builder internal constructor() { + + private var notifications: JsonField? = null + private var categories: JsonField = JsonMissing.of() + private var templateId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferences: Preferences) = apply { + notifications = preferences.notifications + categories = preferences.categories + templateId = preferences.templateId + additionalProperties = preferences.additionalProperties.toMutableMap() + } + + fun notifications(notifications: Notifications) = + notifications(JsonField.of(notifications)) + + /** + * Sets [Builder.notifications] to an arbitrary JSON value. + * + * You should usually call [Builder.notifications] with a well-typed [Notifications] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun notifications(notifications: JsonField) = apply { + this.notifications = notifications + } + + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ + fun categories(categories: Optional) = categories(categories.getOrNull()) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun categories(categories: JsonField) = apply { + this.categories = categories + } + + fun templateId(templateId: String?) = templateId(JsonField.ofNullable(templateId)) + + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) + + /** + * Sets [Builder.templateId] to an arbitrary JSON value. + * + * You should usually call [Builder.templateId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun templateId(templateId: JsonField) = apply { this.templateId = templateId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Preferences]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .notifications() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Preferences = + Preferences( + checkRequired("notifications", notifications), + categories, + templateId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Preferences = apply { + if (validated) { + return@apply + } + + notifications().validate() + categories().ifPresent { it.validate() } + templateId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (notifications.asKnown().getOrNull()?.validity() ?: 0) + + (categories.asKnown().getOrNull()?.validity() ?: 0) + + (if (templateId.asKnown().isPresent) 1 else 0) + + class Notifications + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Notifications]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Notifications]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notifications: Notifications) = apply { + additionalProperties = notifications.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Notifications]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Notifications = Notifications(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Notifications = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Notifications && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Notifications{additionalProperties=$additionalProperties}" + } + + class Categories + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Categories]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Categories]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(categories: Categories) = apply { + additionalProperties = categories.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Categories]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Categories = Categories(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Categories = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Categories && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Categories{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Preferences && + notifications == other.notifications && + categories == other.categories && + templateId == other.templateId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(notifications, categories, templateId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Preferences{notifications=$notifications, categories=$categories, templateId=$templateId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserRecipient && + accountId == other.accountId && + context == other.context && + data == other.data && + email == other.email && + locale == other.locale && + phoneNumber == other.phoneNumber && + preferences == other.preferences && + tenantId == other.tenantId && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserRecipient{accountId=$accountId, context=$context, data=$data, email=$email, locale=$locale, phoneNumber=$phoneNumber, preferences=$preferences, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt new file mode 100644 index 00000000..3bba25fb --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt @@ -0,0 +1,925 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.inbound + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Courier Track Event */ +class InboundTrackEventParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * A descriptive name of the event. This name will appear as a trigger in the Courier Automation + * Trigger node. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun event(): String = body.event() + + /** + * A required unique identifier that will be used to de-duplicate requests. If not unique, will + * respond with 409 Conflict status + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageId(): String = body.messageId() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun properties(): Properties = body.properties() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = body.type() + + /** + * The user id associated with the track + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userId(): Optional = body.userId() + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _event(): JsonField = body._event() + + /** + * Returns the raw JSON value of [messageId]. + * + * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _messageId(): JsonField = body._messageId() + + /** + * Returns the raw JSON value of [properties]. + * + * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _properties(): JsonField = body._properties() + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _type(): JsonField = body._type() + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _userId(): JsonField = body._userId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboundTrackEventParams]. + * + * The following fields are required: + * ```java + * .event() + * .messageId() + * .properties() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundTrackEventParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inboundTrackEventParams: InboundTrackEventParams) = apply { + body = inboundTrackEventParams.body.toBuilder() + additionalHeaders = inboundTrackEventParams.additionalHeaders.toBuilder() + additionalQueryParams = inboundTrackEventParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [event] + * - [messageId] + * - [properties] + * - [type] + * - [userId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * A descriptive name of the event. This name will appear as a trigger in the Courier + * Automation Trigger node. + */ + fun event(event: String) = apply { body.event(event) } + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun event(event: JsonField) = apply { body.event(event) } + + /** + * A required unique identifier that will be used to de-duplicate requests. If not unique, + * will respond with 409 Conflict status + */ + fun messageId(messageId: String) = apply { body.messageId(messageId) } + + /** + * Sets [Builder.messageId] to an arbitrary JSON value. + * + * You should usually call [Builder.messageId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun messageId(messageId: JsonField) = apply { body.messageId(messageId) } + + fun properties(properties: Properties) = apply { body.properties(properties) } + + /** + * Sets [Builder.properties] to an arbitrary JSON value. + * + * You should usually call [Builder.properties] with a well-typed [Properties] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun properties(properties: JsonField) = apply { body.properties(properties) } + + fun type(type: Type) = apply { body.type(type) } + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { body.type(type) } + + /** The user id associated with the track */ + fun userId(userId: String?) = apply { body.userId(userId) } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { body.userId(userId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InboundTrackEventParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .event() + * .messageId() + * .properties() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboundTrackEventParams = + InboundTrackEventParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val event: JsonField, + private val messageId: JsonField, + private val properties: JsonField, + private val type: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("messageId") + @ExcludeMissing + messageId: JsonField = JsonMissing.of(), + @JsonProperty("properties") + @ExcludeMissing + properties: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("userId") @ExcludeMissing userId: JsonField = JsonMissing.of(), + ) : this(event, messageId, properties, type, userId, mutableMapOf()) + + /** + * A descriptive name of the event. This name will appear as a trigger in the Courier + * Automation Trigger node. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun event(): String = event.getRequired("event") + + /** + * A required unique identifier that will be used to de-duplicate requests. If not unique, + * will respond with 409 Conflict status + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageId(): String = messageId.getRequired("messageId") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun properties(): Properties = properties.getRequired("properties") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * The user id associated with the track + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("userId") + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [messageId]. + * + * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId + + /** + * Returns the raw JSON value of [properties]. + * + * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("properties") + @ExcludeMissing + fun _properties(): JsonField = properties + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("userId") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .event() + * .messageId() + * .properties() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var event: JsonField? = null + private var messageId: JsonField? = null + private var properties: JsonField? = null + private var type: JsonField? = null + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + event = body.event + messageId = body.messageId + properties = body.properties + type = body.type + userId = body.userId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * A descriptive name of the event. This name will appear as a trigger in the Courier + * Automation Trigger node. + */ + fun event(event: String) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + /** + * A required unique identifier that will be used to de-duplicate requests. If not + * unique, will respond with 409 Conflict status + */ + fun messageId(messageId: String) = messageId(JsonField.of(messageId)) + + /** + * Sets [Builder.messageId] to an arbitrary JSON value. + * + * You should usually call [Builder.messageId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messageId(messageId: JsonField) = apply { this.messageId = messageId } + + fun properties(properties: Properties) = properties(JsonField.of(properties)) + + /** + * Sets [Builder.properties] to an arbitrary JSON value. + * + * You should usually call [Builder.properties] with a well-typed [Properties] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun properties(properties: JsonField) = apply { + this.properties = properties + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The user id associated with the track */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .event() + * .messageId() + * .properties() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("event", event), + checkRequired("messageId", messageId), + checkRequired("properties", properties), + checkRequired("type", type), + userId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + event() + messageId() + properties().validate() + type().validate() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (event.asKnown().isPresent) 1 else 0) + + (if (messageId.asKnown().isPresent) 1 else 0) + + (properties.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + event == other.event && + messageId == other.messageId && + properties == other.properties && + type == other.type && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(event, messageId, properties, type, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{event=$event, messageId=$messageId, properties=$properties, type=$type, userId=$userId, additionalProperties=$additionalProperties}" + } + + class Properties + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Properties]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Properties]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(properties: Properties) = apply { + additionalProperties = properties.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Properties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Properties = Properties(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Properties = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Properties && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Properties{additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TRACK = of("track") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TRACK + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TRACK, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TRACK -> Value.TRACK + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TRACK -> Known.TRACK + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundTrackEventParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InboundTrackEventParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt new file mode 100644 index 00000000..0021c852 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt @@ -0,0 +1,177 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.inbound + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class InboundTrackEventResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val messageId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("messageId") @ExcludeMissing messageId: JsonField = JsonMissing.of() + ) : this(messageId, mutableMapOf()) + + /** + * A successful call returns a `202` status code along with a `requestId` in the response body. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun messageId(): String = messageId.getRequired("messageId") + + /** + * Returns the raw JSON value of [messageId]. + * + * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboundTrackEventResponse]. + * + * The following fields are required: + * ```java + * .messageId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboundTrackEventResponse]. */ + class Builder internal constructor() { + + private var messageId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboundTrackEventResponse: InboundTrackEventResponse) = apply { + messageId = inboundTrackEventResponse.messageId + additionalProperties = inboundTrackEventResponse.additionalProperties.toMutableMap() + } + + /** + * A successful call returns a `202` status code along with a `requestId` in the response + * body. + */ + fun messageId(messageId: String) = messageId(JsonField.of(messageId)) + + /** + * Sets [Builder.messageId] to an arbitrary JSON value. + * + * You should usually call [Builder.messageId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun messageId(messageId: JsonField) = apply { this.messageId = messageId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboundTrackEventResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .messageId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboundTrackEventResponse = + InboundTrackEventResponse( + checkRequired("messageId", messageId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboundTrackEventResponse = apply { + if (validated) { + return@apply + } + + messageId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (messageId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboundTrackEventResponse && + messageId == other.messageId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(messageId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboundTrackEventResponse{messageId=$messageId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt new file mode 100644 index 00000000..8d0f1d60 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class List +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val created: JsonField, + private val updated: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), + @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), + ) : this(id, name, created, updated, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun updated(): Optional = updated.getOptional("updated") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var created: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + id = list.id + name = list.name + created = list.created + updated = list.updated + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun created(created: Long?) = created(JsonField.ofNullable(created)) + + /** + * Alias for [Builder.created]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun created(created: Long) = created(created as Long?) + + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ + fun created(created: Optional) = created(created.getOrNull()) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun updated(updated: Long?) = updated(JsonField.ofNullable(updated)) + + /** + * Alias for [Builder.updated]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun updated(updated: Long) = updated(updated as Long?) + + /** Alias for calling [Builder.updated] with `updated.orElse(null)`. */ + fun updated(updated: Optional) = updated(updated.getOrNull()) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("id", id), + checkRequired("name", name), + created, + updated, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + id() + name() + created() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is List && + id == other.id && + name == other.name && + created == other.created && + updated == other.updated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, name, created, updated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{id=$id, name=$name, created=$created, updated=$updated, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt new file mode 100644 index 00000000..d528739e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a list by list ID. */ +class ListDeleteParams +private constructor( + private val listId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ListDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ListDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListDeleteParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listDeleteParams: ListDeleteParams) = apply { + listId = listDeleteParams.listId + additionalHeaders = listDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = listDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = listDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ListDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ListDeleteParams = + ListDeleteParams( + listId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListDeleteParams && + listId == other.listId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(listId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ListDeleteParams{listId=$listId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt new file mode 100644 index 00000000..ed5ba28a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns all of the lists, with the ability to filter based on a pattern. */ +class ListListParams +private constructor( + private val cursor: String?, + private val pattern: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** A unique identifier that allows for fetching the next page of lists. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** + * "A pattern used to filter the list items returned. Pattern types supported: exact match on + * `list_id` or a pattern of one or more pattern parts. you may replace a part with either: `*` + * to match all parts in that position, or `**` to signify a wildcard `endsWith` pattern match." + */ + fun pattern(): Optional = Optional.ofNullable(pattern) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ListListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ListListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var pattern: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(listListParams: ListListParams) = apply { + cursor = listListParams.cursor + pattern = listListParams.pattern + additionalHeaders = listListParams.additionalHeaders.toBuilder() + additionalQueryParams = listListParams.additionalQueryParams.toBuilder() + } + + /** A unique identifier that allows for fetching the next page of lists. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * "A pattern used to filter the list items returned. Pattern types supported: exact match + * on `list_id` or a pattern of one or more pattern parts. you may replace a part with + * either: `*` to match all parts in that position, or `**` to signify a wildcard `endsWith` + * pattern match." + */ + fun pattern(pattern: String?) = apply { this.pattern = pattern } + + /** Alias for calling [Builder.pattern] with `pattern.orElse(null)`. */ + fun pattern(pattern: Optional) = pattern(pattern.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ListListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ListListParams = + ListListParams( + cursor, + pattern, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + pattern?.let { put("pattern", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListListParams && + cursor == other.cursor && + pattern == other.pattern && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, pattern, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ListListParams{cursor=$cursor, pattern=$pattern, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt new file mode 100644 index 00000000..f7c1b69f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ListListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListListResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listListResponse: ListListResponse) = apply { + items = listListResponse.items.map { it.toMutableList() } + paging = listListResponse.paging + additionalProperties = listListResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: List) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ListListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListListResponse = + ListListResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListListResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt new file mode 100644 index 00000000..6a9060ed --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Restore a previously deleted list. */ +class ListRestoreParams +private constructor( + private val listId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ListRestoreParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ListRestoreParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRestoreParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listRestoreParams: ListRestoreParams) = apply { + listId = listRestoreParams.listId + additionalHeaders = listRestoreParams.additionalHeaders.toBuilder() + additionalQueryParams = listRestoreParams.additionalQueryParams.toBuilder() + additionalBodyProperties = listRestoreParams.additionalBodyProperties.toMutableMap() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ListRestoreParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ListRestoreParams = + ListRestoreParams( + listId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListRestoreParams && + listId == other.listId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(listId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ListRestoreParams{listId=$listId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt new file mode 100644 index 00000000..dfafc11c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns a list based on the list ID provided. */ +class ListRetrieveParams +private constructor( + private val listId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ListRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ListRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRetrieveParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(listRetrieveParams: ListRetrieveParams) = apply { + listId = listRetrieveParams.listId + additionalHeaders = listRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = listRetrieveParams.additionalQueryParams.toBuilder() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ListRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ListRetrieveParams = + ListRetrieveParams(listId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListRetrieveParams && + listId == other.listId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(listId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ListRetrieveParams{listId=$listId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt new file mode 100644 index 00000000..e6d72757 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt @@ -0,0 +1,508 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create or replace an existing list with the supplied values. */ +class ListUpdateParams +private constructor( + private val listId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = body.preferences() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _preferences(): JsonField = body._preferences() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListUpdateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListUpdateParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(listUpdateParams: ListUpdateParams) = apply { + listId = listUpdateParams.listId + body = listUpdateParams.body.toBuilder() + additionalHeaders = listUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = listUpdateParams.additionalQueryParams.toBuilder() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [preferences] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + fun preferences(preferences: RecipientPreferences?) = apply { + body.preferences(preferences) + } + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + body.preferences(preferences) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ListUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListUpdateParams = + ListUpdateParams( + listId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val preferences: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + ) : this(name, preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + preferences = body.preferences + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [RecipientPreferences] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("name", name), preferences, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, preferences, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, preferences=$preferences, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListUpdateParams && + listId == other.listId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(listId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ListUpdateParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt new file mode 100644 index 00000000..6f14ed16 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PutSubscriptionsRecipient +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val recipientId: JsonField, + private val preferences: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("recipientId") + @ExcludeMissing + recipientId: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + ) : this(recipientId, preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipientId(): String = recipientId.getRequired("recipientId") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [recipientId]. + * + * Unlike [recipientId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipientId") @ExcludeMissing fun _recipientId(): JsonField = recipientId + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PutSubscriptionsRecipient]. + * + * The following fields are required: + * ```java + * .recipientId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PutSubscriptionsRecipient]. */ + class Builder internal constructor() { + + private var recipientId: JsonField? = null + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(putSubscriptionsRecipient: PutSubscriptionsRecipient) = apply { + recipientId = putSubscriptionsRecipient.recipientId + preferences = putSubscriptionsRecipient.preferences + additionalProperties = putSubscriptionsRecipient.additionalProperties.toMutableMap() + } + + fun recipientId(recipientId: String) = recipientId(JsonField.of(recipientId)) + + /** + * Sets [Builder.recipientId] to an arbitrary JSON value. + * + * You should usually call [Builder.recipientId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipientId(recipientId: JsonField) = apply { this.recipientId = recipientId } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PutSubscriptionsRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recipientId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PutSubscriptionsRecipient = + PutSubscriptionsRecipient( + checkRequired("recipientId", recipientId), + preferences, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PutSubscriptionsRecipient = apply { + if (validated) { + return@apply + } + + recipientId() + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (recipientId.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PutSubscriptionsRecipient && + recipientId == other.recipientId && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(recipientId, preferences, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PutSubscriptionsRecipient{recipientId=$recipientId, preferences=$preferences, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt new file mode 100644 index 00000000..227752b7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt @@ -0,0 +1,407 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RecipientPreferences +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val categories: JsonField, + private val notifications: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField = JsonMissing.of(), + @JsonProperty("notifications") + @ExcludeMissing + notifications: JsonField = JsonMissing.of(), + ) : this(categories, notifications, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun categories(): Optional = categories.getOptional("categories") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun notifications(): Optional = notifications.getOptional("notifications") + + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories + + /** + * Returns the raw JSON value of [notifications]. + * + * Unlike [notifications], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("notifications") + @ExcludeMissing + fun _notifications(): JsonField = notifications + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RecipientPreferences]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecipientPreferences]. */ + class Builder internal constructor() { + + private var categories: JsonField = JsonMissing.of() + private var notifications: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recipientPreferences: RecipientPreferences) = apply { + categories = recipientPreferences.categories + notifications = recipientPreferences.notifications + additionalProperties = recipientPreferences.additionalProperties.toMutableMap() + } + + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) + + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ + fun categories(categories: Optional) = categories(categories.getOrNull()) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun categories(categories: JsonField) = apply { this.categories = categories } + + fun notifications(notifications: Notifications?) = + notifications(JsonField.ofNullable(notifications)) + + /** Alias for calling [Builder.notifications] with `notifications.orElse(null)`. */ + fun notifications(notifications: Optional) = + notifications(notifications.getOrNull()) + + /** + * Sets [Builder.notifications] to an arbitrary JSON value. + * + * You should usually call [Builder.notifications] with a well-typed [Notifications] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun notifications(notifications: JsonField) = apply { + this.notifications = notifications + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecipientPreferences]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RecipientPreferences = + RecipientPreferences(categories, notifications, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): RecipientPreferences = apply { + if (validated) { + return@apply + } + + categories().ifPresent { it.validate() } + notifications().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (categories.asKnown().getOrNull()?.validity() ?: 0) + + (notifications.asKnown().getOrNull()?.validity() ?: 0) + + class Categories + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Categories]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Categories]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(categories: Categories) = apply { + additionalProperties = categories.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Categories]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Categories = Categories(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Categories = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Categories && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Categories{additionalProperties=$additionalProperties}" + } + + class Notifications + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Notifications]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Notifications]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notifications: Notifications) = apply { + additionalProperties = notifications.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Notifications]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Notifications = Notifications(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Notifications = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Notifications && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Notifications{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecipientPreferences && + categories == other.categories && + notifications == other.notifications && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(categories, notifications, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RecipientPreferences{categories=$categories, notifications=$notifications, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt new file mode 100644 index 00000000..e53154a4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt @@ -0,0 +1,473 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Subscribes additional users to the list, without modifying existing subscriptions. If the list + * does not exist, it will be automatically created. + */ +class SubscriptionAddParams +private constructor( + private val listId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipients(): List = body.recipients() + + /** + * Returns the raw JSON value of [recipients]. + * + * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _recipients(): JsonField> = body._recipients() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionAddParams]. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionAddParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(subscriptionAddParams: SubscriptionAddParams) = apply { + listId = subscriptionAddParams.listId + body = subscriptionAddParams.body.toBuilder() + additionalHeaders = subscriptionAddParams.additionalHeaders.toBuilder() + additionalQueryParams = subscriptionAddParams.additionalQueryParams.toBuilder() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [recipients] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun recipients(recipients: List) = apply { + body.recipients(recipients) + } + + /** + * Sets [Builder.recipients] to an arbitrary JSON value. + * + * You should usually call [Builder.recipients] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun recipients(recipients: JsonField>) = apply { + body.recipients(recipients) + } + + /** + * Adds a single [PutSubscriptionsRecipient] to [recipients]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { + body.addRecipient(recipient) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SubscriptionAddParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionAddParams = + SubscriptionAddParams( + listId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val recipients: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("recipients") + @ExcludeMissing + recipients: JsonField> = JsonMissing.of() + ) : this(recipients, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipients(): List = recipients.getRequired("recipients") + + /** + * Returns the raw JSON value of [recipients]. + * + * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipients") + @ExcludeMissing + fun _recipients(): JsonField> = recipients + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var recipients: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + recipients = body.recipients.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun recipients(recipients: List) = + recipients(JsonField.of(recipients)) + + /** + * Sets [Builder.recipients] to an arbitrary JSON value. + * + * You should usually call [Builder.recipients] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun recipients(recipients: JsonField>) = apply { + this.recipients = recipients.map { it.toMutableList() } + } + + /** + * Adds a single [PutSubscriptionsRecipient] to [recipients]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { + recipients = + (recipients ?: JsonField.of(mutableListOf())).also { + checkKnown("recipients", it).add(recipient) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("recipients", recipients).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + recipients().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (recipients.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + recipients == other.recipients && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(recipients, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{recipients=$recipients, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionAddParams && + listId == other.listId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(listId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SubscriptionAddParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt new file mode 100644 index 00000000..d0b88e1f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get the list's subscriptions. */ +class SubscriptionListParams +private constructor( + private val listId: String?, + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** A unique identifier that allows for fetching the next set of list subscriptions */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): SubscriptionListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SubscriptionListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionListParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(subscriptionListParams: SubscriptionListParams) = apply { + listId = subscriptionListParams.listId + cursor = subscriptionListParams.cursor + additionalHeaders = subscriptionListParams.additionalHeaders.toBuilder() + additionalQueryParams = subscriptionListParams.additionalQueryParams.toBuilder() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + /** A unique identifier that allows for fetching the next set of list subscriptions */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SubscriptionListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SubscriptionListParams = + SubscriptionListParams( + listId, + cursor, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionListParams && + listId == other.listId && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(listId, cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SubscriptionListParams{listId=$listId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt new file mode 100644 index 00000000..3fc3f033 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt @@ -0,0 +1,467 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SubscriptionListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionListResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionListResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionListResponse: SubscriptionListResponse) = apply { + items = subscriptionListResponse.items.map { it.toMutableList() } + paging = subscriptionListResponse.paging + additionalProperties = subscriptionListResponse.additionalProperties.toMutableMap() + } + + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionListResponse = + SubscriptionListResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubscriptionListResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val recipientId: JsonField, + private val created: JsonField, + private val preferences: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("recipientId") + @ExcludeMissing + recipientId: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + ) : this(recipientId, created, preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipientId(): String = recipientId.getRequired("recipientId") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun created(): Optional = created.getOptional("created") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [recipientId]. + * + * Unlike [recipientId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipientId") + @ExcludeMissing + fun _recipientId(): JsonField = recipientId + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .recipientId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var recipientId: JsonField? = null + private var created: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + recipientId = item.recipientId + created = item.created + preferences = item.preferences + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun recipientId(recipientId: String) = recipientId(JsonField.of(recipientId)) + + /** + * Sets [Builder.recipientId] to an arbitrary JSON value. + * + * You should usually call [Builder.recipientId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun recipientId(recipientId: JsonField) = apply { + this.recipientId = recipientId + } + + fun created(created: String?) = created(JsonField.ofNullable(created)) + + /** Alias for calling [Builder.created] with `created.orElse(null)`. */ + fun created(created: Optional) = created(created.getOrNull()) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [RecipientPreferences] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recipientId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("recipientId", recipientId), + created, + preferences, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + recipientId() + created() + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (recipientId.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + recipientId == other.recipientId && + created == other.created && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(recipientId, created, preferences, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{recipientId=$recipientId, created=$created, preferences=$preferences, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionListResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt new file mode 100644 index 00000000..3e5e4186 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt @@ -0,0 +1,473 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Subscribes the users to the list, overwriting existing subscriptions. If the list does not exist, + * it will be automatically created. + */ +class SubscriptionSubscribeParams +private constructor( + private val listId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun listId(): Optional = Optional.ofNullable(listId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipients(): List = body.recipients() + + /** + * Returns the raw JSON value of [recipients]. + * + * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _recipients(): JsonField> = body._recipients() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionSubscribeParams]. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionSubscribeParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(subscriptionSubscribeParams: SubscriptionSubscribeParams) = apply { + listId = subscriptionSubscribeParams.listId + body = subscriptionSubscribeParams.body.toBuilder() + additionalHeaders = subscriptionSubscribeParams.additionalHeaders.toBuilder() + additionalQueryParams = subscriptionSubscribeParams.additionalQueryParams.toBuilder() + } + + fun listId(listId: String?) = apply { this.listId = listId } + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [recipients] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun recipients(recipients: List) = apply { + body.recipients(recipients) + } + + /** + * Sets [Builder.recipients] to an arbitrary JSON value. + * + * You should usually call [Builder.recipients] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun recipients(recipients: JsonField>) = apply { + body.recipients(recipients) + } + + /** + * Adds a single [PutSubscriptionsRecipient] to [recipients]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { + body.addRecipient(recipient) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SubscriptionSubscribeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionSubscribeParams = + SubscriptionSubscribeParams( + listId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val recipients: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("recipients") + @ExcludeMissing + recipients: JsonField> = JsonMissing.of() + ) : this(recipients, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipients(): List = recipients.getRequired("recipients") + + /** + * Returns the raw JSON value of [recipients]. + * + * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipients") + @ExcludeMissing + fun _recipients(): JsonField> = recipients + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var recipients: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + recipients = body.recipients.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun recipients(recipients: List) = + recipients(JsonField.of(recipients)) + + /** + * Sets [Builder.recipients] to an arbitrary JSON value. + * + * You should usually call [Builder.recipients] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun recipients(recipients: JsonField>) = apply { + this.recipients = recipients.map { it.toMutableList() } + } + + /** + * Adds a single [PutSubscriptionsRecipient] to [recipients]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { + recipients = + (recipients ?: JsonField.of(mutableListOf())).also { + checkKnown("recipients", it).add(recipient) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .recipients() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("recipients", recipients).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + recipients().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (recipients.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + recipients == other.recipients && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(recipients, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{recipients=$recipients, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionSubscribeParams && + listId == other.listId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(listId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SubscriptionSubscribeParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt new file mode 100644 index 00000000..c646c26c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt @@ -0,0 +1,452 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Subscribe a user to an existing list (note: if the List does not exist, it will be automatically + * created). + */ +class SubscriptionSubscribeUserParams +private constructor( + private val listId: String, + private val userId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun listId(): String = listId + + fun userId(): Optional = Optional.ofNullable(userId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = body.preferences() + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _preferences(): JsonField = body._preferences() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionSubscribeUserParams]. + * + * The following fields are required: + * ```java + * .listId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionSubscribeUserParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var userId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(subscriptionSubscribeUserParams: SubscriptionSubscribeUserParams) = + apply { + listId = subscriptionSubscribeUserParams.listId + userId = subscriptionSubscribeUserParams.userId + body = subscriptionSubscribeUserParams.body.toBuilder() + additionalHeaders = subscriptionSubscribeUserParams.additionalHeaders.toBuilder() + additionalQueryParams = + subscriptionSubscribeUserParams.additionalQueryParams.toBuilder() + } + + fun listId(listId: String) = apply { this.listId = listId } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [preferences] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun preferences(preferences: RecipientPreferences?) = apply { + body.preferences(preferences) + } + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + body.preferences(preferences) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SubscriptionSubscribeUserParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .listId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionSubscribeUserParams = + SubscriptionSubscribeUserParams( + checkRequired("listId", listId), + userId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId + 1 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val preferences: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of() + ) : this(preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + preferences = body.preferences + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [RecipientPreferences] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(preferences, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (preferences.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(preferences, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{preferences=$preferences, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionSubscribeUserParams && + listId == other.listId && + userId == other.userId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(listId, userId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SubscriptionSubscribeUserParams{listId=$listId, userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt new file mode 100644 index 00000000..32972d56 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a subscription to a list by list ID and user ID. */ +class SubscriptionUnsubscribeUserParams +private constructor( + private val listId: String, + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun listId(): String = listId + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SubscriptionUnsubscribeUserParams]. + * + * The following fields are required: + * ```java + * .listId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionUnsubscribeUserParams]. */ + class Builder internal constructor() { + + private var listId: String? = null + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionUnsubscribeUserParams: SubscriptionUnsubscribeUserParams) = + apply { + listId = subscriptionUnsubscribeUserParams.listId + userId = subscriptionUnsubscribeUserParams.userId + additionalHeaders = subscriptionUnsubscribeUserParams.additionalHeaders.toBuilder() + additionalQueryParams = + subscriptionUnsubscribeUserParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + subscriptionUnsubscribeUserParams.additionalBodyProperties.toMutableMap() + } + + fun listId(listId: String) = apply { this.listId = listId } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [SubscriptionUnsubscribeUserParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .listId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionUnsubscribeUserParams = + SubscriptionUnsubscribeUserParams( + checkRequired("listId", listId), + userId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> listId + 1 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionUnsubscribeUserParams && + listId == other.listId && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + listId, + userId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "SubscriptionUnsubscribeUserParams{listId=$listId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt new file mode 100644 index 00000000..20b8d109 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Cancel a message that is currently in the process of being delivered. A well-formatted API call + * to the cancel message API will return either `200` status code for a successful cancellation or + * `409` status code for an unsuccessful cancellation. Both cases will include the actual message + * record in the response body (see details below). + */ +class MessageCancelParams +private constructor( + private val messageId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun messageId(): Optional = Optional.ofNullable(messageId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MessageCancelParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageCancelParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageCancelParams]. */ + class Builder internal constructor() { + + private var messageId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageCancelParams: MessageCancelParams) = apply { + messageId = messageCancelParams.messageId + additionalHeaders = messageCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = messageCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = messageCancelParams.additionalBodyProperties.toMutableMap() + } + + fun messageId(messageId: String?) = apply { this.messageId = messageId } + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [MessageCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageCancelParams = + MessageCancelParams( + messageId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> messageId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageCancelParams && + messageId == other.messageId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(messageId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "MessageCancelParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt new file mode 100644 index 00000000..62e8c4b7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt @@ -0,0 +1,991 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class MessageDetails +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val clicked: JsonField, + private val delivered: JsonField, + private val enqueued: JsonField, + private val event: JsonField, + private val notification: JsonField, + private val opened: JsonField, + private val recipient: JsonField, + private val sent: JsonField, + private val status: JsonField, + private val error: JsonField, + private val reason: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("clicked") @ExcludeMissing clicked: JsonField = JsonMissing.of(), + @JsonProperty("delivered") @ExcludeMissing delivered: JsonField = JsonMissing.of(), + @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("notification") + @ExcludeMissing + notification: JsonField = JsonMissing.of(), + @JsonProperty("opened") @ExcludeMissing opened: JsonField = JsonMissing.of(), + @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), + @JsonProperty("sent") @ExcludeMissing sent: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + ) : this( + id, + clicked, + delivered, + enqueued, + event, + notification, + opened, + recipient, + sent, + status, + error, + reason, + mutableMapOf(), + ) + + /** + * A unique identifier associated with the message you wish to retrieve (results from a send). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored + * as a millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun clicked(): Long = clicked.getRequired("clicked") + + /** + * A UTC timestamp at which the Integration provider delivered the message. Stored as a + * millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun delivered(): Long = delivered.getRequired("delivered") + + /** + * A UTC timestamp at which Courier received the message request. Stored as a millisecond + * representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun enqueued(): Long = enqueued.getRequired("enqueued") + + /** + * A unique identifier associated with the event of the delivered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun event(): String = event.getRequired("event") + + /** + * A unique identifier associated with the notification of the delivered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun notification(): String = notification.getRequired("notification") + + /** + * A UTC timestamp at which the recipient opened a message for the first time. Stored as a + * millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun opened(): Long = opened.getRequired("opened") + + /** + * A unique identifier associated with the recipient of the delivered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipient(): String = recipient.getRequired("recipient") + + /** + * A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a + * millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sent(): Long = sent.getRequired("sent") + + /** + * The current status of the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * A message describing the error that occurred. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * The reason for the current status of the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [clicked]. + * + * Unlike [clicked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clicked") @ExcludeMissing fun _clicked(): JsonField = clicked + + /** + * Returns the raw JSON value of [delivered]. + * + * Unlike [delivered], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delivered") @ExcludeMissing fun _delivered(): JsonField = delivered + + /** + * Returns the raw JSON value of [enqueued]. + * + * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [notification]. + * + * Unlike [notification], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("notification") + @ExcludeMissing + fun _notification(): JsonField = notification + + /** + * Returns the raw JSON value of [opened]. + * + * Unlike [opened], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("opened") @ExcludeMissing fun _opened(): JsonField = opened + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [sent]. + * + * Unlike [sent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sent") @ExcludeMissing fun _sent(): JsonField = sent + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageDetails]. + * + * The following fields are required: + * ```java + * .id() + * .clicked() + * .delivered() + * .enqueued() + * .event() + * .notification() + * .opened() + * .recipient() + * .sent() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageDetails]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var clicked: JsonField? = null + private var delivered: JsonField? = null + private var enqueued: JsonField? = null + private var event: JsonField? = null + private var notification: JsonField? = null + private var opened: JsonField? = null + private var recipient: JsonField? = null + private var sent: JsonField? = null + private var status: JsonField? = null + private var error: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageDetails: MessageDetails) = apply { + id = messageDetails.id + clicked = messageDetails.clicked + delivered = messageDetails.delivered + enqueued = messageDetails.enqueued + event = messageDetails.event + notification = messageDetails.notification + opened = messageDetails.opened + recipient = messageDetails.recipient + sent = messageDetails.sent + status = messageDetails.status + error = messageDetails.error + reason = messageDetails.reason + additionalProperties = messageDetails.additionalProperties.toMutableMap() + } + + /** + * A unique identifier associated with the message you wish to retrieve (results from a + * send). + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * A UTC timestamp at which the recipient clicked on a tracked link for the first time. + * Stored as a millisecond representation of the Unix epoch. + */ + fun clicked(clicked: Long) = clicked(JsonField.of(clicked)) + + /** + * Sets [Builder.clicked] to an arbitrary JSON value. + * + * You should usually call [Builder.clicked] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun clicked(clicked: JsonField) = apply { this.clicked = clicked } + + /** + * A UTC timestamp at which the Integration provider delivered the message. Stored as a + * millisecond representation of the Unix epoch. + */ + fun delivered(delivered: Long) = delivered(JsonField.of(delivered)) + + /** + * Sets [Builder.delivered] to an arbitrary JSON value. + * + * You should usually call [Builder.delivered] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delivered(delivered: JsonField) = apply { this.delivered = delivered } + + /** + * A UTC timestamp at which Courier received the message request. Stored as a millisecond + * representation of the Unix epoch. + */ + fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) + + /** + * Sets [Builder.enqueued] to an arbitrary JSON value. + * + * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } + + /** A unique identifier associated with the event of the delivered message. */ + fun event(event: String) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + /** A unique identifier associated with the notification of the delivered message. */ + fun notification(notification: String) = notification(JsonField.of(notification)) + + /** + * Sets [Builder.notification] to an arbitrary JSON value. + * + * You should usually call [Builder.notification] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun notification(notification: JsonField) = apply { + this.notification = notification + } + + /** + * A UTC timestamp at which the recipient opened a message for the first time. Stored as a + * millisecond representation of the Unix epoch. + */ + fun opened(opened: Long) = opened(JsonField.of(opened)) + + /** + * Sets [Builder.opened] to an arbitrary JSON value. + * + * You should usually call [Builder.opened] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun opened(opened: JsonField) = apply { this.opened = opened } + + /** A unique identifier associated with the recipient of the delivered message. */ + fun recipient(recipient: String) = recipient(JsonField.of(recipient)) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + /** + * A UTC timestamp at which Courier passed the message to the Integration provider. Stored + * as a millisecond representation of the Unix epoch. + */ + fun sent(sent: Long) = sent(JsonField.of(sent)) + + /** + * Sets [Builder.sent] to an arbitrary JSON value. + * + * You should usually call [Builder.sent] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sent(sent: JsonField) = apply { this.sent = sent } + + /** The current status of the message. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** A message describing the error that occurred. */ + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** The reason for the current status of the message. */ + fun reason(reason: Reason?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [Reason] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .clicked() + * .delivered() + * .enqueued() + * .event() + * .notification() + * .opened() + * .recipient() + * .sent() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageDetails = + MessageDetails( + checkRequired("id", id), + checkRequired("clicked", clicked), + checkRequired("delivered", delivered), + checkRequired("enqueued", enqueued), + checkRequired("event", event), + checkRequired("notification", notification), + checkRequired("opened", opened), + checkRequired("recipient", recipient), + checkRequired("sent", sent), + checkRequired("status", status), + error, + reason, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MessageDetails = apply { + if (validated) { + return@apply + } + + id() + clicked() + delivered() + enqueued() + event() + notification() + opened() + recipient() + sent() + status().validate() + error() + reason().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (clicked.asKnown().isPresent) 1 else 0) + + (if (delivered.asKnown().isPresent) 1 else 0) + + (if (enqueued.asKnown().isPresent) 1 else 0) + + (if (event.asKnown().isPresent) 1 else 0) + + (if (notification.asKnown().isPresent) 1 else 0) + + (if (opened.asKnown().isPresent) 1 else 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (if (sent.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + /** The current status of the message. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELED = of("CANCELED") + + @JvmField val CLICKED = of("CLICKED") + + @JvmField val DELAYED = of("DELAYED") + + @JvmField val DELIVERED = of("DELIVERED") + + @JvmField val DIGESTED = of("DIGESTED") + + @JvmField val ENQUEUED = of("ENQUEUED") + + @JvmField val FILTERED = of("FILTERED") + + @JvmField val OPENED = of("OPENED") + + @JvmField val ROUTED = of("ROUTED") + + @JvmField val SENT = of("SENT") + + @JvmField val SIMULATED = of("SIMULATED") + + @JvmField val THROTTLED = of("THROTTLED") + + @JvmField val UNDELIVERABLE = of("UNDELIVERABLE") + + @JvmField val UNMAPPED = of("UNMAPPED") + + @JvmField val UNROUTABLE = of("UNROUTABLE") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELED, + CLICKED, + DELAYED, + DELIVERED, + DIGESTED, + ENQUEUED, + FILTERED, + OPENED, + ROUTED, + SENT, + SIMULATED, + THROTTLED, + UNDELIVERABLE, + UNMAPPED, + UNROUTABLE, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELED, + CLICKED, + DELAYED, + DELIVERED, + DIGESTED, + ENQUEUED, + FILTERED, + OPENED, + ROUTED, + SENT, + SIMULATED, + THROTTLED, + UNDELIVERABLE, + UNMAPPED, + UNROUTABLE, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELED -> Value.CANCELED + CLICKED -> Value.CLICKED + DELAYED -> Value.DELAYED + DELIVERED -> Value.DELIVERED + DIGESTED -> Value.DIGESTED + ENQUEUED -> Value.ENQUEUED + FILTERED -> Value.FILTERED + OPENED -> Value.OPENED + ROUTED -> Value.ROUTED + SENT -> Value.SENT + SIMULATED -> Value.SIMULATED + THROTTLED -> Value.THROTTLED + UNDELIVERABLE -> Value.UNDELIVERABLE + UNMAPPED -> Value.UNMAPPED + UNROUTABLE -> Value.UNROUTABLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CANCELED -> Known.CANCELED + CLICKED -> Known.CLICKED + DELAYED -> Known.DELAYED + DELIVERED -> Known.DELIVERED + DIGESTED -> Known.DIGESTED + ENQUEUED -> Known.ENQUEUED + FILTERED -> Known.FILTERED + OPENED -> Known.OPENED + ROUTED -> Known.ROUTED + SENT -> Known.SENT + SIMULATED -> Known.SIMULATED + THROTTLED -> Known.THROTTLED + UNDELIVERABLE -> Known.UNDELIVERABLE + UNMAPPED -> Known.UNMAPPED + UNROUTABLE -> Known.UNROUTABLE + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The reason for the current status of the message. */ + class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FILTERED = of("FILTERED") + + @JvmField val NO_CHANNELS = of("NO_CHANNELS") + + @JvmField val NO_PROVIDERS = of("NO_PROVIDERS") + + @JvmField val PROVIDER_ERROR = of("PROVIDER_ERROR") + + @JvmField val UNPUBLISHED = of("UNPUBLISHED") + + @JvmField val UNSUBSCRIBED = of("UNSUBSCRIBED") + + @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) + } + + /** An enum containing [Reason]'s known values. */ + enum class Known { + FILTERED, + NO_CHANNELS, + NO_PROVIDERS, + PROVIDER_ERROR, + UNPUBLISHED, + UNSUBSCRIBED, + } + + /** + * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Reason] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FILTERED, + NO_CHANNELS, + NO_PROVIDERS, + PROVIDER_ERROR, + UNPUBLISHED, + UNSUBSCRIBED, + /** An enum member indicating that [Reason] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FILTERED -> Value.FILTERED + NO_CHANNELS -> Value.NO_CHANNELS + NO_PROVIDERS -> Value.NO_PROVIDERS + PROVIDER_ERROR -> Value.PROVIDER_ERROR + UNPUBLISHED -> Value.UNPUBLISHED + UNSUBSCRIBED -> Value.UNSUBSCRIBED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FILTERED -> Known.FILTERED + NO_CHANNELS -> Known.NO_CHANNELS + NO_PROVIDERS -> Known.NO_PROVIDERS + PROVIDER_ERROR -> Known.PROVIDER_ERROR + UNPUBLISHED -> Known.UNPUBLISHED + UNSUBSCRIBED -> Known.UNSUBSCRIBED + else -> throw CourierInvalidDataException("Unknown Reason: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Reason = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Reason && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageDetails && + id == other.id && + clicked == other.clicked && + delivered == other.delivered && + enqueued == other.enqueued && + event == other.event && + notification == other.notification && + opened == other.opened && + recipient == other.recipient && + sent == other.sent && + status == other.status && + error == other.error && + reason == other.reason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + clicked, + delivered, + enqueued, + event, + notification, + opened, + recipient, + sent, + status, + error, + reason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageDetails{id=$id, clicked=$clicked, delivered=$delivered, enqueued=$enqueued, event=$event, notification=$notification, opened=$opened, recipient=$recipient, sent=$sent, status=$status, error=$error, reason=$reason, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt new file mode 100644 index 00000000..3ecf9592 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get message content */ +class MessageGetContentParams +private constructor( + private val messageId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun messageId(): Optional = Optional.ofNullable(messageId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MessageGetContentParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageGetContentParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageGetContentParams]. */ + class Builder internal constructor() { + + private var messageId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(messageGetContentParams: MessageGetContentParams) = apply { + messageId = messageGetContentParams.messageId + additionalHeaders = messageGetContentParams.additionalHeaders.toBuilder() + additionalQueryParams = messageGetContentParams.additionalQueryParams.toBuilder() + } + + fun messageId(messageId: String?) = apply { this.messageId = messageId } + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MessageGetContentParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageGetContentParams = + MessageGetContentParams( + messageId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> messageId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageGetContentParams && + messageId == other.messageId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(messageId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MessageGetContentParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt new file mode 100644 index 00000000..afee9a38 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt @@ -0,0 +1,1015 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class MessageGetContentResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of() + ) : this(results, mutableMapOf()) + + /** + * An array of render output of a previously sent message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageGetContentResponse]. + * + * The following fields are required: + * ```java + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageGetContentResponse]. */ + class Builder internal constructor() { + + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageGetContentResponse: MessageGetContentResponse) = apply { + results = messageGetContentResponse.results.map { it.toMutableList() } + additionalProperties = messageGetContentResponse.additionalProperties.toMutableMap() + } + + /** An array of render output of a previously sent message. */ + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageGetContentResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageGetContentResponse = + MessageGetContentResponse( + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MessageGetContentResponse = apply { + if (validated) { + return@apply + } + + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val channelId: JsonField, + private val content: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channel_id") + @ExcludeMissing + channelId: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + ) : this(channel, channelId, content, mutableMapOf()) + + /** + * The channel used for rendering the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * The ID of channel used for rendering the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channelId(): String = channelId.getRequired("channel_id") + + /** + * Content details of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channelId]. + * + * Unlike [channelId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel_id") @ExcludeMissing fun _channelId(): JsonField = channelId + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Result]. + * + * The following fields are required: + * ```java + * .channel() + * .channelId() + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channelId: JsonField? = null + private var content: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + channel = result.channel + channelId = result.channelId + content = result.content + additionalProperties = result.additionalProperties.toMutableMap() + } + + /** The channel used for rendering the message. */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + /** The ID of channel used for rendering the message. */ + fun channelId(channelId: String) = channelId(JsonField.of(channelId)) + + /** + * Sets [Builder.channelId] to an arbitrary JSON value. + * + * You should usually call [Builder.channelId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channelId(channelId: JsonField) = apply { this.channelId = channelId } + + /** Content details of the rendered message. */ + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * .channelId() + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("channel", channel), + checkRequired("channelId", channelId), + checkRequired("content", content), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + channel() + channelId() + content().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (if (channelId.asKnown().isPresent) 1 else 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + /** Content details of the rendered message. */ + class Content + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val blocks: JsonField>, + private val body: JsonField, + private val html: JsonField, + private val subject: JsonField, + private val text: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("blocks") + @ExcludeMissing + blocks: JsonField> = JsonMissing.of(), + @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), + @JsonProperty("html") @ExcludeMissing html: JsonField = JsonMissing.of(), + @JsonProperty("subject") + @ExcludeMissing + subject: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(blocks, body, html, subject, text, title, mutableMapOf()) + + /** + * The blocks of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun blocks(): List = blocks.getRequired("blocks") + + /** + * The body of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun body(): String = body.getRequired("body") + + /** + * The html content of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun html(): String = html.getRequired("html") + + /** + * The subject of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subject(): String = subject.getRequired("subject") + + /** + * The text of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun text(): String = text.getRequired("text") + + /** + * The title of the rendered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun title(): String = title.getRequired("title") + + /** + * Returns the raw JSON value of [blocks]. + * + * Unlike [blocks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocks") @ExcludeMissing fun _blocks(): JsonField> = blocks + + /** + * Returns the raw JSON value of [body]. + * + * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + + /** + * Returns the raw JSON value of [html]. + * + * Unlike [html], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("html") @ExcludeMissing fun _html(): JsonField = html + + /** + * Returns the raw JSON value of [subject]. + * + * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subject") @ExcludeMissing fun _subject(): JsonField = subject + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Content]. + * + * The following fields are required: + * ```java + * .blocks() + * .body() + * .html() + * .subject() + * .text() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Content]. */ + class Builder internal constructor() { + + private var blocks: JsonField>? = null + private var body: JsonField? = null + private var html: JsonField? = null + private var subject: JsonField? = null + private var text: JsonField? = null + private var title: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(content: Content) = apply { + blocks = content.blocks.map { it.toMutableList() } + body = content.body + html = content.html + subject = content.subject + text = content.text + title = content.title + additionalProperties = content.additionalProperties.toMutableMap() + } + + /** The blocks of the rendered message. */ + fun blocks(blocks: List) = blocks(JsonField.of(blocks)) + + /** + * Sets [Builder.blocks] to an arbitrary JSON value. + * + * You should usually call [Builder.blocks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun blocks(blocks: JsonField>) = apply { + this.blocks = blocks.map { it.toMutableList() } + } + + /** + * Adds a single [Block] to [blocks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlock(block: Block) = apply { + blocks = + (blocks ?: JsonField.of(mutableListOf())).also { + checkKnown("blocks", it).add(block) + } + } + + /** The body of the rendered message. */ + fun body(body: String) = body(JsonField.of(body)) + + /** + * Sets [Builder.body] to an arbitrary JSON value. + * + * You should usually call [Builder.body] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun body(body: JsonField) = apply { this.body = body } + + /** The html content of the rendered message. */ + fun html(html: String) = html(JsonField.of(html)) + + /** + * Sets [Builder.html] to an arbitrary JSON value. + * + * You should usually call [Builder.html] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun html(html: JsonField) = apply { this.html = html } + + /** The subject of the rendered message. */ + fun subject(subject: String) = subject(JsonField.of(subject)) + + /** + * Sets [Builder.subject] to an arbitrary JSON value. + * + * You should usually call [Builder.subject] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subject(subject: JsonField) = apply { this.subject = subject } + + /** The text of the rendered message. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** The title of the rendered message. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Content]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .blocks() + * .body() + * .html() + * .subject() + * .text() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Content = + Content( + checkRequired("blocks", blocks).map { it.toImmutable() }, + checkRequired("body", body), + checkRequired("html", html), + checkRequired("subject", subject), + checkRequired("text", text), + checkRequired("title", title), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + blocks().forEach { it.validate() } + body() + html() + subject() + text() + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (blocks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (body.asKnown().isPresent) 1 else 0) + + (if (html.asKnown().isPresent) 1 else 0) + + (if (subject.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + class Block + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val text: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("text") + @ExcludeMissing + text: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(text, type, mutableMapOf()) + + /** + * The block text of the rendered message block. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun text(): String = text.getRequired("text") + + /** + * The block type of the rendered message block. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun type(): String = type.getRequired("type") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Block]. + * + * The following fields are required: + * ```java + * .text() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Block]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(block: Block) = apply { + text = block.text + type = block.type + additionalProperties = block.additionalProperties.toMutableMap() + } + + /** The block text of the rendered message block. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** The block type of the rendered message block. */ + fun type(type: String) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Block]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Block = + Block( + checkRequired("text", text), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Block = apply { + if (validated) { + return@apply + } + + text() + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (text.asKnown().isPresent) 1 else 0) + + (if (type.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Block && + text == other.text && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Block{text=$text, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + blocks == other.blocks && + body == other.body && + html == other.html && + subject == other.subject && + text == other.text && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(blocks, body, html, subject, text, title, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Content{blocks=$blocks, body=$body, html=$html, subject=$subject, text=$text, title=$title, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + channel == other.channel && + channelId == other.channelId && + content == other.content && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, channelId, content, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{channel=$channel, channelId=$channelId, content=$content, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageGetContentResponse && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageGetContentResponse{results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt new file mode 100644 index 00000000..eb6a365d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch the array of events of a message you've previously sent. */ +class MessageHistoryParams +private constructor( + private val messageId: String?, + private val type: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun messageId(): Optional = Optional.ofNullable(messageId) + + /** A supported Message History type that will filter the events returned. */ + fun type(): Optional = Optional.ofNullable(type) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MessageHistoryParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageHistoryParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageHistoryParams]. */ + class Builder internal constructor() { + + private var messageId: String? = null + private var type: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(messageHistoryParams: MessageHistoryParams) = apply { + messageId = messageHistoryParams.messageId + type = messageHistoryParams.type + additionalHeaders = messageHistoryParams.additionalHeaders.toBuilder() + additionalQueryParams = messageHistoryParams.additionalQueryParams.toBuilder() + } + + fun messageId(messageId: String?) = apply { this.messageId = messageId } + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + /** A supported Message History type that will filter the events returned. */ + fun type(type: String?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MessageHistoryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageHistoryParams = + MessageHistoryParams( + messageId, + type, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> messageId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + type?.let { put("type", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageHistoryParams && + messageId == other.messageId && + type == other.type && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(messageId, type, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MessageHistoryParams{messageId=$messageId, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt new file mode 100644 index 00000000..cf2ba77a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class MessageHistoryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of() + ) : this(results, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageHistoryResponse]. + * + * The following fields are required: + * ```java + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageHistoryResponse]. */ + class Builder internal constructor() { + + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageHistoryResponse: MessageHistoryResponse) = apply { + results = messageHistoryResponse.results.map { it.toMutableList() } + additionalProperties = messageHistoryResponse.additionalProperties.toMutableMap() + } + + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageHistoryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageHistoryResponse = + MessageHistoryResponse( + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MessageHistoryResponse = apply { + if (validated) { + return@apply + } + + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Result + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Result]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + additionalProperties = result.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Result = Result(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Result{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageHistoryResponse && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageHistoryResponse{results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt new file mode 100644 index 00000000..92a1fa81 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt @@ -0,0 +1,475 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch the statuses of messages you've previously sent. */ +class MessageListParams +private constructor( + private val archived: Boolean?, + private val cursor: String?, + private val enqueuedAfter: String?, + private val event: String?, + private val list: String?, + private val messageId: String?, + private val notification: String?, + private val provider: List?, + private val recipient: String?, + private val status: List?, + private val tag: List?, + private val tags: String?, + private val tenantId: String?, + private val traceId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * A boolean value that indicates whether archived messages should be included in the response. + */ + fun archived(): Optional = Optional.ofNullable(archived) + + /** A unique identifier that allows for fetching the next set of messages. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The enqueued datetime of a message to filter out messages received before. */ + fun enqueuedAfter(): Optional = Optional.ofNullable(enqueuedAfter) + + /** A unique identifier representing the event that was used to send the event. */ + fun event(): Optional = Optional.ofNullable(event) + + /** A unique identifier representing the list the message was sent to. */ + fun list(): Optional = Optional.ofNullable(list) + + /** A unique identifier representing the message_id returned from either /send or /send/list. */ + fun messageId(): Optional = Optional.ofNullable(messageId) + + /** A unique identifier representing the notification that was used to send the event. */ + fun notification(): Optional = Optional.ofNullable(notification) + + /** + * The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, + * slack, msteams, etc. Allows multiple values to be set in query parameters. + */ + fun provider(): Optional> = Optional.ofNullable(provider) + + /** A unique identifier representing the recipient associated with the requested profile. */ + fun recipient(): Optional = Optional.ofNullable(recipient) + + /** + * An indicator of the current status of the message. Allows multiple values to be set in query + * parameters. + */ + fun status(): Optional> = Optional.ofNullable(status) + + /** + * A tag placed in the metadata.tags during a notification send. Allows multiple values to be + * set in query parameters. + */ + fun tag(): Optional> = Optional.ofNullable(tag) + + /** + * A comma delimited list of 'tags'. Messages will be returned if they match any of the tags + * passed in. + */ + fun tags(): Optional = Optional.ofNullable(tags) + + /** Messages sent with the context of a Tenant */ + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** The unique identifier used to trace the requests */ + fun traceId(): Optional = Optional.ofNullable(traceId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MessageListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageListParams]. */ + class Builder internal constructor() { + + private var archived: Boolean? = null + private var cursor: String? = null + private var enqueuedAfter: String? = null + private var event: String? = null + private var list: String? = null + private var messageId: String? = null + private var notification: String? = null + private var provider: MutableList? = null + private var recipient: String? = null + private var status: MutableList? = null + private var tag: MutableList? = null + private var tags: String? = null + private var tenantId: String? = null + private var traceId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(messageListParams: MessageListParams) = apply { + archived = messageListParams.archived + cursor = messageListParams.cursor + enqueuedAfter = messageListParams.enqueuedAfter + event = messageListParams.event + list = messageListParams.list + messageId = messageListParams.messageId + notification = messageListParams.notification + provider = messageListParams.provider?.toMutableList() + recipient = messageListParams.recipient + status = messageListParams.status?.toMutableList() + tag = messageListParams.tag?.toMutableList() + tags = messageListParams.tags + tenantId = messageListParams.tenantId + traceId = messageListParams.traceId + additionalHeaders = messageListParams.additionalHeaders.toBuilder() + additionalQueryParams = messageListParams.additionalQueryParams.toBuilder() + } + + /** + * A boolean value that indicates whether archived messages should be included in the + * response. + */ + fun archived(archived: Boolean?) = apply { this.archived = archived } + + /** + * Alias for [Builder.archived]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun archived(archived: Boolean) = archived(archived as Boolean?) + + /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ + fun archived(archived: Optional) = archived(archived.getOrNull()) + + /** A unique identifier that allows for fetching the next set of messages. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The enqueued datetime of a message to filter out messages received before. */ + fun enqueuedAfter(enqueuedAfter: String?) = apply { this.enqueuedAfter = enqueuedAfter } + + /** Alias for calling [Builder.enqueuedAfter] with `enqueuedAfter.orElse(null)`. */ + fun enqueuedAfter(enqueuedAfter: Optional) = + enqueuedAfter(enqueuedAfter.getOrNull()) + + /** A unique identifier representing the event that was used to send the event. */ + fun event(event: String?) = apply { this.event = event } + + /** Alias for calling [Builder.event] with `event.orElse(null)`. */ + fun event(event: Optional) = event(event.getOrNull()) + + /** A unique identifier representing the list the message was sent to. */ + fun list(list: String?) = apply { this.list = list } + + /** Alias for calling [Builder.list] with `list.orElse(null)`. */ + fun list(list: Optional) = list(list.getOrNull()) + + /** + * A unique identifier representing the message_id returned from either /send or /send/list. + */ + fun messageId(messageId: String?) = apply { this.messageId = messageId } + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + /** A unique identifier representing the notification that was used to send the event. */ + fun notification(notification: String?) = apply { this.notification = notification } + + /** Alias for calling [Builder.notification] with `notification.orElse(null)`. */ + fun notification(notification: Optional) = notification(notification.getOrNull()) + + /** + * The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, + * slack, msteams, etc. Allows multiple values to be set in query parameters. + */ + fun provider(provider: List?) = apply { this.provider = provider?.toMutableList() } + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional>) = provider(provider.getOrNull()) + + /** + * Adds a single [String] to [Builder.provider]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProvider(provider: String) = apply { + this.provider = (this.provider ?: mutableListOf()).apply { add(provider) } + } + + /** A unique identifier representing the recipient associated with the requested profile. */ + fun recipient(recipient: String?) = apply { this.recipient = recipient } + + /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ + fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) + + /** + * An indicator of the current status of the message. Allows multiple values to be set in + * query parameters. + */ + fun status(status: List?) = apply { this.status = status?.toMutableList() } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional>) = status(status.getOrNull()) + + /** + * Adds a single [String] to [Builder.status]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStatus(status: String) = apply { + this.status = (this.status ?: mutableListOf()).apply { add(status) } + } + + /** + * A tag placed in the metadata.tags during a notification send. Allows multiple values to + * be set in query parameters. + */ + fun tag(tag: List?) = apply { this.tag = tag?.toMutableList() } + + /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ + fun tag(tag: Optional>) = tag(tag.getOrNull()) + + /** + * Adds a single [String] to [Builder.tag]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + this.tag = (this.tag ?: mutableListOf()).apply { add(tag) } + } + + /** + * A comma delimited list of 'tags'. Messages will be returned if they match any of the tags + * passed in. + */ + fun tags(tags: String?) = apply { this.tags = tags } + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional) = tags(tags.getOrNull()) + + /** Messages sent with the context of a Tenant */ + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** The unique identifier used to trace the requests */ + fun traceId(traceId: String?) = apply { this.traceId = traceId } + + /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ + fun traceId(traceId: Optional) = traceId(traceId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MessageListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageListParams = + MessageListParams( + archived, + cursor, + enqueuedAfter, + event, + list, + messageId, + notification, + provider?.toImmutable(), + recipient, + status?.toImmutable(), + tag?.toImmutable(), + tags, + tenantId, + traceId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + archived?.let { put("archived", it.toString()) } + cursor?.let { put("cursor", it) } + enqueuedAfter?.let { put("enqueued_after", it) } + event?.let { put("event", it) } + list?.let { put("list", it) } + messageId?.let { put("messageId", it) } + notification?.let { put("notification", it) } + provider?.let { put("provider", it.joinToString(",")) } + recipient?.let { put("recipient", it) } + status?.let { put("status", it.joinToString(",")) } + tag?.let { put("tag", it.joinToString(",")) } + tags?.let { put("tags", it) } + tenantId?.let { put("tenant_id", it) } + traceId?.let { put("traceId", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageListParams && + archived == other.archived && + cursor == other.cursor && + enqueuedAfter == other.enqueuedAfter && + event == other.event && + list == other.list && + messageId == other.messageId && + notification == other.notification && + provider == other.provider && + recipient == other.recipient && + status == other.status && + tag == other.tag && + tags == other.tags && + tenantId == other.tenantId && + traceId == other.traceId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + archived, + cursor, + enqueuedAfter, + event, + list, + messageId, + notification, + provider, + recipient, + status, + tag, + tags, + tenantId, + traceId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "MessageListParams{archived=$archived, cursor=$cursor, enqueuedAfter=$enqueuedAfter, event=$event, list=$list, messageId=$messageId, notification=$notification, provider=$provider, recipient=$recipient, status=$status, tag=$tag, tags=$tags, tenantId=$tenantId, traceId=$traceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt new file mode 100644 index 00000000..4cb37861 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class MessageListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val paging: JsonField, + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + ) : this(paging, results, mutableMapOf()) + + /** + * Paging information for the result set. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * An array of messages with their details. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") + @ExcludeMissing + fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageListResponse]. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageListResponse]. */ + class Builder internal constructor() { + + private var paging: JsonField? = null + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageListResponse: MessageListResponse) = apply { + paging = messageListResponse.paging + results = messageListResponse.results.map { it.toMutableList() } + additionalProperties = messageListResponse.additionalProperties.toMutableMap() + } + + /** Paging information for the result set. */ + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + /** An array of messages with their details. */ + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [MessageDetails] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: MessageDetails) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageListResponse = + MessageListResponse( + checkRequired("paging", paging), + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MessageListResponse = apply { + if (validated) { + return@apply + } + + paging().validate() + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageListResponse && + paging == other.paging && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt new file mode 100644 index 00000000..de135e40 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch the status of a message you've previously sent. */ +class MessageRetrieveParams +private constructor( + private val messageId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun messageId(): Optional = Optional.ofNullable(messageId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MessageRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MessageRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageRetrieveParams]. */ + class Builder internal constructor() { + + private var messageId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(messageRetrieveParams: MessageRetrieveParams) = apply { + messageId = messageRetrieveParams.messageId + additionalHeaders = messageRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = messageRetrieveParams.additionalQueryParams.toBuilder() + } + + fun messageId(messageId: String?) = apply { this.messageId = messageId } + + /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ + fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MessageRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageRetrieveParams = + MessageRetrieveParams( + messageId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> messageId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageRetrieveParams && + messageId == other.messageId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(messageId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "MessageRetrieveParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt new file mode 100644 index 00000000..ef93ce21 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt @@ -0,0 +1,814 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class MessageRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val clicked: JsonField, + private val delivered: JsonField, + private val enqueued: JsonField, + private val event: JsonField, + private val notification: JsonField, + private val opened: JsonField, + private val recipient: JsonField, + private val sent: JsonField, + private val status: JsonField, + private val error: JsonField, + private val reason: JsonField, + private val providers: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("clicked") @ExcludeMissing clicked: JsonField = JsonMissing.of(), + @JsonProperty("delivered") @ExcludeMissing delivered: JsonField = JsonMissing.of(), + @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("notification") + @ExcludeMissing + notification: JsonField = JsonMissing.of(), + @JsonProperty("opened") @ExcludeMissing opened: JsonField = JsonMissing.of(), + @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), + @JsonProperty("sent") @ExcludeMissing sent: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField> = JsonMissing.of(), + ) : this( + id, + clicked, + delivered, + enqueued, + event, + notification, + opened, + recipient, + sent, + status, + error, + reason, + providers, + mutableMapOf(), + ) + + fun toMessageDetails(): MessageDetails = + MessageDetails.builder() + .id(id) + .clicked(clicked) + .delivered(delivered) + .enqueued(enqueued) + .event(event) + .notification(notification) + .opened(opened) + .recipient(recipient) + .sent(sent) + .status(status) + .error(error) + .reason(reason) + .build() + + /** + * A unique identifier associated with the message you wish to retrieve (results from a send). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored + * as a millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun clicked(): Long = clicked.getRequired("clicked") + + /** + * A UTC timestamp at which the Integration provider delivered the message. Stored as a + * millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun delivered(): Long = delivered.getRequired("delivered") + + /** + * A UTC timestamp at which Courier received the message request. Stored as a millisecond + * representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun enqueued(): Long = enqueued.getRequired("enqueued") + + /** + * A unique identifier associated with the event of the delivered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun event(): String = event.getRequired("event") + + /** + * A unique identifier associated with the notification of the delivered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun notification(): String = notification.getRequired("notification") + + /** + * A UTC timestamp at which the recipient opened a message for the first time. Stored as a + * millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun opened(): Long = opened.getRequired("opened") + + /** + * A unique identifier associated with the recipient of the delivered message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun recipient(): String = recipient.getRequired("recipient") + + /** + * A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a + * millisecond representation of the Unix epoch. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun sent(): Long = sent.getRequired("sent") + + /** + * The current status of the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): MessageDetails.Status = status.getRequired("status") + + /** + * A message describing the error that occurred. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * The reason for the current status of the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun providers(): Optional> = providers.getOptional("providers") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [clicked]. + * + * Unlike [clicked], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("clicked") @ExcludeMissing fun _clicked(): JsonField = clicked + + /** + * Returns the raw JSON value of [delivered]. + * + * Unlike [delivered], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delivered") @ExcludeMissing fun _delivered(): JsonField = delivered + + /** + * Returns the raw JSON value of [enqueued]. + * + * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [notification]. + * + * Unlike [notification], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("notification") + @ExcludeMissing + fun _notification(): JsonField = notification + + /** + * Returns the raw JSON value of [opened]. + * + * Unlike [opened], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("opened") @ExcludeMissing fun _opened(): JsonField = opened + + /** + * Returns the raw JSON value of [recipient]. + * + * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient + + /** + * Returns the raw JSON value of [sent]. + * + * Unlike [sent], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sent") @ExcludeMissing fun _sent(): JsonField = sent + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField> = providers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .clicked() + * .delivered() + * .enqueued() + * .event() + * .notification() + * .opened() + * .recipient() + * .sent() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var clicked: JsonField? = null + private var delivered: JsonField? = null + private var enqueued: JsonField? = null + private var event: JsonField? = null + private var notification: JsonField? = null + private var opened: JsonField? = null + private var recipient: JsonField? = null + private var sent: JsonField? = null + private var status: JsonField? = null + private var error: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var providers: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageRetrieveResponse: MessageRetrieveResponse) = apply { + id = messageRetrieveResponse.id + clicked = messageRetrieveResponse.clicked + delivered = messageRetrieveResponse.delivered + enqueued = messageRetrieveResponse.enqueued + event = messageRetrieveResponse.event + notification = messageRetrieveResponse.notification + opened = messageRetrieveResponse.opened + recipient = messageRetrieveResponse.recipient + sent = messageRetrieveResponse.sent + status = messageRetrieveResponse.status + error = messageRetrieveResponse.error + reason = messageRetrieveResponse.reason + providers = messageRetrieveResponse.providers.map { it.toMutableList() } + additionalProperties = messageRetrieveResponse.additionalProperties.toMutableMap() + } + + /** + * A unique identifier associated with the message you wish to retrieve (results from a + * send). + */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * A UTC timestamp at which the recipient clicked on a tracked link for the first time. + * Stored as a millisecond representation of the Unix epoch. + */ + fun clicked(clicked: Long) = clicked(JsonField.of(clicked)) + + /** + * Sets [Builder.clicked] to an arbitrary JSON value. + * + * You should usually call [Builder.clicked] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun clicked(clicked: JsonField) = apply { this.clicked = clicked } + + /** + * A UTC timestamp at which the Integration provider delivered the message. Stored as a + * millisecond representation of the Unix epoch. + */ + fun delivered(delivered: Long) = delivered(JsonField.of(delivered)) + + /** + * Sets [Builder.delivered] to an arbitrary JSON value. + * + * You should usually call [Builder.delivered] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delivered(delivered: JsonField) = apply { this.delivered = delivered } + + /** + * A UTC timestamp at which Courier received the message request. Stored as a millisecond + * representation of the Unix epoch. + */ + fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) + + /** + * Sets [Builder.enqueued] to an arbitrary JSON value. + * + * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } + + /** A unique identifier associated with the event of the delivered message. */ + fun event(event: String) = event(JsonField.of(event)) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + /** A unique identifier associated with the notification of the delivered message. */ + fun notification(notification: String) = notification(JsonField.of(notification)) + + /** + * Sets [Builder.notification] to an arbitrary JSON value. + * + * You should usually call [Builder.notification] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun notification(notification: JsonField) = apply { + this.notification = notification + } + + /** + * A UTC timestamp at which the recipient opened a message for the first time. Stored as a + * millisecond representation of the Unix epoch. + */ + fun opened(opened: Long) = opened(JsonField.of(opened)) + + /** + * Sets [Builder.opened] to an arbitrary JSON value. + * + * You should usually call [Builder.opened] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun opened(opened: JsonField) = apply { this.opened = opened } + + /** A unique identifier associated with the recipient of the delivered message. */ + fun recipient(recipient: String) = recipient(JsonField.of(recipient)) + + /** + * Sets [Builder.recipient] to an arbitrary JSON value. + * + * You should usually call [Builder.recipient] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun recipient(recipient: JsonField) = apply { this.recipient = recipient } + + /** + * A UTC timestamp at which Courier passed the message to the Integration provider. Stored + * as a millisecond representation of the Unix epoch. + */ + fun sent(sent: Long) = sent(JsonField.of(sent)) + + /** + * Sets [Builder.sent] to an arbitrary JSON value. + * + * You should usually call [Builder.sent] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun sent(sent: JsonField) = apply { this.sent = sent } + + /** The current status of the message. */ + fun status(status: MessageDetails.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [MessageDetails.Status] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** A message describing the error that occurred. */ + fun error(error: String?) = error(JsonField.ofNullable(error)) + + /** Alias for calling [Builder.error] with `error.orElse(null)`. */ + fun error(error: Optional) = error(error.getOrNull()) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** The reason for the current status of the message. */ + fun reason(reason: MessageDetails.Reason?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [MessageDetails.Reason] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + fun providers(providers: List?) = providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional>) = providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun providers(providers: JsonField>) = apply { + this.providers = providers.map { it.toMutableList() } + } + + /** + * Adds a single [Provider] to [providers]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addProvider(provider: Provider) = apply { + providers = + (providers ?: JsonField.of(mutableListOf())).also { + checkKnown("providers", it).add(provider) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .clicked() + * .delivered() + * .enqueued() + * .event() + * .notification() + * .opened() + * .recipient() + * .sent() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageRetrieveResponse = + MessageRetrieveResponse( + checkRequired("id", id), + checkRequired("clicked", clicked), + checkRequired("delivered", delivered), + checkRequired("enqueued", enqueued), + checkRequired("event", event), + checkRequired("notification", notification), + checkRequired("opened", opened), + checkRequired("recipient", recipient), + checkRequired("sent", sent), + checkRequired("status", status), + error, + reason, + (providers ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MessageRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + clicked() + delivered() + enqueued() + event() + notification() + opened() + recipient() + sent() + status().validate() + error() + reason().ifPresent { it.validate() } + providers().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (clicked.asKnown().isPresent) 1 else 0) + + (if (delivered.asKnown().isPresent) 1 else 0) + + (if (enqueued.asKnown().isPresent) 1 else 0) + + (if (event.asKnown().isPresent) 1 else 0) + + (if (notification.asKnown().isPresent) 1 else 0) + + (if (opened.asKnown().isPresent) 1 else 0) + + (if (recipient.asKnown().isPresent) 1 else 0) + + (if (sent.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (error.asKnown().isPresent) 1 else 0) + + (reason.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Provider + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Provider]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Provider]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(provider: Provider) = apply { + additionalProperties = provider.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Provider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Provider = Provider(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Provider = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Provider && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Provider{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageRetrieveResponse && + id == other.id && + clicked == other.clicked && + delivered == other.delivered && + enqueued == other.enqueued && + event == other.event && + notification == other.notification && + opened == other.opened && + recipient == other.recipient && + sent == other.sent && + status == other.status && + error == other.error && + reason == other.reason && + providers == other.providers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + clicked, + delivered, + enqueued, + event, + notification, + opened, + recipient, + sent, + status, + error, + reason, + providers, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageRetrieveResponse{id=$id, clicked=$clicked, delivered=$delivered, enqueued=$enqueued, event=$event, notification=$notification, opened=$opened, recipient=$recipient, sent=$sent, status=$status, error=$error, reason=$reason, providers=$providers, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt new file mode 100644 index 00000000..22f1008f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt @@ -0,0 +1,363 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class MessageRouting +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val channels: JsonField>, + private val method: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), + ) : this(channels, method, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channels(): List = channels.getRequired("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun method(): Method = method.getRequired("method") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MessageRouting]. + * + * The following fields are required: + * ```java + * .channels() + * .method() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageRouting]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var method: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageRouting: MessageRouting) = apply { + channels = messageRouting.channels.map { it.toMutableList() } + method = messageRouting.method + additionalProperties = messageRouting.additionalProperties.toMutableMap() + } + + fun channels(channels: List) = channels(JsonField.of(channels)) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [MessageRoutingChannel] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: MessageRoutingChannel) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** Alias for calling [addChannel] with `MessageRoutingChannel.ofString(string)`. */ + fun addChannel(string: String) = addChannel(MessageRoutingChannel.ofString(string)) + + /** + * Alias for calling [addChannel] with + * `MessageRoutingChannel.ofMessageRouting(messageRouting)`. + */ + fun addChannel(messageRouting: MessageRouting) = + addChannel(MessageRoutingChannel.ofMessageRouting(messageRouting)) + + fun method(method: Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageRouting]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channels() + * .method() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MessageRouting = + MessageRouting( + checkRequired("channels", channels).map { it.toImmutable() }, + checkRequired("method", method), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MessageRouting = apply { + if (validated) { + return@apply + } + + channels().forEach { it.validate() } + method().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + class Method @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ALL = of("all") + + @JvmField val SINGLE = of("single") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + ALL, + SINGLE, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + SINGLE, + /** An enum member indicating that [Method] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + SINGLE -> Value.SINGLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + SINGLE -> Known.SINGLE + else -> throw CourierInvalidDataException("Unknown Method: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Method && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageRouting && + channels == other.channels && + method == other.method && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(channels, method, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageRouting{channels=$channels, method=$method, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt new file mode 100644 index 00000000..969cc112 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.getOrThrow +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(using = MessageRoutingChannel.Deserializer::class) +@JsonSerialize(using = MessageRoutingChannel.Serializer::class) +class MessageRoutingChannel +private constructor( + private val string: String? = null, + private val messageRouting: MessageRouting? = null, + private val _json: JsonValue? = null, +) { + + fun string(): Optional = Optional.ofNullable(string) + + fun messageRouting(): Optional = Optional.ofNullable(messageRouting) + + fun isString(): Boolean = string != null + + fun isMessageRouting(): Boolean = messageRouting != null + + fun asString(): String = string.getOrThrow("string") + + fun asMessageRouting(): MessageRouting = messageRouting.getOrThrow("messageRouting") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + messageRouting != null -> visitor.visitMessageRouting(messageRouting) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MessageRoutingChannel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitMessageRouting(messageRouting: MessageRouting) { + messageRouting.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitMessageRouting(messageRouting: MessageRouting) = + messageRouting.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageRoutingChannel && + string == other.string && + messageRouting == other.messageRouting + } + + override fun hashCode(): Int = Objects.hash(string, messageRouting) + + override fun toString(): String = + when { + string != null -> "MessageRoutingChannel{string=$string}" + messageRouting != null -> "MessageRoutingChannel{messageRouting=$messageRouting}" + _json != null -> "MessageRoutingChannel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MessageRoutingChannel") + } + + companion object { + + @JvmStatic fun ofString(string: String) = MessageRoutingChannel(string = string) + + @JvmStatic + fun ofMessageRouting(messageRouting: MessageRouting) = + MessageRoutingChannel(messageRouting = messageRouting) + } + + /** + * An interface that defines how to map each variant of [MessageRoutingChannel] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitMessageRouting(messageRouting: MessageRouting): T + + /** + * Maps an unknown variant of [MessageRoutingChannel] to a value of type [T]. + * + * An instance of [MessageRoutingChannel] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown MessageRoutingChannel: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MessageRoutingChannel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MessageRoutingChannel { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MessageRoutingChannel(messageRouting = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MessageRoutingChannel(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from array). + 0 -> MessageRoutingChannel(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(MessageRoutingChannel::class) { + + override fun serialize( + value: MessageRoutingChannel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.messageRouting != null -> generator.writeObject(value.messageRouting) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MessageRoutingChannel") + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt new file mode 100644 index 00000000..5b4c3ae5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt @@ -0,0 +1,1906 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotificationGetContent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val blocks: JsonField>, + private val channels: JsonField>, + private val checksum: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("blocks") @ExcludeMissing blocks: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("checksum") @ExcludeMissing checksum: JsonField = JsonMissing.of(), + ) : this(blocks, channels, checksum, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun blocks(): Optional> = blocks.getOptional("blocks") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun checksum(): Optional = checksum.getOptional("checksum") + + /** + * Returns the raw JSON value of [blocks]. + * + * Unlike [blocks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("blocks") @ExcludeMissing fun _blocks(): JsonField> = blocks + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [checksum]. + * + * Unlike [checksum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checksum") @ExcludeMissing fun _checksum(): JsonField = checksum + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [NotificationGetContent]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotificationGetContent]. */ + class Builder internal constructor() { + + private var blocks: JsonField>? = null + private var channels: JsonField>? = null + private var checksum: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notificationGetContent: NotificationGetContent) = apply { + blocks = notificationGetContent.blocks.map { it.toMutableList() } + channels = notificationGetContent.channels.map { it.toMutableList() } + checksum = notificationGetContent.checksum + additionalProperties = notificationGetContent.additionalProperties.toMutableMap() + } + + fun blocks(blocks: List?) = blocks(JsonField.ofNullable(blocks)) + + /** Alias for calling [Builder.blocks] with `blocks.orElse(null)`. */ + fun blocks(blocks: Optional>) = blocks(blocks.getOrNull()) + + /** + * Sets [Builder.blocks] to an arbitrary JSON value. + * + * You should usually call [Builder.blocks] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun blocks(blocks: JsonField>) = apply { + this.blocks = blocks.map { it.toMutableList() } + } + + /** + * Adds a single [Block] to [blocks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBlock(block: Block) = apply { + blocks = + (blocks ?: JsonField.of(mutableListOf())).also { + checkKnown("blocks", it).add(block) + } + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [Channel] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: Channel) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun checksum(checksum: String?) = checksum(JsonField.ofNullable(checksum)) + + /** Alias for calling [Builder.checksum] with `checksum.orElse(null)`. */ + fun checksum(checksum: Optional) = checksum(checksum.getOrNull()) + + /** + * Sets [Builder.checksum] to an arbitrary JSON value. + * + * You should usually call [Builder.checksum] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun checksum(checksum: JsonField) = apply { this.checksum = checksum } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NotificationGetContent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NotificationGetContent = + NotificationGetContent( + (blocks ?: JsonMissing.of()).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + checksum, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NotificationGetContent = apply { + if (validated) { + return@apply + } + + blocks().ifPresent { it.forEach { it.validate() } } + channels().ifPresent { it.forEach { it.validate() } } + checksum() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (blocks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (checksum.asKnown().isPresent) 1 else 0) + + class Block + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val type: JsonField, + private val alias: JsonField, + private val checksum: JsonField, + private val content: JsonField, + private val context: JsonField, + private val locales: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), + @JsonProperty("checksum") + @ExcludeMissing + checksum: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("context") @ExcludeMissing context: JsonField = JsonMissing.of(), + @JsonProperty("locales") @ExcludeMissing locales: JsonField = JsonMissing.of(), + ) : this(id, type, alias, checksum, content, context, locales, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun alias(): Optional = alias.getOptional("alias") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun checksum(): Optional = checksum.getOptional("checksum") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locales(): Optional = locales.getOptional("locales") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [alias]. + * + * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias + + /** + * Returns the raw JSON value of [checksum]. + * + * Unlike [checksum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checksum") @ExcludeMissing fun _checksum(): JsonField = checksum + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [locales]. + * + * Unlike [locales], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locales") @ExcludeMissing fun _locales(): JsonField = locales + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Block]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Block]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var alias: JsonField = JsonMissing.of() + private var checksum: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var locales: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(block: Block) = apply { + id = block.id + type = block.type + alias = block.alias + checksum = block.checksum + content = block.content + context = block.context + locales = block.locales + additionalProperties = block.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun alias(alias: String?) = alias(JsonField.ofNullable(alias)) + + /** Alias for calling [Builder.alias] with `alias.orElse(null)`. */ + fun alias(alias: Optional) = alias(alias.getOrNull()) + + /** + * Sets [Builder.alias] to an arbitrary JSON value. + * + * You should usually call [Builder.alias] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun alias(alias: JsonField) = apply { this.alias = alias } + + fun checksum(checksum: String?) = checksum(JsonField.ofNullable(checksum)) + + /** Alias for calling [Builder.checksum] with `checksum.orElse(null)`. */ + fun checksum(checksum: Optional) = checksum(checksum.getOrNull()) + + /** + * Sets [Builder.checksum] to an arbitrary JSON value. + * + * You should usually call [Builder.checksum] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun checksum(checksum: JsonField) = apply { this.checksum = checksum } + + fun content(content: Content?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofString(string)`. */ + fun content(string: String) = content(Content.ofString(string)) + + /** + * Alias for calling [content] with + * `Content.ofNotificationContentHierarchy(notificationContentHierarchy)`. + */ + fun content(notificationContentHierarchy: Content.NotificationContentHierarchy) = + content(Content.ofNotificationContentHierarchy(notificationContentHierarchy)) + + fun context(context: String?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + fun locales(locales: Locales?) = locales(JsonField.ofNullable(locales)) + + /** Alias for calling [Builder.locales] with `locales.orElse(null)`. */ + fun locales(locales: Optional) = locales(locales.getOrNull()) + + /** + * Sets [Builder.locales] to an arbitrary JSON value. + * + * You should usually call [Builder.locales] with a well-typed [Locales] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun locales(locales: JsonField) = apply { this.locales = locales } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Block]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Block = + Block( + checkRequired("id", id), + checkRequired("type", type), + alias, + checksum, + content, + context, + locales, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Block = apply { + if (validated) { + return@apply + } + + id() + type().validate() + alias() + checksum() + content().ifPresent { it.validate() } + context() + locales().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (alias.asKnown().isPresent) 1 else 0) + + (if (checksum.asKnown().isPresent) 1 else 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (context.asKnown().isPresent) 1 else 0) + + (locales.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTION = of("action") + + @JvmField val DIVIDER = of("divider") + + @JvmField val IMAGE = of("image") + + @JvmField val JSONNET = of("jsonnet") + + @JvmField val LIST = of("list") + + @JvmField val MARKDOWN = of("markdown") + + @JvmField val QUOTE = of("quote") + + @JvmField val TEMPLATE = of("template") + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACTION, + DIVIDER, + IMAGE, + JSONNET, + LIST, + MARKDOWN, + QUOTE, + TEMPLATE, + TEXT, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTION, + DIVIDER, + IMAGE, + JSONNET, + LIST, + MARKDOWN, + QUOTE, + TEMPLATE, + TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTION -> Value.ACTION + DIVIDER -> Value.DIVIDER + IMAGE -> Value.IMAGE + JSONNET -> Value.JSONNET + LIST -> Value.LIST + MARKDOWN -> Value.MARKDOWN + QUOTE -> Value.QUOTE + TEMPLATE -> Value.TEMPLATE + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTION -> Known.ACTION + DIVIDER -> Known.DIVIDER + IMAGE -> Known.IMAGE + JSONNET -> Known.JSONNET + LIST -> Known.LIST + MARKDOWN -> Known.MARKDOWN + QUOTE -> Known.QUOTE + TEMPLATE -> Known.TEMPLATE + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + @JsonDeserialize(using = Content.Deserializer::class) + @JsonSerialize(using = Content.Serializer::class) + class Content + private constructor( + private val string: String? = null, + private val notificationContentHierarchy: NotificationContentHierarchy? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun notificationContentHierarchy(): Optional = + Optional.ofNullable(notificationContentHierarchy) + + fun isString(): Boolean = string != null + + fun isNotificationContentHierarchy(): Boolean = notificationContentHierarchy != null + + fun asString(): String = string.getOrThrow("string") + + fun asNotificationContentHierarchy(): NotificationContentHierarchy = + notificationContentHierarchy.getOrThrow("notificationContentHierarchy") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + notificationContentHierarchy != null -> + visitor.visitNotificationContentHierarchy(notificationContentHierarchy) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitNotificationContentHierarchy( + notificationContentHierarchy: NotificationContentHierarchy + ) { + notificationContentHierarchy.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitNotificationContentHierarchy( + notificationContentHierarchy: NotificationContentHierarchy + ) = notificationContentHierarchy.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + string == other.string && + notificationContentHierarchy == other.notificationContentHierarchy + } + + override fun hashCode(): Int = Objects.hash(string, notificationContentHierarchy) + + override fun toString(): String = + when { + string != null -> "Content{string=$string}" + notificationContentHierarchy != null -> + "Content{notificationContentHierarchy=$notificationContentHierarchy}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofString(string: String) = Content(string = string) + + @JvmStatic + fun ofNotificationContentHierarchy( + notificationContentHierarchy: NotificationContentHierarchy + ) = Content(notificationContentHierarchy = notificationContentHierarchy) + } + + /** + * An interface that defines how to map each variant of [Content] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNotificationContentHierarchy( + notificationContentHierarchy: NotificationContentHierarchy + ): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { + Content(notificationContentHierarchy = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Content(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from array). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.notificationContentHierarchy != null -> + generator.writeObject(value.notificationContentHierarchy) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + class NotificationContentHierarchy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val children: JsonField, + private val parent: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("children") + @ExcludeMissing + children: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + parent: JsonField = JsonMissing.of(), + ) : this(children, parent, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun children(): Optional = children.getOptional("children") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun parent(): Optional = parent.getOptional("parent") + + /** + * Returns the raw JSON value of [children]. + * + * Unlike [children], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("children") + @ExcludeMissing + fun _children(): JsonField = children + + /** + * Returns the raw JSON value of [parent]. + * + * Unlike [parent], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NotificationContentHierarchy]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotificationContentHierarchy]. */ + class Builder internal constructor() { + + private var children: JsonField = JsonMissing.of() + private var parent: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notificationContentHierarchy: NotificationContentHierarchy) = + apply { + children = notificationContentHierarchy.children + parent = notificationContentHierarchy.parent + additionalProperties = + notificationContentHierarchy.additionalProperties.toMutableMap() + } + + fun children(children: String?) = children(JsonField.ofNullable(children)) + + /** Alias for calling [Builder.children] with `children.orElse(null)`. */ + fun children(children: Optional) = children(children.getOrNull()) + + /** + * Sets [Builder.children] to an arbitrary JSON value. + * + * You should usually call [Builder.children] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun children(children: JsonField) = apply { this.children = children } + + fun parent(parent: String?) = parent(JsonField.ofNullable(parent)) + + /** Alias for calling [Builder.parent] with `parent.orElse(null)`. */ + fun parent(parent: Optional) = parent(parent.getOrNull()) + + /** + * Sets [Builder.parent] to an arbitrary JSON value. + * + * You should usually call [Builder.parent] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun parent(parent: JsonField) = apply { this.parent = parent } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NotificationContentHierarchy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NotificationContentHierarchy = + NotificationContentHierarchy( + children, + parent, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NotificationContentHierarchy = apply { + if (validated) { + return@apply + } + + children() + parent() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (children.asKnown().isPresent) 1 else 0) + + (if (parent.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotificationContentHierarchy && + children == other.children && + parent == other.parent && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(children, parent, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NotificationContentHierarchy{children=$children, parent=$parent, additionalProperties=$additionalProperties}" + } + } + + class Locales + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Locales]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Locales]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(locales: Locales) = apply { + additionalProperties = locales.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Locales]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Locales = Locales(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Locales = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Locales && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Locales{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Block && + id == other.id && + type == other.type && + alias == other.alias && + checksum == other.checksum && + content == other.content && + context == other.context && + locales == other.locales && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, type, alias, checksum, content, context, locales, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Block{id=$id, type=$type, alias=$alias, checksum=$checksum, content=$content, context=$context, locales=$locales, additionalProperties=$additionalProperties}" + } + + class Channel + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val checksum: JsonField, + private val content: JsonField, + private val locales: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("checksum") + @ExcludeMissing + checksum: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("locales") @ExcludeMissing locales: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, checksum, content, locales, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun checksum(): Optional = checksum.getOptional("checksum") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locales(): Optional = locales.getOptional("locales") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [checksum]. + * + * Unlike [checksum], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checksum") @ExcludeMissing fun _checksum(): JsonField = checksum + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [locales]. + * + * Unlike [locales], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locales") @ExcludeMissing fun _locales(): JsonField = locales + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Channel]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Channel]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var checksum: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var locales: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channel: Channel) = apply { + id = channel.id + checksum = channel.checksum + content = channel.content + locales = channel.locales + type = channel.type + additionalProperties = channel.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun checksum(checksum: String?) = checksum(JsonField.ofNullable(checksum)) + + /** Alias for calling [Builder.checksum] with `checksum.orElse(null)`. */ + fun checksum(checksum: Optional) = checksum(checksum.getOrNull()) + + /** + * Sets [Builder.checksum] to an arbitrary JSON value. + * + * You should usually call [Builder.checksum] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun checksum(checksum: JsonField) = apply { this.checksum = checksum } + + fun content(content: Content?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun locales(locales: Locales?) = locales(JsonField.ofNullable(locales)) + + /** Alias for calling [Builder.locales] with `locales.orElse(null)`. */ + fun locales(locales: Optional) = locales(locales.getOrNull()) + + /** + * Sets [Builder.locales] to an arbitrary JSON value. + * + * You should usually call [Builder.locales] with a well-typed [Locales] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun locales(locales: JsonField) = apply { this.locales = locales } + + fun type(type: String?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Channel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Channel = + Channel( + checkRequired("id", id), + checksum, + content, + locales, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + id() + checksum() + content().ifPresent { it.validate() } + locales().ifPresent { it.validate() } + type() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (checksum.asKnown().isPresent) 1 else 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + (locales.asKnown().getOrNull()?.validity() ?: 0) + + (if (type.asKnown().isPresent) 1 else 0) + + class Content + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val subject: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("subject") + @ExcludeMissing + subject: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(subject, title, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subject(): Optional = subject.getOptional("subject") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("title") + + /** + * Returns the raw JSON value of [subject]. + * + * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subject") @ExcludeMissing fun _subject(): JsonField = subject + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Content]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Content]. */ + class Builder internal constructor() { + + private var subject: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(content: Content) = apply { + subject = content.subject + title = content.title + additionalProperties = content.additionalProperties.toMutableMap() + } + + fun subject(subject: String?) = subject(JsonField.ofNullable(subject)) + + /** Alias for calling [Builder.subject] with `subject.orElse(null)`. */ + fun subject(subject: Optional) = subject(subject.getOrNull()) + + /** + * Sets [Builder.subject] to an arbitrary JSON value. + * + * You should usually call [Builder.subject] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subject(subject: JsonField) = apply { this.subject = subject } + + fun title(title: String?) = title(JsonField.ofNullable(title)) + + /** Alias for calling [Builder.title] with `title.orElse(null)`. */ + fun title(title: Optional) = title(title.getOrNull()) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Content]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Content = Content(subject, title, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + subject() + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (subject.asKnown().isPresent) 1 else 0) + + (if (title.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + subject == other.subject && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(subject, title, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Content{subject=$subject, title=$title, additionalProperties=$additionalProperties}" + } + + class Locales + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Locales]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Locales]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(locales: Locales) = apply { + additionalProperties = locales.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Locales]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Locales = Locales(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Locales = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Locales && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Locales{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channel && + id == other.id && + checksum == other.checksum && + content == other.content && + locales == other.locales && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, checksum, content, locales, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Channel{id=$id, checksum=$checksum, content=$content, locales=$locales, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotificationGetContent && + blocks == other.blocks && + channels == other.channels && + checksum == other.checksum && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(blocks, channels, checksum, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NotificationGetContent{blocks=$blocks, channels=$channels, checksum=$checksum, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt new file mode 100644 index 00000000..16af7e50 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt @@ -0,0 +1,215 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotificationListParams +private constructor( + private val cursor: String?, + private val notes: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Retrieve the notes from the Notification template settings. */ + fun notes(): Optional = Optional.ofNullable(notes) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NotificationListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [NotificationListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotificationListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var notes: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(notificationListParams: NotificationListParams) = apply { + cursor = notificationListParams.cursor + notes = notificationListParams.notes + additionalHeaders = notificationListParams.additionalHeaders.toBuilder() + additionalQueryParams = notificationListParams.additionalQueryParams.toBuilder() + } + + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** Retrieve the notes from the Notification template settings. */ + fun notes(notes: Boolean?) = apply { this.notes = notes } + + /** + * Alias for [Builder.notes]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun notes(notes: Boolean) = notes(notes as Boolean?) + + /** Alias for calling [Builder.notes] with `notes.orElse(null)`. */ + fun notes(notes: Optional) = notes(notes.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NotificationListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NotificationListParams = + NotificationListParams( + cursor, + notes, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + notes?.let { put("notes", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotificationListParams && + cursor == other.cursor && + notes == other.notes && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, notes, additionalHeaders, additionalQueryParams) + + override fun toString() = + "NotificationListParams{cursor=$cursor, notes=$notes, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt new file mode 100644 index 00000000..e406ae39 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt @@ -0,0 +1,1014 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotificationListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val paging: JsonField, + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of(), + ) : this(paging, results, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotificationListResponse]. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotificationListResponse]. */ + class Builder internal constructor() { + + private var paging: JsonField? = null + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notificationListResponse: NotificationListResponse) = apply { + paging = notificationListResponse.paging + results = notificationListResponse.results.map { it.toMutableList() } + additionalProperties = notificationListResponse.additionalProperties.toMutableMap() + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NotificationListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotificationListResponse = + NotificationListResponse( + checkRequired("paging", paging), + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NotificationListResponse = apply { + if (validated) { + return@apply + } + + paging().validate() + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val note: JsonField, + private val routing: JsonField, + private val topicId: JsonField, + private val updatedAt: JsonField, + private val tags: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("note") @ExcludeMissing note: JsonField = JsonMissing.of(), + @JsonProperty("routing") + @ExcludeMissing + routing: JsonField = JsonMissing.of(), + @JsonProperty("topic_id") @ExcludeMissing topicId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(id, createdAt, note, routing, topicId, updatedAt, tags, title, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): Long = createdAt.getRequired("created_at") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun note(): String = note.getRequired("note") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun routing(): MessageRouting = routing.getRequired("routing") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topicId(): String = topicId.getRequired("topic_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): Long = updatedAt.getRequired("updated_at") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional = tags.getOptional("tags") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun title(): Optional = title.getOptional("title") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [note]. + * + * Unlike [note], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("note") @ExcludeMissing fun _note(): JsonField = note + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") @ExcludeMissing fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [topicId]. + * + * Unlike [topicId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic_id") @ExcludeMissing fun _topicId(): JsonField = topicId + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField = tags + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Result]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .note() + * .routing() + * .topicId() + * .updatedAt() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var note: JsonField? = null + private var routing: JsonField? = null + private var topicId: JsonField? = null + private var updatedAt: JsonField? = null + private var tags: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + id = result.id + createdAt = result.createdAt + note = result.note + routing = result.routing + topicId = result.topicId + updatedAt = result.updatedAt + tags = result.tags + title = result.title + additionalProperties = result.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + fun note(note: String) = note(JsonField.of(note)) + + /** + * Sets [Builder.note] to an arbitrary JSON value. + * + * You should usually call [Builder.note] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun note(note: JsonField) = apply { this.note = note } + + fun routing(routing: MessageRouting) = routing(JsonField.of(routing)) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [MessageRouting] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routing(routing: JsonField) = apply { this.routing = routing } + + fun topicId(topicId: String) = topicId(JsonField.of(topicId)) + + /** + * Sets [Builder.topicId] to an arbitrary JSON value. + * + * You should usually call [Builder.topicId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topicId(topicId: JsonField) = apply { this.topicId = topicId } + + fun updatedAt(updatedAt: Long) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + fun tags(tags: Tags?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed [Tags] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tags(tags: JsonField) = apply { this.tags = tags } + + fun title(title: String?) = title(JsonField.ofNullable(title)) + + /** Alias for calling [Builder.title] with `title.orElse(null)`. */ + fun title(title: Optional) = title(title.getOrNull()) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .note() + * .routing() + * .topicId() + * .updatedAt() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("note", note), + checkRequired("routing", routing), + checkRequired("topicId", topicId), + checkRequired("updatedAt", updatedAt), + tags, + title, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + id() + createdAt() + note() + routing().validate() + topicId() + updatedAt() + tags().ifPresent { it.validate() } + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (note.asKnown().isPresent) 1 else 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (if (topicId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.validity() ?: 0) + + (if (title.asKnown().isPresent) 1 else 0) + + class Tags + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of() + ) : this(data, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun data(): List = data.getRequired("data") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tags]. + * + * The following fields are required: + * ```java + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tags]. */ + class Builder internal constructor() { + + private var data: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tags: Tags) = apply { + data = tags.data.map { it.toMutableList() } + additionalProperties = tags.additionalProperties.toMutableMap() + } + + fun data(data: List) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + /** + * Adds a single [Data] to [Builder.data]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).also { + checkKnown("data", it).add(data) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tags]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tags = + Tags( + checkRequired("data", data).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tags = apply { + if (validated) { + return@apply + } + + data().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(id, name, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + id = data.id + name = data.name + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data( + checkRequired("id", id), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + id() + name() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + id == other.id && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{id=$id, name=$name, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tags && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Tags{data=$data, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + id == other.id && + createdAt == other.createdAt && + note == other.note && + routing == other.routing && + topicId == other.topicId && + updatedAt == other.updatedAt && + tags == other.tags && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + createdAt, + note, + routing, + topicId, + updatedAt, + tags, + title, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{id=$id, createdAt=$createdAt, note=$note, routing=$routing, topicId=$topicId, updatedAt=$updatedAt, tags=$tags, title=$title, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotificationListResponse && + paging == other.paging && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NotificationListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt new file mode 100644 index 00000000..218897c6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotificationRetrieveContentParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): NotificationRetrieveContentParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [NotificationRetrieveContentParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotificationRetrieveContentParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(notificationRetrieveContentParams: NotificationRetrieveContentParams) = + apply { + id = notificationRetrieveContentParams.id + additionalHeaders = notificationRetrieveContentParams.additionalHeaders.toBuilder() + additionalQueryParams = + notificationRetrieveContentParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [NotificationRetrieveContentParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): NotificationRetrieveContentParams = + NotificationRetrieveContentParams( + id, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotificationRetrieveContentParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "NotificationRetrieveContentParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt new file mode 100644 index 00000000..171e9dff --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt @@ -0,0 +1,490 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class BaseCheck +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val status: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, status, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BaseCheck]. + * + * The following fields are required: + * ```java + * .id() + * .status() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BaseCheck]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(baseCheck: BaseCheck) = apply { + id = baseCheck.id + status = baseCheck.status + type = baseCheck.type + additionalProperties = baseCheck.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BaseCheck]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .status() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BaseCheck = + BaseCheck( + checkRequired("id", id), + checkRequired("status", status), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BaseCheck = apply { + if (validated) { + return@apply + } + + id() + status().validate() + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val RESOLVED = of("RESOLVED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + RESOLVED, + FAILED, + PENDING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + RESOLVED, + FAILED, + PENDING, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + RESOLVED -> Value.RESOLVED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + RESOLVED -> Known.RESOLVED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CUSTOM = of("custom") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CUSTOM + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CUSTOM, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CUSTOM -> Value.CUSTOM + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CUSTOM -> Known.CUSTOM + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseCheck && + id == other.id && + status == other.status && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, status, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BaseCheck{id=$id, status=$status, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt new file mode 100644 index 00000000..e2c20679 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt @@ -0,0 +1,280 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class Check +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val status: JsonField, + private val type: JsonField, + private val updated: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), + ) : this(id, status, type, updated, mutableMapOf()) + + fun toBaseCheck(): BaseCheck = BaseCheck.builder().id(id).status(status).type(type).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): BaseCheck.Status = status.getRequired("status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): BaseCheck.Type = type.getRequired("type") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): Long = updated.getRequired("updated") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Check]. + * + * The following fields are required: + * ```java + * .id() + * .status() + * .type() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Check]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null + private var updated: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(check: Check) = apply { + id = check.id + status = check.status + type = check.type + updated = check.updated + additionalProperties = check.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun status(status: BaseCheck.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [BaseCheck.Status] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun type(type: BaseCheck.Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BaseCheck.Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun updated(updated: Long) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Check]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .status() + * .type() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Check = + Check( + checkRequired("id", id), + checkRequired("status", status), + checkRequired("type", type), + checkRequired("updated", updated), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Check = apply { + if (validated) { + return@apply + } + + id() + status().validate() + type().validate() + updated() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Check && + id == other.id && + status == other.status && + type == other.type && + updated == other.updated && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, status, type, updated, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Check{id=$id, status=$status, type=$type, updated=$updated, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt new file mode 100644 index 00000000..e4f88658 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt @@ -0,0 +1,257 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CheckDeleteParams +private constructor( + private val id: String, + private val submissionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun id(): String = id + + fun submissionId(): Optional = Optional.ofNullable(submissionId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CheckDeleteParams]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CheckDeleteParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var submissionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(checkDeleteParams: CheckDeleteParams) = apply { + id = checkDeleteParams.id + submissionId = checkDeleteParams.submissionId + additionalHeaders = checkDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = checkDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = checkDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun id(id: String) = apply { this.id = id } + + fun submissionId(submissionId: String?) = apply { this.submissionId = submissionId } + + /** Alias for calling [Builder.submissionId] with `submissionId.orElse(null)`. */ + fun submissionId(submissionId: Optional) = submissionId(submissionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CheckDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CheckDeleteParams = + CheckDeleteParams( + checkRequired("id", id), + submissionId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id + 1 -> submissionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CheckDeleteParams && + id == other.id && + submissionId == other.submissionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + id, + submissionId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "CheckDeleteParams{id=$id, submissionId=$submissionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt new file mode 100644 index 00000000..cec93f6b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CheckListParams +private constructor( + private val id: String, + private val submissionId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): String = id + + fun submissionId(): Optional = Optional.ofNullable(submissionId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CheckListParams]. + * + * The following fields are required: + * ```java + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CheckListParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var submissionId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(checkListParams: CheckListParams) = apply { + id = checkListParams.id + submissionId = checkListParams.submissionId + additionalHeaders = checkListParams.additionalHeaders.toBuilder() + additionalQueryParams = checkListParams.additionalQueryParams.toBuilder() + } + + fun id(id: String) = apply { this.id = id } + + fun submissionId(submissionId: String?) = apply { this.submissionId = submissionId } + + /** Alias for calling [Builder.submissionId] with `submissionId.orElse(null)`. */ + fun submissionId(submissionId: Optional) = submissionId(submissionId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CheckListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CheckListParams = + CheckListParams( + checkRequired("id", id), + submissionId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id + 1 -> submissionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CheckListParams && + id == other.id && + submissionId == other.submissionId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(id, submissionId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CheckListParams{id=$id, submissionId=$submissionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt new file mode 100644 index 00000000..b9032b32 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CheckListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val checks: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("checks") @ExcludeMissing checks: JsonField> = JsonMissing.of() + ) : this(checks, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun checks(): List = checks.getRequired("checks") + + /** + * Returns the raw JSON value of [checks]. + * + * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): JsonField> = checks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CheckListResponse]. + * + * The following fields are required: + * ```java + * .checks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CheckListResponse]. */ + class Builder internal constructor() { + + private var checks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(checkListResponse: CheckListResponse) = apply { + checks = checkListResponse.checks.map { it.toMutableList() } + additionalProperties = checkListResponse.additionalProperties.toMutableMap() + } + + fun checks(checks: List) = checks(JsonField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary JSON value. + * + * You should usually call [Builder.checks] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun checks(checks: JsonField>) = apply { + this.checks = checks.map { it.toMutableList() } + } + + /** + * Adds a single [Check] to [checks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCheck(check: Check) = apply { + checks = + (checks ?: JsonField.of(mutableListOf())).also { + checkKnown("checks", it).add(check) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CheckListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .checks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CheckListResponse = + CheckListResponse( + checkRequired("checks", checks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CheckListResponse = apply { + if (validated) { + return@apply + } + + checks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (checks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CheckListResponse && + checks == other.checks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(checks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CheckListResponse{checks=$checks, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt new file mode 100644 index 00000000..da33d0cf --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt @@ -0,0 +1,471 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CheckUpdateParams +private constructor( + private val id: String, + private val submissionId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): String = id + + fun submissionId(): Optional = Optional.ofNullable(submissionId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun checks(): List = body.checks() + + /** + * Returns the raw JSON value of [checks]. + * + * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _checks(): JsonField> = body._checks() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CheckUpdateParams]. + * + * The following fields are required: + * ```java + * .id() + * .checks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CheckUpdateParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var submissionId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(checkUpdateParams: CheckUpdateParams) = apply { + id = checkUpdateParams.id + submissionId = checkUpdateParams.submissionId + body = checkUpdateParams.body.toBuilder() + additionalHeaders = checkUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = checkUpdateParams.additionalQueryParams.toBuilder() + } + + fun id(id: String) = apply { this.id = id } + + fun submissionId(submissionId: String?) = apply { this.submissionId = submissionId } + + /** Alias for calling [Builder.submissionId] with `submissionId.orElse(null)`. */ + fun submissionId(submissionId: Optional) = submissionId(submissionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [checks] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun checks(checks: List) = apply { body.checks(checks) } + + /** + * Sets [Builder.checks] to an arbitrary JSON value. + * + * You should usually call [Builder.checks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun checks(checks: JsonField>) = apply { body.checks(checks) } + + /** + * Adds a single [BaseCheck] to [checks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCheck(check: BaseCheck) = apply { body.addCheck(check) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CheckUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .checks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CheckUpdateParams = + CheckUpdateParams( + checkRequired("id", id), + submissionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id + 1 -> submissionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val checks: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("checks") + @ExcludeMissing + checks: JsonField> = JsonMissing.of() + ) : this(checks, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun checks(): List = checks.getRequired("checks") + + /** + * Returns the raw JSON value of [checks]. + * + * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): JsonField> = checks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .checks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var checks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + checks = body.checks.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun checks(checks: List) = checks(JsonField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary JSON value. + * + * You should usually call [Builder.checks] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun checks(checks: JsonField>) = apply { + this.checks = checks.map { it.toMutableList() } + } + + /** + * Adds a single [BaseCheck] to [checks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCheck(check: BaseCheck) = apply { + checks = + (checks ?: JsonField.of(mutableListOf())).also { + checkKnown("checks", it).add(check) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .checks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("checks", checks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + checks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (checks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + checks == other.checks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(checks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{checks=$checks, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CheckUpdateParams && + id == other.id && + submissionId == other.submissionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(id, submissionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CheckUpdateParams{id=$id, submissionId=$submissionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt new file mode 100644 index 00000000..247b068e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class CheckUpdateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val checks: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("checks") @ExcludeMissing checks: JsonField> = JsonMissing.of() + ) : this(checks, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun checks(): List = checks.getRequired("checks") + + /** + * Returns the raw JSON value of [checks]. + * + * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("checks") @ExcludeMissing fun _checks(): JsonField> = checks + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [CheckUpdateResponse]. + * + * The following fields are required: + * ```java + * .checks() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CheckUpdateResponse]. */ + class Builder internal constructor() { + + private var checks: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(checkUpdateResponse: CheckUpdateResponse) = apply { + checks = checkUpdateResponse.checks.map { it.toMutableList() } + additionalProperties = checkUpdateResponse.additionalProperties.toMutableMap() + } + + fun checks(checks: List) = checks(JsonField.of(checks)) + + /** + * Sets [Builder.checks] to an arbitrary JSON value. + * + * You should usually call [Builder.checks] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun checks(checks: JsonField>) = apply { + this.checks = checks.map { it.toMutableList() } + } + + /** + * Adds a single [Check] to [checks]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCheck(check: Check) = apply { + checks = + (checks ?: JsonField.of(mutableListOf())).also { + checkKnown("checks", it).add(check) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CheckUpdateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .checks() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CheckUpdateResponse = + CheckUpdateResponse( + checkRequired("checks", checks).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CheckUpdateResponse = apply { + if (validated) { + return@apply + } + + checks().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (checks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CheckUpdateResponse && + checks == other.checks && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(checks, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CheckUpdateResponse{checks=$checks, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt new file mode 100644 index 00000000..5c43c165 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.draft + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class DraftRetrieveContentParams +private constructor( + private val id: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun id(): Optional = Optional.ofNullable(id) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DraftRetrieveContentParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [DraftRetrieveContentParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DraftRetrieveContentParams]. */ + class Builder internal constructor() { + + private var id: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(draftRetrieveContentParams: DraftRetrieveContentParams) = apply { + id = draftRetrieveContentParams.id + additionalHeaders = draftRetrieveContentParams.additionalHeaders.toBuilder() + additionalQueryParams = draftRetrieveContentParams.additionalQueryParams.toBuilder() + } + + fun id(id: String?) = apply { this.id = id } + + /** Alias for calling [Builder.id] with `id.orElse(null)`. */ + fun id(id: Optional) = id(id.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DraftRetrieveContentParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DraftRetrieveContentParams = + DraftRetrieveContentParams(id, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> id ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DraftRetrieveContentParams && + id == other.id && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DraftRetrieveContentParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt new file mode 100644 index 00000000..3152fbfa --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt @@ -0,0 +1,534 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Merge the supplied values with an existing profile or create a new profile if one doesn't already + * exist. + */ +class ProfileCreateParams +private constructor( + private val userId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun profile(): Profile = body.profile() + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _profile(): JsonField = body._profile() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProfileCreateParams]. + * + * The following fields are required: + * ```java + * .profile() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileCreateParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(profileCreateParams: ProfileCreateParams) = apply { + userId = profileCreateParams.userId + body = profileCreateParams.body.toBuilder() + additionalHeaders = profileCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = profileCreateParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [profile] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun profile(profile: Profile) = apply { body.profile(profile) } + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun profile(profile: JsonField) = apply { body.profile(profile) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ProfileCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .profile() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProfileCreateParams = + ProfileCreateParams( + userId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val profile: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of() + ) : this(profile, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun profile(): Profile = profile.getRequired("profile") + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .profile() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var profile: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + profile = body.profile + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun profile(profile: Profile) = profile(JsonField.of(profile)) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .profile() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("profile", profile), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + profile().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (profile.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + profile == other.profile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(profile, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{profile=$profile, additionalProperties=$additionalProperties}" + } + + class Profile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Profile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Profile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profile: Profile) = apply { + additionalProperties = profile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Profile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Profile = Profile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Profile{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileCreateParams && + userId == other.userId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ProfileCreateParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt new file mode 100644 index 00000000..3fbea25f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ProfileCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProfileCreateResponse]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileCreateResponse]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profileCreateResponse: ProfileCreateResponse) = apply { + status = profileCreateResponse.status + additionalProperties = profileCreateResponse.additionalProperties.toMutableMap() + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProfileCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProfileCreateResponse = + ProfileCreateResponse( + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProfileCreateResponse = apply { + if (validated) { + return@apply + } + + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("SUCCESS") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCESS + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileCreateResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProfileCreateResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt new file mode 100644 index 00000000..00f0c4ec --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Deletes the specified user profile. */ +class ProfileDeleteParams +private constructor( + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ProfileDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ProfileDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileDeleteParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profileDeleteParams: ProfileDeleteParams) = apply { + userId = profileDeleteParams.userId + additionalHeaders = profileDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = profileDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = profileDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ProfileDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProfileDeleteParams = + ProfileDeleteParams( + userId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileDeleteParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ProfileDeleteParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt new file mode 100644 index 00000000..b098e69f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt @@ -0,0 +1,536 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * When using `PUT`, be sure to include all the key-value pairs required by the recipient's profile. + * Any key-value pairs that exist in the profile but fail to be included in the `PUT` request will + * be removed from the profile. Remember, a `PUT` update is a full replacement of the data. For + * partial updates, use the [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. + */ +class ProfileReplaceParams +private constructor( + private val userId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun profile(): Profile = body.profile() + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _profile(): JsonField = body._profile() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProfileReplaceParams]. + * + * The following fields are required: + * ```java + * .profile() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileReplaceParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(profileReplaceParams: ProfileReplaceParams) = apply { + userId = profileReplaceParams.userId + body = profileReplaceParams.body.toBuilder() + additionalHeaders = profileReplaceParams.additionalHeaders.toBuilder() + additionalQueryParams = profileReplaceParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [profile] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun profile(profile: Profile) = apply { body.profile(profile) } + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun profile(profile: JsonField) = apply { body.profile(profile) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ProfileReplaceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .profile() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProfileReplaceParams = + ProfileReplaceParams( + userId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val profile: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of() + ) : this(profile, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun profile(): Profile = profile.getRequired("profile") + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .profile() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var profile: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + profile = body.profile + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun profile(profile: Profile) = profile(JsonField.of(profile)) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .profile() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("profile", profile), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + profile().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (profile.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + profile == other.profile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(profile, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{profile=$profile, additionalProperties=$additionalProperties}" + } + + class Profile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Profile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Profile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profile: Profile) = apply { + additionalProperties = profile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Profile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Profile = Profile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Profile{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileReplaceParams && + userId == other.userId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ProfileReplaceParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt new file mode 100644 index 00000000..aece92bb --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ProfileReplaceResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProfileReplaceResponse]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileReplaceResponse]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profileReplaceResponse: ProfileReplaceResponse) = apply { + status = profileReplaceResponse.status + additionalProperties = profileReplaceResponse.additionalProperties.toMutableMap() + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProfileReplaceResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProfileReplaceResponse = + ProfileReplaceResponse( + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProfileReplaceResponse = apply { + if (validated) { + return@apply + } + + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("SUCCESS") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCESS + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileReplaceResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProfileReplaceResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt new file mode 100644 index 00000000..f1473061 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns the specified user profile. */ +class ProfileRetrieveParams +private constructor( + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ProfileRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ProfileRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileRetrieveParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(profileRetrieveParams: ProfileRetrieveParams) = apply { + userId = profileRetrieveParams.userId + additionalHeaders = profileRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = profileRetrieveParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ProfileRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ProfileRetrieveParams = + ProfileRetrieveParams(userId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileRetrieveParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(userId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ProfileRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt new file mode 100644 index 00000000..3cad1eaf --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt @@ -0,0 +1,318 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ProfileRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val profile: JsonField, + private val preferences: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + ) : this(profile, preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun profile(): Profile = profile.getRequired("profile") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProfileRetrieveResponse]. + * + * The following fields are required: + * ```java + * .profile() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileRetrieveResponse]. */ + class Builder internal constructor() { + + private var profile: JsonField? = null + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profileRetrieveResponse: ProfileRetrieveResponse) = apply { + profile = profileRetrieveResponse.profile + preferences = profileRetrieveResponse.preferences + additionalProperties = profileRetrieveResponse.additionalProperties.toMutableMap() + } + + fun profile(profile: Profile) = profile(JsonField.of(profile)) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ProfileRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .profile() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProfileRetrieveResponse = + ProfileRetrieveResponse( + checkRequired("profile", profile), + preferences, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ProfileRetrieveResponse = apply { + if (validated) { + return@apply + } + + profile().validate() + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (profile.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + class Profile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Profile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Profile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profile: Profile) = apply { + additionalProperties = profile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Profile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Profile = Profile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Profile{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileRetrieveResponse && + profile == other.profile && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(profile, preferences, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ProfileRetrieveResponse{profile=$profile, preferences=$preferences, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt new file mode 100644 index 00000000..bba60512 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt @@ -0,0 +1,699 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a profile */ +class ProfileUpdateParams +private constructor( + private val userId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** + * List of patch operations to apply to the profile. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun patch(): List = body.patch() + + /** + * Returns the raw JSON value of [patch]. + * + * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _patch(): JsonField> = body._patch() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProfileUpdateParams]. + * + * The following fields are required: + * ```java + * .patch() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ProfileUpdateParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(profileUpdateParams: ProfileUpdateParams) = apply { + userId = profileUpdateParams.userId + body = profileUpdateParams.body.toBuilder() + additionalHeaders = profileUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = profileUpdateParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [patch] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** List of patch operations to apply to the profile. */ + fun patch(patch: List) = apply { body.patch(patch) } + + /** + * Sets [Builder.patch] to an arbitrary JSON value. + * + * You should usually call [Builder.patch] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun patch(patch: JsonField>) = apply { body.patch(patch) } + + /** + * Adds a single [Patch] to [Builder.patch]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPatch(patch: Patch) = apply { body.addPatch(patch) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ProfileUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .patch() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProfileUpdateParams = + ProfileUpdateParams( + userId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val patch: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("patch") @ExcludeMissing patch: JsonField> = JsonMissing.of() + ) : this(patch, mutableMapOf()) + + /** + * List of patch operations to apply to the profile. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun patch(): List = patch.getRequired("patch") + + /** + * Returns the raw JSON value of [patch]. + * + * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("patch") @ExcludeMissing fun _patch(): JsonField> = patch + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .patch() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var patch: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + patch = body.patch.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** List of patch operations to apply to the profile. */ + fun patch(patch: List) = patch(JsonField.of(patch)) + + /** + * Sets [Builder.patch] to an arbitrary JSON value. + * + * You should usually call [Builder.patch] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patch(patch: JsonField>) = apply { + this.patch = patch.map { it.toMutableList() } + } + + /** + * Adds a single [Patch] to [Builder.patch]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPatch(patch: Patch) = apply { + this.patch = + (this.patch ?: JsonField.of(mutableListOf())).also { + checkKnown("patch", it).add(patch) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .patch() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("patch", patch).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + patch().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (patch.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + patch == other.patch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(patch, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{patch=$patch, additionalProperties=$additionalProperties}" + } + + class Patch + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val op: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("op") @ExcludeMissing op: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(op, path, value, mutableMapOf()) + + /** + * The operation to perform. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun op(): String = op.getRequired("op") + + /** + * The JSON path specifying the part of the profile to operate on. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun path(): String = path.getRequired("path") + + /** + * The value for the operation. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [op]. + * + * Unlike [op], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("op") @ExcludeMissing fun _op(): JsonField = op + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Patch]. + * + * The following fields are required: + * ```java + * .op() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Patch]. */ + class Builder internal constructor() { + + private var op: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patch: Patch) = apply { + op = patch.op + path = patch.path + value = patch.value + additionalProperties = patch.additionalProperties.toMutableMap() + } + + /** The operation to perform. */ + fun op(op: String) = op(JsonField.of(op)) + + /** + * Sets [Builder.op] to an arbitrary JSON value. + * + * You should usually call [Builder.op] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun op(op: JsonField) = apply { this.op = op } + + /** The JSON path specifying the part of the profile to operate on. */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + /** The value for the operation. */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Patch]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .op() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Patch = + Patch( + checkRequired("op", op), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Patch = apply { + if (validated) { + return@apply + } + + op() + path() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (op.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Patch && + op == other.op && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(op, path, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Patch{op=$op, path=$path, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProfileUpdateParams && + userId == other.userId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ProfileUpdateParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt new file mode 100644 index 00000000..2ec008a1 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Removes all list subscriptions for given user. */ +class ListDeleteParams +private constructor( + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ListDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ListDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListDeleteParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listDeleteParams: ListDeleteParams) = apply { + userId = listDeleteParams.userId + additionalHeaders = listDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = listDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = listDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ListDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ListDeleteParams = + ListDeleteParams( + userId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListDeleteParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "ListDeleteParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt new file mode 100644 index 00000000..87e9f656 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt @@ -0,0 +1,288 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ListDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListDeleteResponse]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListDeleteResponse]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listDeleteResponse: ListDeleteResponse) = apply { + status = listDeleteResponse.status + additionalProperties = listDeleteResponse.additionalProperties.toMutableMap() + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ListDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListDeleteResponse = + ListDeleteResponse(checkRequired("status", status), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ListDeleteResponse = apply { + if (validated) { + return@apply + } + + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("SUCCESS") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCESS + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListDeleteResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListDeleteResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt new file mode 100644 index 00000000..58865be6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns the subscribed lists for a specified user. */ +class ListRetrieveParams +private constructor( + private val userId: String?, + private val cursor: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** A unique identifier that allows for fetching the next set of message statuses. */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ListRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ListRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRetrieveParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var cursor: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(listRetrieveParams: ListRetrieveParams) = apply { + userId = listRetrieveParams.userId + cursor = listRetrieveParams.cursor + additionalHeaders = listRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = listRetrieveParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** A unique identifier that allows for fetching the next set of message statuses. */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ListRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ListRetrieveParams = + ListRetrieveParams( + userId, + cursor, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListRetrieveParams && + userId == other.userId && + cursor == other.cursor && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, cursor, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ListRetrieveParams{userId=$userId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt new file mode 100644 index 00000000..c9315e95 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt @@ -0,0 +1,547 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ListRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val paging: JsonField, + private val results: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of(), + ) : this(paging, results, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * An array of lists + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun results(): List = results.getRequired("results") + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + /** + * Returns the raw JSON value of [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListRetrieveResponse]. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListRetrieveResponse]. */ + class Builder internal constructor() { + + private var paging: JsonField? = null + private var results: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listRetrieveResponse: ListRetrieveResponse) = apply { + paging = listRetrieveResponse.paging + results = listRetrieveResponse.results.map { it.toMutableList() } + additionalProperties = listRetrieveResponse.additionalProperties.toMutableMap() + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + /** An array of lists */ + fun results(results: List) = results(JsonField.of(results)) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ListRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .results() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListRetrieveResponse = + ListRetrieveResponse( + checkRequired("paging", paging), + checkRequired("results", results).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListRetrieveResponse = apply { + if (validated) { + return@apply + } + + paging().validate() + results().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val created: JsonField, + private val name: JsonField, + private val updated: JsonField, + private val preferences: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + ) : this(id, created, name, updated, preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The date/time of when the list was created. Represented as a string in ISO format. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun created(): String = created.getRequired("created") + + /** + * List name + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * The date/time of when the list was updated. Represented as a string in ISO format. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updated(): String = updated.getRequired("updated") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [created]. + * + * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [updated]. + * + * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Result]. + * + * The following fields are required: + * ```java + * .id() + * .created() + * .name() + * .updated() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var created: JsonField? = null + private var name: JsonField? = null + private var updated: JsonField? = null + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + id = result.id + created = result.created + name = result.name + updated = result.updated + preferences = result.preferences + additionalProperties = result.additionalProperties.toMutableMap() + } + + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** + * The date/time of when the list was created. Represented as a string in ISO format. + */ + fun created(created: String) = created(JsonField.of(created)) + + /** + * Sets [Builder.created] to an arbitrary JSON value. + * + * You should usually call [Builder.created] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun created(created: JsonField) = apply { this.created = created } + + /** List name */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The date/time of when the list was updated. Represented as a string in ISO format. + */ + fun updated(updated: String) = updated(JsonField.of(updated)) + + /** + * Sets [Builder.updated] to an arbitrary JSON value. + * + * You should usually call [Builder.updated] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updated(updated: JsonField) = apply { this.updated = updated } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [RecipientPreferences] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .created() + * .name() + * .updated() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("id", id), + checkRequired("created", created), + checkRequired("name", name), + checkRequired("updated", updated), + preferences, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Result = apply { + if (validated) { + return@apply + } + + id() + created() + name() + updated() + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (created.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (updated.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + id == other.id && + created == other.created && + name == other.name && + updated == other.updated && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, created, name, updated, preferences, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{id=$id, created=$created, name=$name, updated=$updated, preferences=$preferences, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListRetrieveResponse && + paging == other.paging && + results == other.results && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListRetrieveResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt new file mode 100644 index 00000000..b8ae717f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt @@ -0,0 +1,664 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Subscribes the given user to one or more lists. If the list does not exist, it will be created. + */ +class ListSubscribeParams +private constructor( + private val userId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lists(): List = body.lists() + + /** + * Returns the raw JSON value of [lists]. + * + * Unlike [lists], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _lists(): JsonField> = body._lists() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListSubscribeParams]. + * + * The following fields are required: + * ```java + * .lists() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListSubscribeParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(listSubscribeParams: ListSubscribeParams) = apply { + userId = listSubscribeParams.userId + body = listSubscribeParams.body.toBuilder() + additionalHeaders = listSubscribeParams.additionalHeaders.toBuilder() + additionalQueryParams = listSubscribeParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [lists] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun lists(lists: List) = apply { body.lists(lists) } + + /** + * Sets [Builder.lists] to an arbitrary JSON value. + * + * You should usually call [Builder.lists] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lists(lists: JsonField>) = apply { body.lists(lists) } + + /** + * Adds a single [List] to [lists]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { body.addList(list) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ListSubscribeParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .lists() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListSubscribeParams = + ListSubscribeParams( + userId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lists: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("lists") @ExcludeMissing lists: JsonField> = JsonMissing.of() + ) : this(lists, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun lists(): List = lists.getRequired("lists") + + /** + * Returns the raw JSON value of [lists]. + * + * Unlike [lists], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lists") @ExcludeMissing fun _lists(): JsonField> = lists + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .lists() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var lists: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + lists = body.lists.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun lists(lists: List) = lists(JsonField.of(lists)) + + /** + * Sets [Builder.lists] to an arbitrary JSON value. + * + * You should usually call [Builder.lists] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lists(lists: JsonField>) = apply { + this.lists = lists.map { it.toMutableList() } + } + + /** + * Adds a single [List] to [lists]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addList(list: List) = apply { + lists = + (lists ?: JsonField.of(mutableListOf())).also { + checkKnown("lists", it).add(list) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .lists() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("lists", lists).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + lists().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (lists.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + lists == other.lists && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(lists, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{lists=$lists, additionalProperties=$additionalProperties}" + } + + class List + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val listId: JsonField, + private val preferences: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("listId") @ExcludeMissing listId: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + ) : this(listId, preferences, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun listId(): String = listId.getRequired("listId") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Returns the raw JSON value of [listId]. + * + * Unlike [listId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("listId") @ExcludeMissing fun _listId(): JsonField = listId + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [List]. + * + * The following fields are required: + * ```java + * .listId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [List]. */ + class Builder internal constructor() { + + private var listId: JsonField? = null + private var preferences: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(list: List) = apply { + listId = list.listId + preferences = list.preferences + additionalProperties = list.additionalProperties.toMutableMap() + } + + fun listId(listId: String) = listId(JsonField.of(listId)) + + /** + * Sets [Builder.listId] to an arbitrary JSON value. + * + * You should usually call [Builder.listId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun listId(listId: JsonField) = apply { this.listId = listId } + + fun preferences(preferences: RecipientPreferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [RecipientPreferences] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [List]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .listId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): List = + List( + checkRequired("listId", listId), + preferences, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): List = apply { + if (validated) { + return@apply + } + + listId() + preferences().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (listId.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is List && + listId == other.listId && + preferences == other.preferences && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(listId, preferences, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "List{listId=$listId, preferences=$preferences, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListSubscribeParams && + userId == other.userId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ListSubscribeParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt new file mode 100644 index 00000000..63337ea9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ListSubscribeResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() + ) : this(status, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ListSubscribeResponse]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ListSubscribeResponse]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(listSubscribeResponse: ListSubscribeResponse) = apply { + status = listSubscribeResponse.status + additionalProperties = listSubscribeResponse.additionalProperties.toMutableMap() + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ListSubscribeResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ListSubscribeResponse = + ListSubscribeResponse( + checkRequired("status", status), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ListSubscribeResponse = apply { + if (validated) { + return@apply + } + + status().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUCCESS = of("SUCCESS") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + SUCCESS + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUCCESS, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUCCESS -> Value.SUCCESS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUCCESS -> Known.SUCCESS + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ListSubscribeResponse && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ListSubscribeResponse{status=$status, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt new file mode 100644 index 00000000..7a8d7632 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.requests + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Archive message */ +class RequestArchiveParams +private constructor( + private val requestId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun requestId(): Optional = Optional.ofNullable(requestId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): RequestArchiveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [RequestArchiveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RequestArchiveParams]. */ + class Builder internal constructor() { + + private var requestId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(requestArchiveParams: RequestArchiveParams) = apply { + requestId = requestArchiveParams.requestId + additionalHeaders = requestArchiveParams.additionalHeaders.toBuilder() + additionalQueryParams = requestArchiveParams.additionalQueryParams.toBuilder() + additionalBodyProperties = requestArchiveParams.additionalBodyProperties.toMutableMap() + } + + fun requestId(requestId: String?) = apply { this.requestId = requestId } + + /** Alias for calling [Builder.requestId] with `requestId.orElse(null)`. */ + fun requestId(requestId: Optional) = requestId(requestId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [RequestArchiveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RequestArchiveParams = + RequestArchiveParams( + requestId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> requestId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RequestArchiveParams && + requestId == other.requestId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(requestId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "RequestArchiveParams{requestId=$requestId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt new file mode 100644 index 00000000..9c8edb31 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt @@ -0,0 +1,4181 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BaseMessage +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val brandId: JsonField, + private val channels: JsonField, + private val context: JsonField, + private val data: JsonField, + private val delay: JsonField, + private val expiry: JsonField, + private val metadata: JsonField, + private val preferences: JsonField, + private val providers: JsonField, + private val routing: JsonField, + private val timeout: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), + @JsonProperty("channels") @ExcludeMissing channels: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("delay") @ExcludeMissing delay: JsonField = JsonMissing.of(), + @JsonProperty("expiry") @ExcludeMissing expiry: JsonField = JsonMissing.of(), + @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + @JsonProperty("routing") @ExcludeMissing routing: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + ) : this( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + mutableMapOf(), + ) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * "Define run-time configuration for one or more channels. If you don't specify channels, the + * default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, + * inbox, direct_message, banner, and webhook." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * Context to load with this recipient. Will override any context set on message.context. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * An arbitrary object that includes any data you want to pass to the message. The data will + * populate the corresponding template or elements variables. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Defines the time to wait before delivering the message. You can specify one of the following + * options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp + * that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like + * format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun delay(): Optional = delay.getOptional("delay") + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. Note: This + * is only valid for the Courier Inbox channel as of 12-08-2022." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiry(): Optional = expiry.getOptional("expiry") + + /** + * Metadata such as utm tracking attached with the notification through this channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * An object whose keys are valid provider identifiers which map to an object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the message. If no + * routing key is specified, Courier will use the default routing configuration or routing + * defined by the template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routing(): Optional = routing.getOptional("routing") + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [delay]. + * + * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay + + /** + * Returns the raw JSON value of [expiry]. + * + * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry") @ExcludeMissing fun _expiry(): JsonField = expiry + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("providers") @ExcludeMissing fun _providers(): JsonField = providers + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") @ExcludeMissing fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BaseMessage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BaseMessage]. */ + class Builder internal constructor() { + + private var brandId: JsonField = JsonMissing.of() + private var channels: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var delay: JsonField = JsonMissing.of() + private var expiry: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var routing: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(baseMessage: BaseMessage) = apply { + brandId = baseMessage.brandId + channels = baseMessage.channels + context = baseMessage.context + data = baseMessage.data + delay = baseMessage.delay + expiry = baseMessage.expiry + metadata = baseMessage.metadata + preferences = baseMessage.preferences + providers = baseMessage.providers + routing = baseMessage.routing + timeout = baseMessage.timeout + additionalProperties = baseMessage.additionalProperties.toMutableMap() + } + + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * "Define run-time configuration for one or more channels. If you don't specify channels, + * the default configuration for each channel will be used. Valid ChannelId's are: email, + * sms, push, inbox, direct_message, banner, and webhook." + */ + fun channels(channels: Channels?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed [Channels] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun channels(channels: JsonField) = apply { this.channels = channels } + + /** + * Context to load with this recipient. Will override any context set on message.context. + */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + /** + * An arbitrary object that includes any data you want to pass to the message. The data will + * populate the corresponding template or elements variables. + */ + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an ISO + * 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap + * opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + fun delay(delay: Delay?) = delay(JsonField.ofNullable(delay)) + + /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ + fun delay(delay: Optional) = delay(delay.getOrNull()) + + /** + * Sets [Builder.delay] to an arbitrary JSON value. + * + * You should usually call [Builder.delay] with a well-typed [Delay] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun delay(delay: JsonField) = apply { this.delay = delay } + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. Note: + * This is only valid for the Courier Inbox channel as of 12-08-2022." + */ + fun expiry(expiry: Expiry?) = expiry(JsonField.ofNullable(expiry)) + + /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ + fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) + + /** + * Sets [Builder.expiry] to an arbitrary JSON value. + * + * You should usually call [Builder.expiry] with a well-typed [Expiry] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expiry(expiry: JsonField) = apply { this.expiry = expiry } + + /** Metadata such as utm tracking attached with the notification through this channel. */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun preferences(preferences: Preferences?) = preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [Preferences] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** An object whose keys are valid provider identifiers which map to an object. */ + fun providers(providers: Providers?) = providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed [Providers] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun providers(providers: JsonField) = apply { this.providers = providers } + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the message. If + * no routing key is specified, Courier will use the default routing configuration or + * routing defined by the template. + */ + fun routing(routing: Routing?) = routing(JsonField.ofNullable(routing)) + + /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ + fun routing(routing: Optional) = routing(routing.getOrNull()) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [Routing] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun routing(routing: JsonField) = apply { this.routing = routing } + + /** Time in ms to attempt the channel before failing over to the next available channel. */ + fun timeout(timeout: Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Timeout] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BaseMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BaseMessage = + BaseMessage( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BaseMessage = apply { + if (validated) { + return@apply + } + + brandId() + channels().ifPresent { it.validate() } + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + delay().ifPresent { it.validate() } + expiry().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + preferences().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + routing().ifPresent { it.validate() } + timeout().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brandId.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (delay.asKnown().getOrNull()?.validity() ?: 0) + + (expiry.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + /** + * "Define run-time configuration for one or more channels. If you don't specify channels, the + * default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, + * inbox, direct_message, banner, and webhook." + */ + class Channels + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Channels]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Channels]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channels: Channels) = apply { + additionalProperties = channels.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Channels]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Channels = Channels(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Channels = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channels && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Channels{additionalProperties=$additionalProperties}" + } + + /** + * An arbitrary object that includes any data you want to pass to the message. The data will + * populate the corresponding template or elements variables. + */ + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + /** + * Defines the time to wait before delivering the message. You can specify one of the following + * options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp + * that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like + * format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + class Delay + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val duration: JsonField, + private val until: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("until") @ExcludeMissing until: JsonField = JsonMissing.of(), + ) : this(duration, until, mutableMapOf()) + + /** + * The duration of the delay in milliseconds. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap + * opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun until(): Optional = until.getOptional("until") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [until]. + * + * Unlike [until], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Delay]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Delay]. */ + class Builder internal constructor() { + + private var duration: JsonField = JsonMissing.of() + private var until: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(delay: Delay) = apply { + duration = delay.duration + until = delay.until + additionalProperties = delay.additionalProperties.toMutableMap() + } + + /** The duration of the delay in milliseconds. */ + fun duration(duration: Long?) = duration(JsonField.ofNullable(duration)) + + /** + * Alias for [Builder.duration]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun duration(duration: Long) = duration(duration as Long?) + + /** Alias for calling [Builder.duration] with `duration.orElse(null)`. */ + fun duration(duration: Optional) = duration(duration.getOrNull()) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** + * An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap + * opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + fun until(until: String?) = until(JsonField.ofNullable(until)) + + /** Alias for calling [Builder.until] with `until.orElse(null)`. */ + fun until(until: Optional) = until(until.getOrNull()) + + /** + * Sets [Builder.until] to an arbitrary JSON value. + * + * You should usually call [Builder.until] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun until(until: JsonField) = apply { this.until = until } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Delay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Delay = Delay(duration, until, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Delay = apply { + if (validated) { + return@apply + } + + duration() + until() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + (if (until.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Delay && + duration == other.duration && + until == other.until && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, until, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Delay{duration=$duration, until=$until, additionalProperties=$additionalProperties}" + } + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. Note: This + * is only valid for the Courier Inbox channel as of 12-08-2022." + */ + class Expiry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expiresIn: JsonField, + private val expiresAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expires_in") + @ExcludeMissing + expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField = JsonMissing.of(), + ) : this(expiresIn, expiresAt, mutableMapOf()) + + /** + * A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun expiresIn(): ExpiresIn = expiresIn.getRequired("expires_in") + + /** + * An epoch timestamp or ISO8601 timestamp with timezone `(YYYY-MM-DDThh:mm:ss.sTZD)` that + * describes the time in which a message expires. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresAt(): Optional = expiresAt.getOptional("expires_at") + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") + @ExcludeMissing + fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") @ExcludeMissing fun _expiresAt(): JsonField = expiresAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Expiry]. + * + * The following fields are required: + * ```java + * .expiresIn() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Expiry]. */ + class Builder internal constructor() { + + private var expiresIn: JsonField? = null + private var expiresAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(expiry: Expiry) = apply { + expiresIn = expiry.expiresIn + expiresAt = expiry.expiresAt + additionalProperties = expiry.additionalProperties.toMutableMap() + } + + /** + * A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). + */ + fun expiresIn(expiresIn: ExpiresIn) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [ExpiresIn] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** Alias for calling [expiresIn] with `ExpiresIn.ofString(string)`. */ + fun expiresIn(string: String) = expiresIn(ExpiresIn.ofString(string)) + + /** Alias for calling [expiresIn] with `ExpiresIn.ofInteger(integer)`. */ + fun expiresIn(integer: Long) = expiresIn(ExpiresIn.ofInteger(integer)) + + /** + * An epoch timestamp or ISO8601 timestamp with timezone `(YYYY-MM-DDThh:mm:ss.sTZD)` + * that describes the time in which a message expires. + */ + fun expiresAt(expiresAt: String?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Expiry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expiresIn() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Expiry = + Expiry( + checkRequired("expiresIn", expiresIn), + expiresAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Expiry = apply { + if (validated) { + return@apply + } + + expiresIn().validate() + expiresAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (expiresIn.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + /** A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). */ + @JsonDeserialize(using = ExpiresIn.Deserializer::class) + @JsonSerialize(using = ExpiresIn.Serializer::class) + class ExpiresIn + private constructor( + private val string: String? = null, + private val integer: Long? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun integer(): Optional = Optional.ofNullable(integer) + + fun isString(): Boolean = string != null + + fun isInteger(): Boolean = integer != null + + fun asString(): String = string.getOrThrow("string") + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + integer != null -> visitor.visitInteger(integer) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ExpiresIn = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitInteger(integer: Long) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExpiresIn && string == other.string && integer == other.integer + } + + override fun hashCode(): Int = Objects.hash(string, integer) + + override fun toString(): String = + when { + string != null -> "ExpiresIn{string=$string}" + integer != null -> "ExpiresIn{integer=$integer}" + _json != null -> "ExpiresIn{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ExpiresIn") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ExpiresIn(string = string) + + @JvmStatic fun ofInteger(integer: Long) = ExpiresIn(integer = integer) + } + + /** + * An interface that defines how to map each variant of [ExpiresIn] to a value of type + * [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitInteger(integer: Long): T + + /** + * Maps an unknown variant of [ExpiresIn] to a value of type [T]. + * + * An instance of [ExpiresIn] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ExpiresIn: $json") + } + } + + internal class Deserializer : BaseDeserializer(ExpiresIn::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ExpiresIn { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ExpiresIn(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ExpiresIn(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> ExpiresIn(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ExpiresIn::class) { + + override fun serialize( + value: ExpiresIn, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.integer != null -> generator.writeObject(value.integer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ExpiresIn") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Expiry && + expiresIn == other.expiresIn && + expiresAt == other.expiresAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expiresIn, expiresAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Expiry{expiresIn=$expiresIn, expiresAt=$expiresAt, additionalProperties=$additionalProperties}" + } + + /** Metadata such as utm tracking attached with the notification through this channel. */ + class Metadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val event: JsonField, + private val tags: JsonField>, + private val traceId: JsonField, + private val utm: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), + @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), + @JsonProperty("utm") @ExcludeMissing utm: JsonField = JsonMissing.of(), + ) : this(event, tags, traceId, utm, mutableMapOf()) + + /** + * An arbitrary string to tracks the event that generated this request (e.g. 'signup'). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun event(): Optional = event.getOptional("event") + + /** + * An array of up to 9 tags you wish to associate with this request (and corresponding + * messages) for later analysis. Individual tags cannot be more than 30 characters in + * length. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * A unique ID used to correlate this request to processing on your servers. Note: Courier + * does not verify the uniqueness of this ID. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun traceId(): Optional = traceId.getOptional("trace_id") + + /** + * Identify the campaign that refers traffic to a specific website, and attributes the + * browser's website session. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun utm(): Optional = utm.getOptional("utm") + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField = traceId + + /** + * Returns the raw JSON value of [utm]. + * + * Unlike [utm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("utm") @ExcludeMissing fun _utm(): JsonField = utm + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var event: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var traceId: JsonField = JsonMissing.of() + private var utm: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + event = metadata.event + tags = metadata.tags.map { it.toMutableList() } + traceId = metadata.traceId + utm = metadata.utm + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * An arbitrary string to tracks the event that generated this request (e.g. 'signup'). + */ + fun event(event: String?) = event(JsonField.ofNullable(event)) + + /** Alias for calling [Builder.event] with `event.orElse(null)`. */ + fun event(event: Optional) = event(event.getOrNull()) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + /** + * An array of up to 9 tags you wish to associate with this request (and corresponding + * messages) for later analysis. Individual tags cannot be more than 30 characters in + * length. + */ + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } + } + + /** + * A unique ID used to correlate this request to processing on your servers. Note: + * Courier does not verify the uniqueness of this ID. + */ + fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) + + /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ + fun traceId(traceId: Optional) = traceId(traceId.getOrNull()) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun traceId(traceId: JsonField) = apply { this.traceId = traceId } + + /** + * Identify the campaign that refers traffic to a specific website, and attributes the + * browser's website session. + */ + fun utm(utm: Utm?) = utm(JsonField.ofNullable(utm)) + + /** Alias for calling [Builder.utm] with `utm.orElse(null)`. */ + fun utm(utm: Optional) = utm(utm.getOrNull()) + + /** + * Sets [Builder.utm] to an arbitrary JSON value. + * + * You should usually call [Builder.utm] with a well-typed [Utm] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun utm(utm: JsonField) = apply { this.utm = utm } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = + Metadata( + event, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + traceId, + utm, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + event() + tags() + traceId() + utm().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (event.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (utm.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + event == other.event && + tags == other.tags && + traceId == other.traceId && + utm == other.utm && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(event, tags, traceId, utm, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{event=$event, tags=$tags, traceId=$traceId, utm=$utm, additionalProperties=$additionalProperties}" + } + + class Preferences + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val subscriptionTopicId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("subscription_topic_id") + @ExcludeMissing + subscriptionTopicId: JsonField = JsonMissing.of() + ) : this(subscriptionTopicId, mutableMapOf()) + + /** + * The ID of the subscription topic you want to apply to the message. If this is a templated + * message, it will override the subscription topic if already associated + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun subscriptionTopicId(): String = subscriptionTopicId.getRequired("subscription_topic_id") + + /** + * Returns the raw JSON value of [subscriptionTopicId]. + * + * Unlike [subscriptionTopicId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_topic_id") + @ExcludeMissing + fun _subscriptionTopicId(): JsonField = subscriptionTopicId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Preferences]. + * + * The following fields are required: + * ```java + * .subscriptionTopicId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Preferences]. */ + class Builder internal constructor() { + + private var subscriptionTopicId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferences: Preferences) = apply { + subscriptionTopicId = preferences.subscriptionTopicId + additionalProperties = preferences.additionalProperties.toMutableMap() + } + + /** + * The ID of the subscription topic you want to apply to the message. If this is a + * templated message, it will override the subscription topic if already associated + */ + fun subscriptionTopicId(subscriptionTopicId: String) = + subscriptionTopicId(JsonField.of(subscriptionTopicId)) + + /** + * Sets [Builder.subscriptionTopicId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionTopicId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun subscriptionTopicId(subscriptionTopicId: JsonField) = apply { + this.subscriptionTopicId = subscriptionTopicId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Preferences]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionTopicId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Preferences = + Preferences( + checkRequired("subscriptionTopicId", subscriptionTopicId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Preferences = apply { + if (validated) { + return@apply + } + + subscriptionTopicId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (subscriptionTopicId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Preferences && + subscriptionTopicId == other.subscriptionTopicId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(subscriptionTopicId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Preferences{subscriptionTopicId=$subscriptionTopicId, additionalProperties=$additionalProperties}" + } + + /** An object whose keys are valid provider identifiers which map to an object. */ + class Providers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Providers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Providers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(providers: Providers) = apply { + additionalProperties = providers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Providers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Providers = Providers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Providers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Providers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Providers{additionalProperties=$additionalProperties}" + } + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the message. If no + * routing key is specified, Courier will use the default routing configuration or routing + * defined by the template. + */ + class Routing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val method: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + ) : this(channels, method, mutableMapOf()) + + /** + * A list of channels or providers to send the message through. Can also recursively define + * sub-routing methods, which can be useful for defining advanced push notification delivery + * strategies. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channels(): List = channels.getRequired("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun method(): RoutingMethod = method.getRequired("method") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Routing]. + * + * The following fields are required: + * ```java + * .channels() + * .method() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Routing]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var method: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routing: Routing) = apply { + channels = routing.channels.map { it.toMutableList() } + method = routing.method + additionalProperties = routing.additionalProperties.toMutableMap() + } + + /** + * A list of channels or providers to send the message through. Can also recursively + * define sub-routing methods, which can be useful for defining advanced push + * notification delivery strategies. + */ + fun channels(channels: List) = channels(JsonField.of(channels)) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [Channel] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: Channel) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** Alias for calling [addChannel] with `Channel.ofRoutingStrategy(routingStrategy)`. */ + fun addChannel(routingStrategy: Channel.RoutingStrategyChannel) = + addChannel(Channel.ofRoutingStrategy(routingStrategy)) + + /** + * Alias for calling [addChannel] with + * `Channel.ofRoutingStrategyProvider(routingStrategyProvider)`. + */ + fun addChannel(routingStrategyProvider: Channel.RoutingStrategyProvider) = + addChannel(Channel.ofRoutingStrategyProvider(routingStrategyProvider)) + + /** Alias for calling [addChannel] with `Channel.ofString(string)`. */ + fun addChannel(string: String) = addChannel(Channel.ofString(string)) + + fun method(method: RoutingMethod) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [RoutingMethod] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Routing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channels() + * .method() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Routing = + Routing( + checkRequired("channels", channels).map { it.toImmutable() }, + checkRequired("method", method), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Routing = apply { + if (validated) { + return@apply + } + + channels().forEach { it.validate() } + method().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Channel.Deserializer::class) + @JsonSerialize(using = Channel.Serializer::class) + class Channel + private constructor( + private val routingStrategy: RoutingStrategyChannel? = null, + private val routingStrategyProvider: RoutingStrategyProvider? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun routingStrategy(): Optional = + Optional.ofNullable(routingStrategy) + + fun routingStrategyProvider(): Optional = + Optional.ofNullable(routingStrategyProvider) + + fun string(): Optional = Optional.ofNullable(string) + + fun isRoutingStrategy(): Boolean = routingStrategy != null + + fun isRoutingStrategyProvider(): Boolean = routingStrategyProvider != null + + fun isString(): Boolean = string != null + + fun asRoutingStrategy(): RoutingStrategyChannel = + routingStrategy.getOrThrow("routingStrategy") + + fun asRoutingStrategyProvider(): RoutingStrategyProvider = + routingStrategyProvider.getOrThrow("routingStrategyProvider") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + routingStrategy != null -> visitor.visitRoutingStrategy(routingStrategy) + routingStrategyProvider != null -> + visitor.visitRoutingStrategyProvider(routingStrategyProvider) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitRoutingStrategy(routingStrategy: RoutingStrategyChannel) { + routingStrategy.validate() + } + + override fun visitRoutingStrategyProvider( + routingStrategyProvider: RoutingStrategyProvider + ) { + routingStrategyProvider.validate() + } + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitRoutingStrategy(routingStrategy: RoutingStrategyChannel) = + routingStrategy.validity() + + override fun visitRoutingStrategyProvider( + routingStrategyProvider: RoutingStrategyProvider + ) = routingStrategyProvider.validity() + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channel && + routingStrategy == other.routingStrategy && + routingStrategyProvider == other.routingStrategyProvider && + string == other.string + } + + override fun hashCode(): Int = + Objects.hash(routingStrategy, routingStrategyProvider, string) + + override fun toString(): String = + when { + routingStrategy != null -> "Channel{routingStrategy=$routingStrategy}" + routingStrategyProvider != null -> + "Channel{routingStrategyProvider=$routingStrategyProvider}" + string != null -> "Channel{string=$string}" + _json != null -> "Channel{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Channel") + } + + companion object { + + @JvmStatic + fun ofRoutingStrategy(routingStrategy: RoutingStrategyChannel) = + Channel(routingStrategy = routingStrategy) + + @JvmStatic + fun ofRoutingStrategyProvider(routingStrategyProvider: RoutingStrategyProvider) = + Channel(routingStrategyProvider = routingStrategyProvider) + + @JvmStatic fun ofString(string: String) = Channel(string = string) + } + + /** + * An interface that defines how to map each variant of [Channel] to a value of type + * [T]. + */ + interface Visitor { + + fun visitRoutingStrategy(routingStrategy: RoutingStrategyChannel): T + + fun visitRoutingStrategyProvider( + routingStrategyProvider: RoutingStrategyProvider + ): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Channel] to a value of type [T]. + * + * An instance of [Channel] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Channel: $json") + } + } + + internal class Deserializer : BaseDeserializer(Channel::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Channel { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Channel(routingStrategy = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Channel(routingStrategyProvider = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Channel(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from array). + 0 -> Channel(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Channel::class) { + + override fun serialize( + value: Channel, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.routingStrategy != null -> + generator.writeObject(value.routingStrategy) + value.routingStrategyProvider != null -> + generator.writeObject(value.routingStrategyProvider) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Channel") + } + } + } + + class RoutingStrategyChannel + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val config: JsonField, + private val if_: JsonField, + private val method: JsonField, + private val providers: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + ) : this(channel, config, if_, method, providers, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun method(): Optional = method.getOptional("method") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("method") + @ExcludeMissing + fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField = providers + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RoutingStrategyChannel]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutingStrategyChannel]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var config: JsonField = JsonMissing.of() + private var if_: JsonField = JsonMissing.of() + private var method: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routingStrategyChannel: RoutingStrategyChannel) = apply { + channel = routingStrategyChannel.channel + config = routingStrategyChannel.config + if_ = routingStrategyChannel.if_ + method = routingStrategyChannel.method + providers = routingStrategyChannel.providers + additionalProperties = + routingStrategyChannel.additionalProperties.toMutableMap() + } + + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun method(method: RoutingMethod?) = method(JsonField.ofNullable(method)) + + /** Alias for calling [Builder.method] with `method.orElse(null)`. */ + fun method(method: Optional) = method(method.getOrNull()) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [RoutingMethod] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + fun providers(providers: Providers?) = + providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed [Providers] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun providers(providers: JsonField) = apply { + this.providers = providers + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutingStrategyChannel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RoutingStrategyChannel = + RoutingStrategyChannel( + checkRequired("channel", channel), + config, + if_, + method, + providers, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RoutingStrategyChannel = apply { + if (validated) { + return@apply + } + + channel() + config().ifPresent { it.validate() } + if_() + method().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + class Providers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Providers]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Providers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(providers: Providers) = apply { + additionalProperties = providers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Providers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Providers = Providers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Providers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Providers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Providers{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingStrategyChannel && + channel == other.channel && + config == other.config && + if_ == other.if_ && + method == other.method && + providers == other.providers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, config, if_, method, providers, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutingStrategyChannel{channel=$channel, config=$config, if_=$if_, method=$method, providers=$providers, additionalProperties=$additionalProperties}" + } + + class RoutingStrategyProvider + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val metadata: JsonField, + private val name: JsonField, + private val config: JsonField, + private val if_: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("config") + @ExcludeMissing + config: JsonField = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + ) : this(metadata, name, config, if_, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun config(): Optional = config.getOptional("config") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [RoutingStrategyProvider]. + * + * The following fields are required: + * ```java + * .metadata() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RoutingStrategyProvider]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var name: JsonField? = null + private var config: JsonField = JsonMissing.of() + private var if_: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routingStrategyProvider: RoutingStrategyProvider) = apply { + metadata = routingStrategyProvider.metadata + name = routingStrategyProvider.name + config = routingStrategyProvider.config + if_ = routingStrategyProvider.if_ + additionalProperties = + routingStrategyProvider.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun config(config: Config?) = config(JsonField.ofNullable(config)) + + /** Alias for calling [Builder.config] with `config.orElse(null)`. */ + fun config(config: Optional) = config(config.getOrNull()) + + /** + * Sets [Builder.config] to an arbitrary JSON value. + * + * You should usually call [Builder.config] with a well-typed [Config] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun config(config: JsonField) = apply { this.config = config } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RoutingStrategyProvider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RoutingStrategyProvider = + RoutingStrategyProvider( + checkRequired("metadata", metadata), + checkRequired("name", name), + config, + if_, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): RoutingStrategyProvider = apply { + if (validated) { + return@apply + } + + metadata().validate() + name() + config().ifPresent { it.validate() } + if_() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + class Metadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val utm: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("utm") @ExcludeMissing utm: JsonField = JsonMissing.of() + ) : this(utm, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun utm(): Optional = utm.getOptional("utm") + + /** + * Returns the raw JSON value of [utm]. + * + * Unlike [utm], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("utm") @ExcludeMissing fun _utm(): JsonField = utm + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var utm: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + utm = metadata.utm + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun utm(utm: Utm?) = utm(JsonField.ofNullable(utm)) + + /** Alias for calling [Builder.utm] with `utm.orElse(null)`. */ + fun utm(utm: Optional) = utm(utm.getOrNull()) + + /** + * Sets [Builder.utm] to an arbitrary JSON value. + * + * You should usually call [Builder.utm] with a well-typed [Utm] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun utm(utm: JsonField) = apply { this.utm = utm } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = Metadata(utm, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + utm().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (utm.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + utm == other.utm && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(utm, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{utm=$utm, additionalProperties=$additionalProperties}" + } + + class Config + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Config]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + additionalProperties = config.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Config]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Config = Config(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Config = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingStrategyProvider && + metadata == other.metadata && + name == other.name && + config == other.config && + if_ == other.if_ && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(metadata, name, config, if_, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RoutingStrategyProvider{metadata=$metadata, name=$name, config=$config, if_=$if_, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Routing && + channels == other.channels && + method == other.method && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(channels, method, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Routing{channels=$channels, method=$method, additionalProperties=$additionalProperties}" + } + + /** Time in ms to attempt the channel before failing over to the next available channel. */ + class Timeout + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val criteria: JsonField, + private val escalation: JsonField, + private val message: JsonField, + private val provider: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("criteria") + @ExcludeMissing + criteria: JsonField = JsonMissing.of(), + @JsonProperty("escalation") + @ExcludeMissing + escalation: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField = JsonMissing.of(), + ) : this(channel, criteria, escalation, message, provider, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channel(): Optional = channel.getOptional("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun criteria(): Optional = criteria.getOptional("criteria") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun escalation(): Optional = escalation.getOptional("escalation") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun message(): Optional = message.getOptional("message") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun provider(): Optional = provider.getOptional("provider") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [criteria]. + * + * Unlike [criteria], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("criteria") @ExcludeMissing fun _criteria(): JsonField = criteria + + /** + * Returns the raw JSON value of [escalation]. + * + * Unlike [escalation], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("escalation") @ExcludeMissing fun _escalation(): JsonField = escalation + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var channel: JsonField = JsonMissing.of() + private var criteria: JsonField = JsonMissing.of() + private var escalation: JsonField = JsonMissing.of() + private var message: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + channel = timeout.channel + criteria = timeout.criteria + escalation = timeout.escalation + message = timeout.message + provider = timeout.provider + additionalProperties = timeout.additionalProperties.toMutableMap() + } + + fun channel(channel: Channel?) = channel(JsonField.ofNullable(channel)) + + /** Alias for calling [Builder.channel] with `channel.orElse(null)`. */ + fun channel(channel: Optional) = channel(channel.getOrNull()) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [Channel] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun criteria(criteria: Criteria?) = criteria(JsonField.ofNullable(criteria)) + + /** Alias for calling [Builder.criteria] with `criteria.orElse(null)`. */ + fun criteria(criteria: Optional) = criteria(criteria.getOrNull()) + + /** + * Sets [Builder.criteria] to an arbitrary JSON value. + * + * You should usually call [Builder.criteria] with a well-typed [Criteria] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun criteria(criteria: JsonField) = apply { this.criteria = criteria } + + fun escalation(escalation: Long?) = escalation(JsonField.ofNullable(escalation)) + + /** + * Alias for [Builder.escalation]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun escalation(escalation: Long) = escalation(escalation as Long?) + + /** Alias for calling [Builder.escalation] with `escalation.orElse(null)`. */ + fun escalation(escalation: Optional) = escalation(escalation.getOrNull()) + + /** + * Sets [Builder.escalation] to an arbitrary JSON value. + * + * You should usually call [Builder.escalation] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun escalation(escalation: JsonField) = apply { this.escalation = escalation } + + fun message(message: Long?) = message(JsonField.ofNullable(message)) + + /** + * Alias for [Builder.message]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun message(message: Long) = message(message as Long?) + + /** Alias for calling [Builder.message] with `message.orElse(null)`. */ + fun message(message: Optional) = message(message.getOrNull()) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun provider(provider: Provider?) = provider(JsonField.ofNullable(provider)) + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [Provider] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = + Timeout( + channel, + criteria, + escalation, + message, + provider, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Timeout = apply { + if (validated) { + return@apply + } + + channel().ifPresent { it.validate() } + criteria().ifPresent { it.validate() } + escalation() + message() + provider().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (criteria.asKnown().getOrNull()?.validity() ?: 0) + + (if (escalation.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (provider.asKnown().getOrNull()?.validity() ?: 0) + + class Channel + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Channel]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Channel]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channel: Channel) = apply { + additionalProperties = channel.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Channel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Channel = Channel(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channel && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Channel{additionalProperties=$additionalProperties}" + } + + class Criteria @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NO_ESCALATION = of("no-escalation") + + @JvmField val DELIVERED = of("delivered") + + @JvmField val VIEWED = of("viewed") + + @JvmField val ENGAGED = of("engaged") + + @JvmStatic fun of(value: String) = Criteria(JsonField.of(value)) + } + + /** An enum containing [Criteria]'s known values. */ + enum class Known { + NO_ESCALATION, + DELIVERED, + VIEWED, + ENGAGED, + } + + /** + * An enum containing [Criteria]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Criteria] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NO_ESCALATION, + DELIVERED, + VIEWED, + ENGAGED, + /** + * An enum member indicating that [Criteria] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NO_ESCALATION -> Value.NO_ESCALATION + DELIVERED -> Value.DELIVERED + VIEWED -> Value.VIEWED + ENGAGED -> Value.ENGAGED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NO_ESCALATION -> Known.NO_ESCALATION + DELIVERED -> Known.DELIVERED + VIEWED -> Known.VIEWED + ENGAGED -> Known.ENGAGED + else -> throw CourierInvalidDataException("Unknown Criteria: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Criteria = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Criteria && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Provider + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Provider]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Provider]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(provider: Provider) = apply { + additionalProperties = provider.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Provider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Provider = Provider(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Provider = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Provider && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Provider{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Timeout && + channel == other.channel && + criteria == other.criteria && + escalation == other.escalation && + message == other.message && + provider == other.provider && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, criteria, escalation, message, provider, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Timeout{channel=$channel, criteria=$criteria, escalation=$escalation, message=$message, provider=$provider, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseMessage && + brandId == other.brandId && + channels == other.channels && + context == other.context && + data == other.data && + delay == other.delay && + expiry == other.expiry && + metadata == other.metadata && + preferences == other.preferences && + providers == other.providers && + routing == other.routing && + timeout == other.timeout && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BaseMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt new file mode 100644 index 00000000..42f9e658 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt @@ -0,0 +1,7483 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.bulk.UserRecipient +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BaseMessageSendTo +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val to: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of() + ) : this(to, mutableMapOf()) + + /** + * The recipient or a list of recipients of the message + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BaseMessageSendTo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BaseMessageSendTo]. */ + class Builder internal constructor() { + + private var to: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(baseMessageSendTo: BaseMessageSendTo) = apply { + to = baseMessageSendTo.to + additionalProperties = baseMessageSendTo.additionalProperties.toMutableMap() + } + + /** The recipient or a list of recipients of the message */ + fun to(to: To?) = to(JsonField.ofNullable(to)) + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.getOrNull()) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [To] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun to(to: JsonField) = apply { this.to = to } + + /** Alias for calling [to] with `To.ofAudienceRecipient(audienceRecipient)`. */ + fun to(audienceRecipient: To.AudienceRecipient) = + to(To.ofAudienceRecipient(audienceRecipient)) + + /** Alias for calling [to] with `To.ofUnionMember1(unionMember1)`. */ + fun to(unionMember1: To.UnionMember1) = to(To.ofUnionMember1(unionMember1)) + + /** Alias for calling [to] with `To.ofUnionMember2(unionMember2)`. */ + fun to(unionMember2: To.UnionMember2) = to(To.ofUnionMember2(unionMember2)) + + /** Alias for calling [to] with `To.ofUserRecipient(userRecipient)`. */ + fun to(userRecipient: UserRecipient) = to(To.ofUserRecipient(userRecipient)) + + /** Alias for calling [to] with `To.ofSlackRecipient(slackRecipient)`. */ + fun to(slackRecipient: To.SlackRecipient) = to(To.ofSlackRecipient(slackRecipient)) + + /** Alias for calling [to] with `To.ofMsTeamsRecipient(msTeamsRecipient)`. */ + fun to(msTeamsRecipient: To.MsTeamsRecipient) = to(To.ofMsTeamsRecipient(msTeamsRecipient)) + + /** Alias for calling [to] with `To.ofRecipientData(recipientData)`. */ + fun to(recipientData: To.RecipientData) = to(To.ofRecipientData(recipientData)) + + /** Alias for calling [to] with `To.ofPagerdutyRecipient(pagerdutyRecipient)`. */ + fun to(pagerdutyRecipient: To.PagerdutyRecipient) = + to(To.ofPagerdutyRecipient(pagerdutyRecipient)) + + /** Alias for calling [to] with `To.ofWebhookRecipient(webhookRecipient)`. */ + fun to(webhookRecipient: To.WebhookRecipient) = to(To.ofWebhookRecipient(webhookRecipient)) + + /** Alias for calling [to] with `To.ofRecipients(recipients)`. */ + fun toOfRecipients(recipients: List) = to(To.ofRecipients(recipients)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BaseMessageSendTo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BaseMessageSendTo = BaseMessageSendTo(to, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BaseMessageSendTo = apply { + if (validated) { + return@apply + } + + to().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (to.asKnown().getOrNull()?.validity() ?: 0) + + /** The recipient or a list of recipients of the message */ + @JsonDeserialize(using = To.Deserializer::class) + @JsonSerialize(using = To.Serializer::class) + class To + private constructor( + private val audienceRecipient: AudienceRecipient? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val userRecipient: UserRecipient? = null, + private val slackRecipient: SlackRecipient? = null, + private val msTeamsRecipient: MsTeamsRecipient? = null, + private val recipientData: RecipientData? = null, + private val pagerdutyRecipient: PagerdutyRecipient? = null, + private val webhookRecipient: WebhookRecipient? = null, + private val recipients: List? = null, + private val _json: JsonValue? = null, + ) { + + fun audienceRecipient(): Optional = + Optional.ofNullable(audienceRecipient) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun userRecipient(): Optional = Optional.ofNullable(userRecipient) + + fun slackRecipient(): Optional = Optional.ofNullable(slackRecipient) + + fun msTeamsRecipient(): Optional = Optional.ofNullable(msTeamsRecipient) + + fun recipientData(): Optional = Optional.ofNullable(recipientData) + + fun pagerdutyRecipient(): Optional = + Optional.ofNullable(pagerdutyRecipient) + + fun webhookRecipient(): Optional = Optional.ofNullable(webhookRecipient) + + fun recipients(): Optional> = Optional.ofNullable(recipients) + + fun isAudienceRecipient(): Boolean = audienceRecipient != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUserRecipient(): Boolean = userRecipient != null + + fun isSlackRecipient(): Boolean = slackRecipient != null + + fun isMsTeamsRecipient(): Boolean = msTeamsRecipient != null + + fun isRecipientData(): Boolean = recipientData != null + + fun isPagerdutyRecipient(): Boolean = pagerdutyRecipient != null + + fun isWebhookRecipient(): Boolean = webhookRecipient != null + + fun isRecipients(): Boolean = recipients != null + + fun asAudienceRecipient(): AudienceRecipient = + audienceRecipient.getOrThrow("audienceRecipient") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUserRecipient(): UserRecipient = userRecipient.getOrThrow("userRecipient") + + fun asSlackRecipient(): SlackRecipient = slackRecipient.getOrThrow("slackRecipient") + + fun asMsTeamsRecipient(): MsTeamsRecipient = msTeamsRecipient.getOrThrow("msTeamsRecipient") + + fun asRecipientData(): RecipientData = recipientData.getOrThrow("recipientData") + + fun asPagerdutyRecipient(): PagerdutyRecipient = + pagerdutyRecipient.getOrThrow("pagerdutyRecipient") + + fun asWebhookRecipient(): WebhookRecipient = webhookRecipient.getOrThrow("webhookRecipient") + + fun asRecipients(): List = recipients.getOrThrow("recipients") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + audienceRecipient != null -> visitor.visitAudienceRecipient(audienceRecipient) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + userRecipient != null -> visitor.visitUserRecipient(userRecipient) + slackRecipient != null -> visitor.visitSlackRecipient(slackRecipient) + msTeamsRecipient != null -> visitor.visitMsTeamsRecipient(msTeamsRecipient) + recipientData != null -> visitor.visitRecipientData(recipientData) + pagerdutyRecipient != null -> visitor.visitPagerdutyRecipient(pagerdutyRecipient) + webhookRecipient != null -> visitor.visitWebhookRecipient(webhookRecipient) + recipients != null -> visitor.visitRecipients(recipients) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): To = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAudienceRecipient(audienceRecipient: AudienceRecipient) { + audienceRecipient.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUserRecipient(userRecipient: UserRecipient) { + userRecipient.validate() + } + + override fun visitSlackRecipient(slackRecipient: SlackRecipient) { + slackRecipient.validate() + } + + override fun visitMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient) { + msTeamsRecipient.validate() + } + + override fun visitRecipientData(recipientData: RecipientData) { + recipientData.validate() + } + + override fun visitPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient) { + pagerdutyRecipient.validate() + } + + override fun visitWebhookRecipient(webhookRecipient: WebhookRecipient) { + webhookRecipient.validate() + } + + override fun visitRecipients(recipients: List) { + recipients.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAudienceRecipient(audienceRecipient: AudienceRecipient) = + audienceRecipient.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = + unionMember2.validity() + + override fun visitUserRecipient(userRecipient: UserRecipient) = + userRecipient.validity() + + override fun visitSlackRecipient(slackRecipient: SlackRecipient) = + slackRecipient.validity() + + override fun visitMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient) = + msTeamsRecipient.validity() + + override fun visitRecipientData(recipientData: RecipientData) = + recipientData.validity() + + override fun visitPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient) = + pagerdutyRecipient.validity() + + override fun visitWebhookRecipient(webhookRecipient: WebhookRecipient) = + webhookRecipient.validity() + + override fun visitRecipients(recipients: List) = + recipients.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is To && + audienceRecipient == other.audienceRecipient && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + userRecipient == other.userRecipient && + slackRecipient == other.slackRecipient && + msTeamsRecipient == other.msTeamsRecipient && + recipientData == other.recipientData && + pagerdutyRecipient == other.pagerdutyRecipient && + webhookRecipient == other.webhookRecipient && + recipients == other.recipients + } + + override fun hashCode(): Int = + Objects.hash( + audienceRecipient, + unionMember1, + unionMember2, + userRecipient, + slackRecipient, + msTeamsRecipient, + recipientData, + pagerdutyRecipient, + webhookRecipient, + recipients, + ) + + override fun toString(): String = + when { + audienceRecipient != null -> "To{audienceRecipient=$audienceRecipient}" + unionMember1 != null -> "To{unionMember1=$unionMember1}" + unionMember2 != null -> "To{unionMember2=$unionMember2}" + userRecipient != null -> "To{userRecipient=$userRecipient}" + slackRecipient != null -> "To{slackRecipient=$slackRecipient}" + msTeamsRecipient != null -> "To{msTeamsRecipient=$msTeamsRecipient}" + recipientData != null -> "To{recipientData=$recipientData}" + pagerdutyRecipient != null -> "To{pagerdutyRecipient=$pagerdutyRecipient}" + webhookRecipient != null -> "To{webhookRecipient=$webhookRecipient}" + recipients != null -> "To{recipients=$recipients}" + _json != null -> "To{_unknown=$_json}" + else -> throw IllegalStateException("Invalid To") + } + + companion object { + + @JvmStatic + fun ofAudienceRecipient(audienceRecipient: AudienceRecipient) = + To(audienceRecipient = audienceRecipient) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = To(unionMember1 = unionMember1) + + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = To(unionMember2 = unionMember2) + + @JvmStatic + fun ofUserRecipient(userRecipient: UserRecipient) = To(userRecipient = userRecipient) + + @JvmStatic + fun ofSlackRecipient(slackRecipient: SlackRecipient) = + To(slackRecipient = slackRecipient) + + @JvmStatic + fun ofMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient) = + To(msTeamsRecipient = msTeamsRecipient) + + @JvmStatic + fun ofRecipientData(recipientData: RecipientData) = To(recipientData = recipientData) + + @JvmStatic + fun ofPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient) = + To(pagerdutyRecipient = pagerdutyRecipient) + + @JvmStatic + fun ofWebhookRecipient(webhookRecipient: WebhookRecipient) = + To(webhookRecipient = webhookRecipient) + + @JvmStatic + fun ofRecipients(recipients: List) = + To(recipients = recipients.toImmutable()) + } + + /** An interface that defines how to map each variant of [To] to a value of type [T]. */ + interface Visitor { + + fun visitAudienceRecipient(audienceRecipient: AudienceRecipient): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUserRecipient(userRecipient: UserRecipient): T + + fun visitSlackRecipient(slackRecipient: SlackRecipient): T + + fun visitMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient): T + + fun visitRecipientData(recipientData: RecipientData): T + + fun visitPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient): T + + fun visitWebhookRecipient(webhookRecipient: WebhookRecipient): T + + fun visitRecipients(recipients: List): T + + /** + * Maps an unknown variant of [To] to a value of type [T]. + * + * An instance of [To] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown To: $json") + } + } + + internal class Deserializer : BaseDeserializer(To::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): To { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + To(audienceRecipient = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(userRecipient = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(slackRecipient = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(msTeamsRecipient = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(recipientData = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(pagerdutyRecipient = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + To(webhookRecipient = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + To(recipients = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> To(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(To::class) { + + override fun serialize( + value: To, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.audienceRecipient != null -> + generator.writeObject(value.audienceRecipient) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.userRecipient != null -> generator.writeObject(value.userRecipient) + value.slackRecipient != null -> generator.writeObject(value.slackRecipient) + value.msTeamsRecipient != null -> generator.writeObject(value.msTeamsRecipient) + value.recipientData != null -> generator.writeObject(value.recipientData) + value.pagerdutyRecipient != null -> + generator.writeObject(value.pagerdutyRecipient) + value.webhookRecipient != null -> generator.writeObject(value.webhookRecipient) + value.recipients != null -> generator.writeObject(value.recipients) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid To") + } + } + } + + class AudienceRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val audienceId: JsonField, + private val data: JsonField, + private val filters: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audience_id") + @ExcludeMissing + audienceId: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + ) : this(audienceId, data, filters, mutableMapOf()) + + /** + * A unique identifier associated with an Audience. A message will be sent to each user + * in the audience. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun audienceId(): String = audienceId.getRequired("audience_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filters(): Optional> = filters.getOptional("filters") + + /** + * Returns the raw JSON value of [audienceId]. + * + * Unlike [audienceId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("audience_id") + @ExcludeMissing + fun _audienceId(): JsonField = audienceId + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AudienceRecipient]. + * + * The following fields are required: + * ```java + * .audienceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceRecipient]. */ + class Builder internal constructor() { + + private var audienceId: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var filters: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audienceRecipient: AudienceRecipient) = apply { + audienceId = audienceRecipient.audienceId + data = audienceRecipient.data + filters = audienceRecipient.filters.map { it.toMutableList() } + additionalProperties = audienceRecipient.additionalProperties.toMutableMap() + } + + /** + * A unique identifier associated with an Audience. A message will be sent to each + * user in the audience. + */ + fun audienceId(audienceId: String) = audienceId(JsonField.of(audienceId)) + + /** + * Sets [Builder.audienceId] to an arbitrary JSON value. + * + * You should usually call [Builder.audienceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun audienceId(audienceId: JsonField) = apply { + this.audienceId = audienceId + } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional>) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AudienceRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .audienceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AudienceRecipient = + AudienceRecipient( + checkRequired("audienceId", audienceId), + data, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AudienceRecipient = apply { + if (validated) { + return@apply + } + + audienceId() + data().ifPresent { it.validate() } + filters().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (audienceId.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val operator: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(operator, path, value, mutableMapOf()) + + /** + * Send to users only if they are member of the account + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun path(): Path = path.getRequired("path") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + operator = filter.operator + path = filter.path + value = filter.value + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Send to users only if they are member of the account */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun path(path: Path) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [Path] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("operator", operator), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + operator().validate() + path().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (path.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Send to users only if they are member of the account */ + class Operator + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MEMBER_OF = of("MEMBER_OF") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + MEMBER_OF + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMBER_OF, + /** + * An enum member indicating that [Operator] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMBER_OF -> Value.MEMBER_OF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MEMBER_OF -> Known.MEMBER_OF + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Path @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ACCOUNT_ID = of("account_id") + + @JvmStatic fun of(value: String) = Path(JsonField.of(value)) + } + + /** An enum containing [Path]'s known values. */ + enum class Known { + ACCOUNT_ID + } + + /** + * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Path] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ID, + /** + * An enum member indicating that [Path] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ID -> Value.ACCOUNT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_ID -> Known.ACCOUNT_ID + else -> throw CourierInvalidDataException("Unknown Path: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Path = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Path && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + operator == other.operator && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(operator, path, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceRecipient && + audienceId == other.audienceId && + data == other.data && + filters == other.filters && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(audienceId, data, filters, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AudienceRecipient{audienceId=$audienceId, data=$data, filters=$filters, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val filters: JsonField>, + private val listId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("list_id") + @ExcludeMissing + listId: JsonField = JsonMissing.of(), + ) : this(data, filters, listId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filters(): Optional> = filters.getOptional("filters") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun listId(): Optional = listId.getOptional("list_id") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") + @ExcludeMissing + fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [listId]. + * + * Unlike [listId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list_id") @ExcludeMissing fun _listId(): JsonField = listId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var filters: JsonField>? = null + private var listId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + data = unionMember1.data + filters = unionMember1.filters.map { it.toMutableList() } + listId = unionMember1.listId + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional>) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun listId(listId: String?) = listId(JsonField.ofNullable(listId)) + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + /** + * Sets [Builder.listId] to an arbitrary JSON value. + * + * You should usually call [Builder.listId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun listId(listId: JsonField) = apply { this.listId = listId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + data, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, + listId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + filters().ifPresent { it.forEach { it.validate() } } + listId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.validity() ?: 0) + + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (listId.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val operator: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(operator, path, value, mutableMapOf()) + + /** + * Send to users only if they are member of the account + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun path(): Path = path.getRequired("path") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + operator = filter.operator + path = filter.path + value = filter.value + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Send to users only if they are member of the account */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun path(path: Path) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [Path] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("operator", operator), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + operator().validate() + path().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (path.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Send to users only if they are member of the account */ + class Operator + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val MEMBER_OF = of("MEMBER_OF") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + MEMBER_OF + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMBER_OF, + /** + * An enum member indicating that [Operator] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMBER_OF -> Value.MEMBER_OF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MEMBER_OF -> Known.MEMBER_OF + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Path @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ACCOUNT_ID = of("account_id") + + @JvmStatic fun of(value: String) = Path(JsonField.of(value)) + } + + /** An enum containing [Path]'s known values. */ + enum class Known { + ACCOUNT_ID + } + + /** + * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Path] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ID, + /** + * An enum member indicating that [Path] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ID -> Value.ACCOUNT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_ID -> Known.ACCOUNT_ID + else -> throw CourierInvalidDataException("Unknown Path: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Path = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Path && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + operator == other.operator && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(operator, path, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + data == other.data && + filters == other.filters && + listId == other.listId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, filters, listId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{data=$data, filters=$filters, listId=$listId, additionalProperties=$additionalProperties}" + } + + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val listPattern: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("list_pattern") + @ExcludeMissing + listPattern: JsonField = JsonMissing.of(), + ) : this(data, listPattern, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun listPattern(): Optional = listPattern.getOptional("list_pattern") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [listPattern]. + * + * Unlike [listPattern], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("list_pattern") + @ExcludeMissing + fun _listPattern(): JsonField = listPattern + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var listPattern: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + data = unionMember2.data + listPattern = unionMember2.listPattern + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun listPattern(listPattern: String?) = + listPattern(JsonField.ofNullable(listPattern)) + + /** Alias for calling [Builder.listPattern] with `listPattern.orElse(null)`. */ + fun listPattern(listPattern: Optional) = + listPattern(listPattern.getOrNull()) + + /** + * Sets [Builder.listPattern] to an arbitrary JSON value. + * + * You should usually call [Builder.listPattern] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun listPattern(listPattern: JsonField) = apply { + this.listPattern = listPattern + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = + UnionMember2(data, listPattern, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + listPattern() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (listPattern.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + data == other.data && + listPattern == other.listPattern && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, listPattern, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{data=$data, listPattern=$listPattern, additionalProperties=$additionalProperties}" + } + + class SlackRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val slack: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("slack") @ExcludeMissing slack: JsonField = JsonMissing.of() + ) : this(slack, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun slack(): Slack = slack.getRequired("slack") + + /** + * Returns the raw JSON value of [slack]. + * + * Unlike [slack], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slack") @ExcludeMissing fun _slack(): JsonField = slack + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SlackRecipient]. + * + * The following fields are required: + * ```java + * .slack() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SlackRecipient]. */ + class Builder internal constructor() { + + private var slack: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(slackRecipient: SlackRecipient) = apply { + slack = slackRecipient.slack + additionalProperties = slackRecipient.additionalProperties.toMutableMap() + } + + fun slack(slack: Slack) = slack(JsonField.of(slack)) + + /** + * Sets [Builder.slack] to an arbitrary JSON value. + * + * You should usually call [Builder.slack] with a well-typed [Slack] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun slack(slack: JsonField) = apply { this.slack = slack } + + /** + * Alias for calling [slack] with `Slack.ofSendToSlackChannel(sendToSlackChannel)`. + */ + fun slack(sendToSlackChannel: Slack.SendToSlackChannel) = + slack(Slack.ofSendToSlackChannel(sendToSlackChannel)) + + /** Alias for calling [slack] with `Slack.ofSendToSlackEmail(sendToSlackEmail)`. */ + fun slack(sendToSlackEmail: Slack.SendToSlackEmail) = + slack(Slack.ofSendToSlackEmail(sendToSlackEmail)) + + /** + * Alias for calling [slack] with `Slack.ofSendToSlackUserId(sendToSlackUserId)`. + */ + fun slack(sendToSlackUserId: Slack.SendToSlackUserId) = + slack(Slack.ofSendToSlackUserId(sendToSlackUserId)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SlackRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .slack() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SlackRecipient = + SlackRecipient( + checkRequired("slack", slack), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SlackRecipient = apply { + if (validated) { + return@apply + } + + slack().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (slack.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Slack.Deserializer::class) + @JsonSerialize(using = Slack.Serializer::class) + class Slack + private constructor( + private val sendToSlackChannel: SendToSlackChannel? = null, + private val sendToSlackEmail: SendToSlackEmail? = null, + private val sendToSlackUserId: SendToSlackUserId? = null, + private val _json: JsonValue? = null, + ) { + + fun sendToSlackChannel(): Optional = + Optional.ofNullable(sendToSlackChannel) + + fun sendToSlackEmail(): Optional = + Optional.ofNullable(sendToSlackEmail) + + fun sendToSlackUserId(): Optional = + Optional.ofNullable(sendToSlackUserId) + + fun isSendToSlackChannel(): Boolean = sendToSlackChannel != null + + fun isSendToSlackEmail(): Boolean = sendToSlackEmail != null + + fun isSendToSlackUserId(): Boolean = sendToSlackUserId != null + + fun asSendToSlackChannel(): SendToSlackChannel = + sendToSlackChannel.getOrThrow("sendToSlackChannel") + + fun asSendToSlackEmail(): SendToSlackEmail = + sendToSlackEmail.getOrThrow("sendToSlackEmail") + + fun asSendToSlackUserId(): SendToSlackUserId = + sendToSlackUserId.getOrThrow("sendToSlackUserId") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + sendToSlackChannel != null -> + visitor.visitSendToSlackChannel(sendToSlackChannel) + sendToSlackEmail != null -> visitor.visitSendToSlackEmail(sendToSlackEmail) + sendToSlackUserId != null -> + visitor.visitSendToSlackUserId(sendToSlackUserId) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Slack = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSendToSlackChannel( + sendToSlackChannel: SendToSlackChannel + ) { + sendToSlackChannel.validate() + } + + override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) { + sendToSlackEmail.validate() + } + + override fun visitSendToSlackUserId( + sendToSlackUserId: SendToSlackUserId + ) { + sendToSlackUserId.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSendToSlackChannel( + sendToSlackChannel: SendToSlackChannel + ) = sendToSlackChannel.validity() + + override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = + sendToSlackEmail.validity() + + override fun visitSendToSlackUserId( + sendToSlackUserId: SendToSlackUserId + ) = sendToSlackUserId.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Slack && + sendToSlackChannel == other.sendToSlackChannel && + sendToSlackEmail == other.sendToSlackEmail && + sendToSlackUserId == other.sendToSlackUserId + } + + override fun hashCode(): Int = + Objects.hash(sendToSlackChannel, sendToSlackEmail, sendToSlackUserId) + + override fun toString(): String = + when { + sendToSlackChannel != null -> + "Slack{sendToSlackChannel=$sendToSlackChannel}" + sendToSlackEmail != null -> "Slack{sendToSlackEmail=$sendToSlackEmail}" + sendToSlackUserId != null -> "Slack{sendToSlackUserId=$sendToSlackUserId}" + _json != null -> "Slack{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Slack") + } + + companion object { + + @JvmStatic + fun ofSendToSlackChannel(sendToSlackChannel: SendToSlackChannel) = + Slack(sendToSlackChannel = sendToSlackChannel) + + @JvmStatic + fun ofSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = + Slack(sendToSlackEmail = sendToSlackEmail) + + @JvmStatic + fun ofSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) = + Slack(sendToSlackUserId = sendToSlackUserId) + } + + /** + * An interface that defines how to map each variant of [Slack] to a value of type + * [T]. + */ + interface Visitor { + + fun visitSendToSlackChannel(sendToSlackChannel: SendToSlackChannel): T + + fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail): T + + fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId): T + + /** + * Maps an unknown variant of [Slack] to a value of type [T]. + * + * An instance of [Slack] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Slack: $json") + } + } + + internal class Deserializer : BaseDeserializer(Slack::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Slack { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { Slack(sendToSlackChannel = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Slack(sendToSlackEmail = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Slack(sendToSlackUserId = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> Slack(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Slack::class) { + + override fun serialize( + value: Slack, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.sendToSlackChannel != null -> + generator.writeObject(value.sendToSlackChannel) + value.sendToSlackEmail != null -> + generator.writeObject(value.sendToSlackEmail) + value.sendToSlackUserId != null -> + generator.writeObject(value.sendToSlackUserId) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Slack") + } + } + } + + class SendToSlackChannel + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessToken: JsonField, + private val channel: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + ) : this(accessToken, channel, mutableMapOf()) + + fun toSlackBaseProperties(): SlackBaseProperties = + SlackBaseProperties.builder().accessToken(accessToken).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToSlackChannel]. + * + * The following fields are required: + * ```java + * .accessToken() + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToSlackChannel]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var channel: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToSlackChannel: SendToSlackChannel) = apply { + accessToken = sendToSlackChannel.accessToken + channel = sendToSlackChannel.channel + additionalProperties = + sendToSlackChannel.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = + accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessToken(accessToken: JsonField) = apply { + this.accessToken = accessToken + } + + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToSlackChannel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToSlackChannel = + SendToSlackChannel( + checkRequired("accessToken", accessToken), + checkRequired("channel", channel), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToSlackChannel = apply { + if (validated) { + return@apply + } + + accessToken() + channel() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (channel.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToSlackChannel && + accessToken == other.accessToken && + channel == other.channel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, channel, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToSlackChannel{accessToken=$accessToken, channel=$channel, additionalProperties=$additionalProperties}" + } + + class SendToSlackEmail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessToken: JsonField, + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + ) : this(accessToken, email, mutableMapOf()) + + fun toSlackBaseProperties(): SlackBaseProperties = + SlackBaseProperties.builder().accessToken(accessToken).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToSlackEmail]. + * + * The following fields are required: + * ```java + * .accessToken() + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToSlackEmail]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var email: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToSlackEmail: SendToSlackEmail) = apply { + accessToken = sendToSlackEmail.accessToken + email = sendToSlackEmail.email + additionalProperties = + sendToSlackEmail.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = + accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessToken(accessToken: JsonField) = apply { + this.accessToken = accessToken + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToSlackEmail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToSlackEmail = + SendToSlackEmail( + checkRequired("accessToken", accessToken), + checkRequired("email", email), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToSlackEmail = apply { + if (validated) { + return@apply + } + + accessToken() + email() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToSlackEmail && + accessToken == other.accessToken && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, email, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToSlackEmail{accessToken=$accessToken, email=$email, additionalProperties=$additionalProperties}" + } + + class SendToSlackUserId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessToken: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + userId: JsonField = JsonMissing.of(), + ) : this(accessToken, userId, mutableMapOf()) + + fun toSlackBaseProperties(): SlackBaseProperties = + SlackBaseProperties.builder().accessToken(accessToken).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToSlackUserId]. + * + * The following fields are required: + * ```java + * .accessToken() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToSlackUserId]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var userId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToSlackUserId: SendToSlackUserId) = apply { + accessToken = sendToSlackUserId.accessToken + userId = sendToSlackUserId.userId + additionalProperties = + sendToSlackUserId.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = + accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessToken(accessToken: JsonField) = apply { + this.accessToken = accessToken + } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToSlackUserId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToSlackUserId = + SendToSlackUserId( + checkRequired("accessToken", accessToken), + checkRequired("userId", userId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToSlackUserId = apply { + if (validated) { + return@apply + } + + accessToken() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToSlackUserId && + accessToken == other.accessToken && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToSlackUserId{accessToken=$accessToken, userId=$userId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SlackRecipient && + slack == other.slack && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(slack, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SlackRecipient{slack=$slack, additionalProperties=$additionalProperties}" + } + + class MsTeamsRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val msTeams: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ms_teams") + @ExcludeMissing + msTeams: JsonField = JsonMissing.of() + ) : this(msTeams, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun msTeams(): MsTeams = msTeams.getRequired("ms_teams") + + /** + * Returns the raw JSON value of [msTeams]. + * + * Unlike [msTeams], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ms_teams") @ExcludeMissing fun _msTeams(): JsonField = msTeams + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MsTeamsRecipient]. + * + * The following fields are required: + * ```java + * .msTeams() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MsTeamsRecipient]. */ + class Builder internal constructor() { + + private var msTeams: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(msTeamsRecipient: MsTeamsRecipient) = apply { + msTeams = msTeamsRecipient.msTeams + additionalProperties = msTeamsRecipient.additionalProperties.toMutableMap() + } + + fun msTeams(msTeams: MsTeams) = msTeams(JsonField.of(msTeams)) + + /** + * Sets [Builder.msTeams] to an arbitrary JSON value. + * + * You should usually call [Builder.msTeams] with a well-typed [MsTeams] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun msTeams(msTeams: JsonField) = apply { this.msTeams = msTeams } + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)`. + */ + fun msTeams(sendToMsTeamsUserId: MsTeams.SendToMsTeamsUserId) = + msTeams(MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)`. + */ + fun msTeams(sendToMsTeamsEmail: MsTeams.SendToMsTeamsEmail) = + msTeams(MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)`. + */ + fun msTeams(sendToMsTeamsChannelId: MsTeams.SendToMsTeamsChannelId) = + msTeams(MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)`. + */ + fun msTeams(sendToMsTeamsConversationId: MsTeams.SendToMsTeamsConversationId) = + msTeams(MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)`. + */ + fun msTeams(sendToMsTeamsChannelName: MsTeams.SendToMsTeamsChannelName) = + msTeams(MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MsTeamsRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .msTeams() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MsTeamsRecipient = + MsTeamsRecipient( + checkRequired("msTeams", msTeams), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MsTeamsRecipient = apply { + if (validated) { + return@apply + } + + msTeams().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (msTeams.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = MsTeams.Deserializer::class) + @JsonSerialize(using = MsTeams.Serializer::class) + class MsTeams + private constructor( + private val sendToMsTeamsUserId: SendToMsTeamsUserId? = null, + private val sendToMsTeamsEmail: SendToMsTeamsEmail? = null, + private val sendToMsTeamsChannelId: SendToMsTeamsChannelId? = null, + private val sendToMsTeamsConversationId: SendToMsTeamsConversationId? = null, + private val sendToMsTeamsChannelName: SendToMsTeamsChannelName? = null, + private val _json: JsonValue? = null, + ) { + + fun sendToMsTeamsUserId(): Optional = + Optional.ofNullable(sendToMsTeamsUserId) + + fun sendToMsTeamsEmail(): Optional = + Optional.ofNullable(sendToMsTeamsEmail) + + fun sendToMsTeamsChannelId(): Optional = + Optional.ofNullable(sendToMsTeamsChannelId) + + fun sendToMsTeamsConversationId(): Optional = + Optional.ofNullable(sendToMsTeamsConversationId) + + fun sendToMsTeamsChannelName(): Optional = + Optional.ofNullable(sendToMsTeamsChannelName) + + fun isSendToMsTeamsUserId(): Boolean = sendToMsTeamsUserId != null + + fun isSendToMsTeamsEmail(): Boolean = sendToMsTeamsEmail != null + + fun isSendToMsTeamsChannelId(): Boolean = sendToMsTeamsChannelId != null + + fun isSendToMsTeamsConversationId(): Boolean = sendToMsTeamsConversationId != null + + fun isSendToMsTeamsChannelName(): Boolean = sendToMsTeamsChannelName != null + + fun asSendToMsTeamsUserId(): SendToMsTeamsUserId = + sendToMsTeamsUserId.getOrThrow("sendToMsTeamsUserId") + + fun asSendToMsTeamsEmail(): SendToMsTeamsEmail = + sendToMsTeamsEmail.getOrThrow("sendToMsTeamsEmail") + + fun asSendToMsTeamsChannelId(): SendToMsTeamsChannelId = + sendToMsTeamsChannelId.getOrThrow("sendToMsTeamsChannelId") + + fun asSendToMsTeamsConversationId(): SendToMsTeamsConversationId = + sendToMsTeamsConversationId.getOrThrow("sendToMsTeamsConversationId") + + fun asSendToMsTeamsChannelName(): SendToMsTeamsChannelName = + sendToMsTeamsChannelName.getOrThrow("sendToMsTeamsChannelName") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + sendToMsTeamsUserId != null -> + visitor.visitSendToMsTeamsUserId(sendToMsTeamsUserId) + sendToMsTeamsEmail != null -> + visitor.visitSendToMsTeamsEmail(sendToMsTeamsEmail) + sendToMsTeamsChannelId != null -> + visitor.visitSendToMsTeamsChannelId(sendToMsTeamsChannelId) + sendToMsTeamsConversationId != null -> + visitor.visitSendToMsTeamsConversationId(sendToMsTeamsConversationId) + sendToMsTeamsChannelName != null -> + visitor.visitSendToMsTeamsChannelName(sendToMsTeamsChannelName) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MsTeams = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSendToMsTeamsUserId( + sendToMsTeamsUserId: SendToMsTeamsUserId + ) { + sendToMsTeamsUserId.validate() + } + + override fun visitSendToMsTeamsEmail( + sendToMsTeamsEmail: SendToMsTeamsEmail + ) { + sendToMsTeamsEmail.validate() + } + + override fun visitSendToMsTeamsChannelId( + sendToMsTeamsChannelId: SendToMsTeamsChannelId + ) { + sendToMsTeamsChannelId.validate() + } + + override fun visitSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) { + sendToMsTeamsConversationId.validate() + } + + override fun visitSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ) { + sendToMsTeamsChannelName.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSendToMsTeamsUserId( + sendToMsTeamsUserId: SendToMsTeamsUserId + ) = sendToMsTeamsUserId.validity() + + override fun visitSendToMsTeamsEmail( + sendToMsTeamsEmail: SendToMsTeamsEmail + ) = sendToMsTeamsEmail.validity() + + override fun visitSendToMsTeamsChannelId( + sendToMsTeamsChannelId: SendToMsTeamsChannelId + ) = sendToMsTeamsChannelId.validity() + + override fun visitSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) = sendToMsTeamsConversationId.validity() + + override fun visitSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ) = sendToMsTeamsChannelName.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MsTeams && + sendToMsTeamsUserId == other.sendToMsTeamsUserId && + sendToMsTeamsEmail == other.sendToMsTeamsEmail && + sendToMsTeamsChannelId == other.sendToMsTeamsChannelId && + sendToMsTeamsConversationId == other.sendToMsTeamsConversationId && + sendToMsTeamsChannelName == other.sendToMsTeamsChannelName + } + + override fun hashCode(): Int = + Objects.hash( + sendToMsTeamsUserId, + sendToMsTeamsEmail, + sendToMsTeamsChannelId, + sendToMsTeamsConversationId, + sendToMsTeamsChannelName, + ) + + override fun toString(): String = + when { + sendToMsTeamsUserId != null -> + "MsTeams{sendToMsTeamsUserId=$sendToMsTeamsUserId}" + sendToMsTeamsEmail != null -> + "MsTeams{sendToMsTeamsEmail=$sendToMsTeamsEmail}" + sendToMsTeamsChannelId != null -> + "MsTeams{sendToMsTeamsChannelId=$sendToMsTeamsChannelId}" + sendToMsTeamsConversationId != null -> + "MsTeams{sendToMsTeamsConversationId=$sendToMsTeamsConversationId}" + sendToMsTeamsChannelName != null -> + "MsTeams{sendToMsTeamsChannelName=$sendToMsTeamsChannelName}" + _json != null -> "MsTeams{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MsTeams") + } + + companion object { + + @JvmStatic + fun ofSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId) = + MsTeams(sendToMsTeamsUserId = sendToMsTeamsUserId) + + @JvmStatic + fun ofSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail) = + MsTeams(sendToMsTeamsEmail = sendToMsTeamsEmail) + + @JvmStatic + fun ofSendToMsTeamsChannelId(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = + MsTeams(sendToMsTeamsChannelId = sendToMsTeamsChannelId) + + @JvmStatic + fun ofSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) = MsTeams(sendToMsTeamsConversationId = sendToMsTeamsConversationId) + + @JvmStatic + fun ofSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ) = MsTeams(sendToMsTeamsChannelName = sendToMsTeamsChannelName) + } + + /** + * An interface that defines how to map each variant of [MsTeams] to a value of type + * [T]. + */ + interface Visitor { + + fun visitSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId): T + + fun visitSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail): T + + fun visitSendToMsTeamsChannelId( + sendToMsTeamsChannelId: SendToMsTeamsChannelId + ): T + + fun visitSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ): T + + fun visitSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ): T + + /** + * Maps an unknown variant of [MsTeams] to a value of type [T]. + * + * An instance of [MsTeams] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown MsTeams: $json") + } + } + + internal class Deserializer : BaseDeserializer(MsTeams::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MsTeams { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef()) + ?.let { MsTeams(sendToMsTeamsUserId = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { MsTeams(sendToMsTeamsEmail = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MsTeams(sendToMsTeamsChannelId = it, _json = json) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + MsTeams(sendToMsTeamsConversationId = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MsTeams(sendToMsTeamsChannelName = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // boolean). + 0 -> MsTeams(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MsTeams::class) { + + override fun serialize( + value: MsTeams, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.sendToMsTeamsUserId != null -> + generator.writeObject(value.sendToMsTeamsUserId) + value.sendToMsTeamsEmail != null -> + generator.writeObject(value.sendToMsTeamsEmail) + value.sendToMsTeamsChannelId != null -> + generator.writeObject(value.sendToMsTeamsChannelId) + value.sendToMsTeamsConversationId != null -> + generator.writeObject(value.sendToMsTeamsConversationId) + value.sendToMsTeamsChannelName != null -> + generator.writeObject(value.sendToMsTeamsChannelName) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MsTeams") + } + } + } + + class SendToMsTeamsUserId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + userId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, userId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("user_id") + @ExcludeMissing + fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsUserId]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsUserId]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var userId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsUserId: SendToMsTeamsUserId) = apply { + serviceUrl = sendToMsTeamsUserId.serviceUrl + tenantId = sendToMsTeamsUserId.tenantId + userId = sendToMsTeamsUserId.userId + additionalProperties = + sendToMsTeamsUserId.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { + this.tenantId = tenantId + } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsUserId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsUserId = + SendToMsTeamsUserId( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("userId", userId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsUserId = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsUserId && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsUserId{serviceUrl=$serviceUrl, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsEmail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, email, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsEmail]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsEmail]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var email: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsEmail: SendToMsTeamsEmail) = apply { + serviceUrl = sendToMsTeamsEmail.serviceUrl + tenantId = sendToMsTeamsEmail.tenantId + email = sendToMsTeamsEmail.email + additionalProperties = + sendToMsTeamsEmail.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { + this.tenantId = tenantId + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsEmail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsEmail = + SendToMsTeamsEmail( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("email", email), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsEmail = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + email() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsEmail && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, email, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsEmail{serviceUrl=$serviceUrl, tenantId=$tenantId, email=$email, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsChannelId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val channelId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("channel_id") + @ExcludeMissing + channelId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, channelId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channelId(): String = channelId.getRequired("channel_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [channelId]. + * + * Unlike [channelId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("channel_id") + @ExcludeMissing + fun _channelId(): JsonField = channelId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsChannelId]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsChannelId]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var channelId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = apply { + serviceUrl = sendToMsTeamsChannelId.serviceUrl + tenantId = sendToMsTeamsChannelId.tenantId + channelId = sendToMsTeamsChannelId.channelId + additionalProperties = + sendToMsTeamsChannelId.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { + this.tenantId = tenantId + } + + fun channelId(channelId: String) = channelId(JsonField.of(channelId)) + + /** + * Sets [Builder.channelId] to an arbitrary JSON value. + * + * You should usually call [Builder.channelId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channelId(channelId: JsonField) = apply { + this.channelId = channelId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsChannelId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsChannelId = + SendToMsTeamsChannelId( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("channelId", channelId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsChannelId = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + channelId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (channelId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsChannelId && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + channelId == other.channelId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, channelId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsChannelId{serviceUrl=$serviceUrl, tenantId=$tenantId, channelId=$channelId, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsConversationId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val conversationId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("conversation_id") + @ExcludeMissing + conversationId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, conversationId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun conversationId(): String = conversationId.getRequired("conversation_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [conversationId]. + * + * Unlike [conversationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversation_id") + @ExcludeMissing + fun _conversationId(): JsonField = conversationId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsConversationId]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .conversationId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsConversationId]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var conversationId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) = apply { + serviceUrl = sendToMsTeamsConversationId.serviceUrl + tenantId = sendToMsTeamsConversationId.tenantId + conversationId = sendToMsTeamsConversationId.conversationId + additionalProperties = + sendToMsTeamsConversationId.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { + this.tenantId = tenantId + } + + fun conversationId(conversationId: String) = + conversationId(JsonField.of(conversationId)) + + /** + * Sets [Builder.conversationId] to an arbitrary JSON value. + * + * You should usually call [Builder.conversationId] with a well-typed + * [String] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun conversationId(conversationId: JsonField) = apply { + this.conversationId = conversationId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsConversationId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .conversationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsConversationId = + SendToMsTeamsConversationId( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("conversationId", conversationId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsConversationId = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + conversationId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (conversationId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsConversationId && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + conversationId == other.conversationId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, conversationId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsConversationId{serviceUrl=$serviceUrl, tenantId=$tenantId, conversationId=$conversationId, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsChannelName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val channelName: JsonField, + private val teamId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("channel_name") + @ExcludeMissing + channelName: JsonField = JsonMissing.of(), + @JsonProperty("team_id") + @ExcludeMissing + teamId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, channelName, teamId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channelName(): String = channelName.getRequired("channel_name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun teamId(): String = teamId.getRequired("team_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [channelName]. + * + * Unlike [channelName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("channel_name") + @ExcludeMissing + fun _channelName(): JsonField = channelName + + /** + * Returns the raw JSON value of [teamId]. + * + * Unlike [teamId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("team_id") + @ExcludeMissing + fun _teamId(): JsonField = teamId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsChannelName]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelName() + * .teamId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsChannelName]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var channelName: JsonField? = null + private var teamId: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsChannelName: SendToMsTeamsChannelName) = + apply { + serviceUrl = sendToMsTeamsChannelName.serviceUrl + tenantId = sendToMsTeamsChannelName.tenantId + channelName = sendToMsTeamsChannelName.channelName + teamId = sendToMsTeamsChannelName.teamId + additionalProperties = + sendToMsTeamsChannelName.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { + this.tenantId = tenantId + } + + fun channelName(channelName: String) = + channelName(JsonField.of(channelName)) + + /** + * Sets [Builder.channelName] to an arbitrary JSON value. + * + * You should usually call [Builder.channelName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channelName(channelName: JsonField) = apply { + this.channelName = channelName + } + + fun teamId(teamId: String) = teamId(JsonField.of(teamId)) + + /** + * Sets [Builder.teamId] to an arbitrary JSON value. + * + * You should usually call [Builder.teamId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun teamId(teamId: JsonField) = apply { this.teamId = teamId } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsChannelName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelName() + * .teamId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsChannelName = + SendToMsTeamsChannelName( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("channelName", channelName), + checkRequired("teamId", teamId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsChannelName = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + channelName() + teamId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (channelName.asKnown().isPresent) 1 else 0) + + (if (teamId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsChannelName && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + channelName == other.channelName && + teamId == other.teamId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + serviceUrl, + tenantId, + channelName, + teamId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsChannelName{serviceUrl=$serviceUrl, tenantId=$tenantId, channelName=$channelName, teamId=$teamId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MsTeamsRecipient && + msTeams == other.msTeams && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(msTeams, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MsTeamsRecipient{msTeams=$msTeams, additionalProperties=$additionalProperties}" + } + + class RecipientData + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RecipientData]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecipientData]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recipientData: RecipientData) = apply { + additionalProperties = recipientData.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecipientData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RecipientData = RecipientData(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RecipientData = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecipientData && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RecipientData{additionalProperties=$additionalProperties}" + } + + class PagerdutyRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pagerduty: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pagerduty") + @ExcludeMissing + pagerduty: JsonField = JsonMissing.of() + ) : this(pagerduty, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun pagerduty(): Pagerduty = pagerduty.getRequired("pagerduty") + + /** + * Returns the raw JSON value of [pagerduty]. + * + * Unlike [pagerduty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pagerduty") + @ExcludeMissing + fun _pagerduty(): JsonField = pagerduty + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PagerdutyRecipient]. + * + * The following fields are required: + * ```java + * .pagerduty() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PagerdutyRecipient]. */ + class Builder internal constructor() { + + private var pagerduty: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pagerdutyRecipient: PagerdutyRecipient) = apply { + pagerduty = pagerdutyRecipient.pagerduty + additionalProperties = pagerdutyRecipient.additionalProperties.toMutableMap() + } + + fun pagerduty(pagerduty: Pagerduty) = pagerduty(JsonField.of(pagerduty)) + + /** + * Sets [Builder.pagerduty] to an arbitrary JSON value. + * + * You should usually call [Builder.pagerduty] with a well-typed [Pagerduty] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun pagerduty(pagerduty: JsonField) = apply { + this.pagerduty = pagerduty + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PagerdutyRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .pagerduty() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PagerdutyRecipient = + PagerdutyRecipient( + checkRequired("pagerduty", pagerduty), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PagerdutyRecipient = apply { + if (validated) { + return@apply + } + + pagerduty().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (pagerduty.asKnown().getOrNull()?.validity() ?: 0) + + class Pagerduty + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val eventAction: JsonField, + private val routingKey: JsonField, + private val severity: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event_action") + @ExcludeMissing + eventAction: JsonField = JsonMissing.of(), + @JsonProperty("routing_key") + @ExcludeMissing + routingKey: JsonField = JsonMissing.of(), + @JsonProperty("severity") + @ExcludeMissing + severity: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + ) : this(eventAction, routingKey, severity, source, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun eventAction(): Optional = eventAction.getOptional("event_action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun routingKey(): Optional = routingKey.getOptional("routing_key") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun severity(): Optional = severity.getOptional("severity") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [eventAction]. + * + * Unlike [eventAction], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("event_action") + @ExcludeMissing + fun _eventAction(): JsonField = eventAction + + /** + * Returns the raw JSON value of [routingKey]. + * + * Unlike [routingKey], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("routing_key") + @ExcludeMissing + fun _routingKey(): JsonField = routingKey + + /** + * Returns the raw JSON value of [severity]. + * + * Unlike [severity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("severity") + @ExcludeMissing + fun _severity(): JsonField = severity + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Pagerduty]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Pagerduty]. */ + class Builder internal constructor() { + + private var eventAction: JsonField = JsonMissing.of() + private var routingKey: JsonField = JsonMissing.of() + private var severity: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pagerduty: Pagerduty) = apply { + eventAction = pagerduty.eventAction + routingKey = pagerduty.routingKey + severity = pagerduty.severity + source = pagerduty.source + additionalProperties = pagerduty.additionalProperties.toMutableMap() + } + + fun eventAction(eventAction: String?) = + eventAction(JsonField.ofNullable(eventAction)) + + /** Alias for calling [Builder.eventAction] with `eventAction.orElse(null)`. */ + fun eventAction(eventAction: Optional) = + eventAction(eventAction.getOrNull()) + + /** + * Sets [Builder.eventAction] to an arbitrary JSON value. + * + * You should usually call [Builder.eventAction] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun eventAction(eventAction: JsonField) = apply { + this.eventAction = eventAction + } + + fun routingKey(routingKey: String?) = + routingKey(JsonField.ofNullable(routingKey)) + + /** Alias for calling [Builder.routingKey] with `routingKey.orElse(null)`. */ + fun routingKey(routingKey: Optional) = + routingKey(routingKey.getOrNull()) + + /** + * Sets [Builder.routingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.routingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routingKey(routingKey: JsonField) = apply { + this.routingKey = routingKey + } + + fun severity(severity: String?) = severity(JsonField.ofNullable(severity)) + + /** Alias for calling [Builder.severity] with `severity.orElse(null)`. */ + fun severity(severity: Optional) = severity(severity.getOrNull()) + + /** + * Sets [Builder.severity] to an arbitrary JSON value. + * + * You should usually call [Builder.severity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun severity(severity: JsonField) = apply { this.severity = severity } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Pagerduty]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Pagerduty = + Pagerduty( + eventAction, + routingKey, + severity, + source, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Pagerduty = apply { + if (validated) { + return@apply + } + + eventAction() + routingKey() + severity() + source() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (eventAction.asKnown().isPresent) 1 else 0) + + (if (routingKey.asKnown().isPresent) 1 else 0) + + (if (severity.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Pagerduty && + eventAction == other.eventAction && + routingKey == other.routingKey && + severity == other.severity && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(eventAction, routingKey, severity, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Pagerduty{eventAction=$eventAction, routingKey=$routingKey, severity=$severity, source=$source, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PagerdutyRecipient && + pagerduty == other.pagerduty && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(pagerduty, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PagerdutyRecipient{pagerduty=$pagerduty, additionalProperties=$additionalProperties}" + } + + class WebhookRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val webhook: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("webhook") + @ExcludeMissing + webhook: JsonField = JsonMissing.of() + ) : this(webhook, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun webhook(): Webhook = webhook.getRequired("webhook") + + /** + * Returns the raw JSON value of [webhook]. + * + * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook") @ExcludeMissing fun _webhook(): JsonField = webhook + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebhookRecipient]. + * + * The following fields are required: + * ```java + * .webhook() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookRecipient]. */ + class Builder internal constructor() { + + private var webhook: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookRecipient: WebhookRecipient) = apply { + webhook = webhookRecipient.webhook + additionalProperties = webhookRecipient.additionalProperties.toMutableMap() + } + + fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) + + /** + * Sets [Builder.webhook] to an arbitrary JSON value. + * + * You should usually call [Builder.webhook] with a well-typed [Webhook] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhook(webhook: JsonField) = apply { this.webhook = webhook } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebhookRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .webhook() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebhookRecipient = + WebhookRecipient( + checkRequired("webhook", webhook), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebhookRecipient = apply { + if (validated) { + return@apply + } + + webhook().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (webhook.asKnown().getOrNull()?.validity() ?: 0) + + class Webhook + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val authentication: JsonField, + private val headers: JsonField, + private val method: JsonField, + private val profile: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("authentication") + @ExcludeMissing + authentication: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("profile") + @ExcludeMissing + profile: JsonField = JsonMissing.of(), + ) : this(url, authentication, headers, method, profile, mutableMapOf()) + + /** + * The URL to send the webhook request to. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * Authentication configuration for the webhook request. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun authentication(): Optional = + authentication.getOptional("authentication") + + /** + * Custom headers to include in the webhook request. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * The HTTP method to use for the webhook request. Defaults to POST if not + * specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun method(): Optional = method.getOptional("method") + + /** + * Specifies what profile information is included in the request payload. Defaults + * to 'limited' if not specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun profile(): Optional = profile.getOptional("profile") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [authentication]. + * + * Unlike [authentication], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authentication") + @ExcludeMissing + fun _authentication(): JsonField = authentication + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("headers") + @ExcludeMissing + fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("profile") + @ExcludeMissing + fun _profile(): JsonField = profile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Webhook]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Webhook]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var authentication: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var method: JsonField = JsonMissing.of() + private var profile: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhook: Webhook) = apply { + url = webhook.url + authentication = webhook.authentication + headers = webhook.headers + method = webhook.method + profile = webhook.profile + additionalProperties = webhook.additionalProperties.toMutableMap() + } + + /** The URL to send the webhook request to. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Authentication configuration for the webhook request. */ + fun authentication(authentication: Authentication?) = + authentication(JsonField.ofNullable(authentication)) + + /** + * Alias for calling [Builder.authentication] with + * `authentication.orElse(null)`. + */ + fun authentication(authentication: Optional) = + authentication(authentication.getOrNull()) + + /** + * Sets [Builder.authentication] to an arbitrary JSON value. + * + * You should usually call [Builder.authentication] with a well-typed + * [Authentication] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun authentication(authentication: JsonField) = apply { + this.authentication = authentication + } + + /** Custom headers to include in the webhook request. */ + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** + * The HTTP method to use for the webhook request. Defaults to POST if not + * specified. + */ + fun method(method: Method?) = method(JsonField.ofNullable(method)) + + /** Alias for calling [Builder.method] with `method.orElse(null)`. */ + fun method(method: Optional) = method(method.getOrNull()) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** + * Specifies what profile information is included in the request payload. + * Defaults to 'limited' if not specified. + */ + fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) + + /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ + fun profile(profile: Optional) = profile(profile.getOrNull()) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Webhook]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Webhook = + Webhook( + checkRequired("url", url), + authentication, + headers, + method, + profile, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Webhook = apply { + if (validated) { + return@apply + } + + url() + authentication().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + method().ifPresent { it.validate() } + profile().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (authentication.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (profile.asKnown().getOrNull()?.validity() ?: 0) + + /** Authentication configuration for the webhook request. */ + class Authentication + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val mode: JsonField, + private val token: JsonField, + private val password: JsonField, + private val username: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("mode") + @ExcludeMissing + mode: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + token: JsonField = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField = JsonMissing.of(), + @JsonProperty("username") + @ExcludeMissing + username: JsonField = JsonMissing.of(), + ) : this(mode, token, password, username, mutableMapOf()) + + /** + * The authentication mode to use. Defaults to 'none' if not specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun mode(): Mode = mode.getRequired("mode") + + /** + * Token for bearer authentication. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Password for basic authentication. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun password(): Optional = password.getOptional("password") + + /** + * Username for basic authentication. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun username(): Optional = username.getOptional("username") + + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("password") + @ExcludeMissing + fun _password(): JsonField = password + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("username") + @ExcludeMissing + fun _username(): JsonField = username + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Authentication]. + * + * The following fields are required: + * ```java + * .mode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Authentication]. */ + class Builder internal constructor() { + + private var mode: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var password: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(authentication: Authentication) = apply { + mode = authentication.mode + token = authentication.token + password = authentication.password + username = authentication.username + additionalProperties = + authentication.additionalProperties.toMutableMap() + } + + /** The authentication mode to use. Defaults to 'none' if not specified. */ + fun mode(mode: Mode) = mode(JsonField.of(mode)) + + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [Mode] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + /** Token for bearer authentication. */ + fun token(token: String?) = token(JsonField.ofNullable(token)) + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Password for basic authentication. */ + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun password(password: JsonField) = apply { + this.password = password + } + + /** Username for basic authentication. */ + fun username(username: String?) = username(JsonField.ofNullable(username)) + + /** Alias for calling [Builder.username] with `username.orElse(null)`. */ + fun username(username: Optional) = username(username.getOrNull()) + + /** + * Sets [Builder.username] to an arbitrary JSON value. + * + * You should usually call [Builder.username] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun username(username: JsonField) = apply { + this.username = username + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Authentication]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .mode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Authentication = + Authentication( + checkRequired("mode", mode), + token, + password, + username, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Authentication = apply { + if (validated) { + return@apply + } + + mode().validate() + token() + password() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (mode.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + /** The authentication mode to use. Defaults to 'none' if not specified. */ + class Mode + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("none") + + @JvmField val BASIC = of("basic") + + @JvmField val BEARER = of("bearer") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + NONE, + BASIC, + BEARER, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + BASIC, + BEARER, + /** + * An enum member indicating that [Mode] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + BASIC -> Value.BASIC + BEARER -> Value.BEARER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always + * known and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a + * not a known member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + BASIC -> Known.BASIC + BEARER -> Known.BEARER + else -> throw CourierInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does + * not have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Mode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Authentication && + mode == other.mode && + token == other.token && + password == other.password && + username == other.username && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(mode, token, password, username, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Authentication{mode=$mode, token=$token, password=$password, username=$username, additionalProperties=$additionalProperties}" + } + + /** Custom headers to include in the webhook request. */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + /** + * The HTTP method to use for the webhook request. Defaults to POST if not + * specified. + */ + class Method + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val POST = of("POST") + + @JvmField val PUT = of("PUT") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + POST, + PUT, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + POST, + PUT, + /** + * An enum member indicating that [Method] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + POST -> Value.POST + PUT -> Value.PUT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + POST -> Known.POST + PUT -> Known.PUT + else -> throw CourierInvalidDataException("Unknown Method: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Method && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies what profile information is included in the request payload. Defaults + * to 'limited' if not specified. + */ + class Profile + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val LIMITED = of("limited") + + @JvmField val EXPANDED = of("expanded") + + @JvmStatic fun of(value: String) = Profile(JsonField.of(value)) + } + + /** An enum containing [Profile]'s known values. */ + enum class Known { + LIMITED, + EXPANDED, + } + + /** + * An enum containing [Profile]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Profile] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIMITED, + EXPANDED, + /** + * An enum member indicating that [Profile] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIMITED -> Value.LIMITED + EXPANDED -> Value.EXPANDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIMITED -> Known.LIMITED + EXPANDED -> Known.EXPANDED + else -> throw CourierInvalidDataException("Unknown Profile: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Webhook && + url == other.url && + authentication == other.authentication && + headers == other.headers && + method == other.method && + profile == other.profile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + url, + authentication, + headers, + method, + profile, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Webhook{url=$url, authentication=$authentication, headers=$headers, method=$method, profile=$profile, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebhookRecipient && + webhook == other.webhook && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(webhook, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookRecipient{webhook=$webhook, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseMessageSendTo && + to == other.to && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(to, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BaseMessageSendTo{to=$to, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt new file mode 100644 index 00000000..b1857ad5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -0,0 +1,671 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ +@JsonDeserialize(using = Content.Deserializer::class) +@JsonSerialize(using = Content.Serializer::class) +class Content +private constructor( + private val elemental: ElementalContent? = null, + private val elementalContentSugar: ElementalContentSugar? = null, + private val _json: JsonValue? = null, +) { + + fun elemental(): Optional = Optional.ofNullable(elemental) + + /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ + fun elementalContentSugar(): Optional = + Optional.ofNullable(elementalContentSugar) + + fun isElemental(): Boolean = elemental != null + + fun isElementalContentSugar(): Boolean = elementalContentSugar != null + + fun asElemental(): ElementalContent = elemental.getOrThrow("elemental") + + /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ + fun asElementalContentSugar(): ElementalContentSugar = + elementalContentSugar.getOrThrow("elementalContentSugar") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + elemental != null -> visitor.visitElemental(elemental) + elementalContentSugar != null -> + visitor.visitElementalContentSugar(elementalContentSugar) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitElemental(elemental: ElementalContent) { + elemental.validate() + } + + override fun visitElementalContentSugar( + elementalContentSugar: ElementalContentSugar + ) { + elementalContentSugar.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitElemental(elemental: ElementalContent) = elemental.validity() + + override fun visitElementalContentSugar( + elementalContentSugar: ElementalContentSugar + ) = elementalContentSugar.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + elemental == other.elemental && + elementalContentSugar == other.elementalContentSugar + } + + override fun hashCode(): Int = Objects.hash(elemental, elementalContentSugar) + + override fun toString(): String = + when { + elemental != null -> "Content{elemental=$elemental}" + elementalContentSugar != null -> "Content{elementalContentSugar=$elementalContentSugar}" + _json != null -> "Content{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Content") + } + + companion object { + + @JvmStatic fun ofElemental(elemental: ElementalContent) = Content(elemental = elemental) + + /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ + @JvmStatic + fun ofElementalContentSugar(elementalContentSugar: ElementalContentSugar) = + Content(elementalContentSugar = elementalContentSugar) + } + + /** An interface that defines how to map each variant of [Content] to a value of type [T]. */ + interface Visitor { + + fun visitElemental(elemental: ElementalContent): T + + /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ + fun visitElementalContentSugar(elementalContentSugar: ElementalContentSugar): T + + /** + * Maps an unknown variant of [Content] to a value of type [T]. + * + * An instance of [Content] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Content: $json") + } + } + + internal class Deserializer : BaseDeserializer(Content::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Content { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Content(elemental = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Content(elementalContentSugar = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> Content(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Content::class) { + + override fun serialize( + value: Content, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.elemental != null -> generator.writeObject(value.elemental) + value.elementalContentSugar != null -> + generator.writeObject(value.elementalContentSugar) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Content") + } + } + } + + class ElementalContent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val elements: JsonField>, + private val version: JsonField, + private val brand: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), + ) : this(elements, version, brand, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * For example, "2022-01-01" + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalContent]. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalContent]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var version: JsonField? = null + private var brand: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalContent: ElementalContent) = apply { + elements = elementalContent.elements.map { it.toMutableList() } + version = elementalContent.version + brand = elementalContent.brand + additionalProperties = elementalContent.additionalProperties.toMutableMap() + } + + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + /** For example, "2022-01-01" */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun brand(brand: JsonValue) = apply { this.brand = brand } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalContent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalContent = + ElementalContent( + checkRequired("elements", elements).map { it.toImmutable() }, + checkRequired("version", version), + brand, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalContent = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + version() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalContent && + elements == other.elements && + version == other.version && + brand == other.brand && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, version, brand, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" + } + + /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ + class ElementalContentSugar + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val body: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(body, title, mutableMapOf()) + + /** + * The text content displayed in the notification. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun body(): String = body.getRequired("body") + + /** + * The title to be displayed by supported channels i.e. push, email (as subject) + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun title(): String = title.getRequired("title") + + /** + * Returns the raw JSON value of [body]. + * + * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalContentSugar]. + * + * The following fields are required: + * ```java + * .body() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalContentSugar]. */ + class Builder internal constructor() { + + private var body: JsonField? = null + private var title: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalContentSugar: ElementalContentSugar) = apply { + body = elementalContentSugar.body + title = elementalContentSugar.title + additionalProperties = elementalContentSugar.additionalProperties.toMutableMap() + } + + /** The text content displayed in the notification. */ + fun body(body: String) = body(JsonField.of(body)) + + /** + * Sets [Builder.body] to an arbitrary JSON value. + * + * You should usually call [Builder.body] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun body(body: JsonField) = apply { this.body = body } + + /** The title to be displayed by supported channels i.e. push, email (as subject) */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalContentSugar]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalContentSugar = + ElementalContentSugar( + checkRequired("body", body), + checkRequired("title", title), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalContentSugar = apply { + if (validated) { + return@apply + } + + body() + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (body.asKnown().isPresent) 1 else 0) + (if (title.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalContentSugar && + body == other.body && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(body, title, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalContentSugar{body=$body, title=$title, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt new file mode 100644 index 00000000..68c66523 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt @@ -0,0 +1,572 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ElementalChannelNode +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val channel: JsonField, + private val channels: JsonField>, + private val elements: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val raw: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(channel, channels, elements, if_, loop, raw, ref, mutableMapOf()) + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` is + * `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elements(): Optional> = elements.getOptional("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalChannelNode]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalChannelNode]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channels: JsonField>? = null + private var elements: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalChannelNode: ElementalChannelNode) = apply { + channel = elementalChannelNode.channel + channels = elementalChannelNode.channels.map { it.toMutableList() } + elements = elementalChannelNode.elements.map { it.toMutableList() } + if_ = elementalChannelNode.if_ + loop = elementalChannelNode.loop + raw = elementalChannelNode.raw + ref = elementalChannelNode.ref + additionalProperties = elementalChannelNode.additionalProperties.toMutableMap() + } + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` + * is `required`. + */ + fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) + + /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ + fun elements(elements: Optional>) = elements(elements.getOrNull()) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + */ + fun raw(raw: Raw?) = raw(JsonField.ofNullable(raw)) + + /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ + fun raw(raw: Optional) = raw(raw.getOrNull()) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [Raw] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalChannelNode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalChannelNode = + ElementalChannelNode( + checkRequired("channel", channel), + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + (elements ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + raw, + ref, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalChannelNode = apply { + if (validated) { + return@apply + } + + channel() + channels() + elements().ifPresent { it.forEach { it.validate() } } + if_() + loop() + raw().ifPresent { it.validate() } + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (raw.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. + */ + class Raw + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Raw]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Raw]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(raw: Raw) = apply { + additionalProperties = raw.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Raw]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Raw = Raw(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Raw = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Raw && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Raw{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalChannelNode && + channel == other.channel && + channels == other.channels && + elements == other.elements && + if_ == other.if_ && + loop == other.loop && + raw == other.raw && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, channels, elements, if_, loop, raw, ref, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalChannelNode{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt new file mode 100644 index 00000000..c0d905c7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ElementalGroupNode +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val elements: JsonField>, + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(elements, channels, if_, loop, ref, mutableMapOf()) + + /** + * Sub elements to render. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalGroupNode]. + * + * The following fields are required: + * ```java + * .elements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalGroupNode]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalGroupNode: ElementalGroupNode) = apply { + elements = elementalGroupNode.elements.map { it.toMutableList() } + channels = elementalGroupNode.channels.map { it.toMutableList() } + if_ = elementalGroupNode.if_ + loop = elementalGroupNode.loop + ref = elementalGroupNode.ref + additionalProperties = elementalGroupNode.additionalProperties.toMutableMap() + } + + /** Sub elements to render. */ + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalGroupNode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalGroupNode = + ElementalGroupNode( + checkRequired("elements", elements).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalGroupNode = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + channels() + if_() + loop() + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalGroupNode && + elements == other.elements && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, channels, if_, loop, ref, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalGroupNode{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt new file mode 100644 index 00000000..17b2304e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt @@ -0,0 +1,4182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is sent + * through email, and a more concise message in a push notification. Channel elements are only valid + * as top-level elements; you cannot nest channel elements. If there is a channel element specified + * at the top-level of the document, all sibling elements must be channel elements. Note: As an + * alternative, most elements support a `channel` property. Which allows you to selectively display + * an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for + * more details. + */ +@JsonDeserialize(using = ElementalNode.Deserializer::class) +@JsonSerialize(using = ElementalNode.Serializer::class) +class ElementalNode +private constructor( + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val unionMember3: UnionMember3? = null, + private val unionMember4: UnionMember4? = null, + private val unionMember5: UnionMember5? = null, + private val unionMember6: UnionMember6? = null, + private val unionMember7: UnionMember7? = null, + private val _json: JsonValue? = null, +) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun unionMember4(): Optional = Optional.ofNullable(unionMember4) + + fun unionMember5(): Optional = Optional.ofNullable(unionMember5) + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun unionMember6(): Optional = Optional.ofNullable(unionMember6) + + fun unionMember7(): Optional = Optional.ofNullable(unionMember7) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUnionMember3(): Boolean = unionMember3 != null + + fun isUnionMember4(): Boolean = unionMember4 != null + + fun isUnionMember5(): Boolean = unionMember5 != null + + fun isUnionMember6(): Boolean = unionMember6 != null + + fun isUnionMember7(): Boolean = unionMember7 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") + + fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") + + fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) + unionMember4 != null -> visitor.visitUnionMember4(unionMember4) + unionMember5 != null -> visitor.visitUnionMember5(unionMember5) + unionMember6 != null -> visitor.visitUnionMember6(unionMember6) + unionMember7 != null -> visitor.visitUnionMember7(unionMember7) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ElementalNode = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } + + override fun visitUnionMember4(unionMember4: UnionMember4) { + unionMember4.validate() + } + + override fun visitUnionMember5(unionMember5: UnionMember5) { + unionMember5.validate() + } + + override fun visitUnionMember6(unionMember6: UnionMember6) { + unionMember6.validate() + } + + override fun visitUnionMember7(unionMember7: UnionMember7) { + unionMember7.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + + override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() + + override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() + + override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() + + override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() + + override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalNode && + unionMember0 == other.unionMember0 && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + unionMember3 == other.unionMember3 && + unionMember4 == other.unionMember4 && + unionMember5 == other.unionMember5 && + unionMember6 == other.unionMember6 && + unionMember7 == other.unionMember7 + } + + override fun hashCode(): Int = + Objects.hash( + unionMember0, + unionMember1, + unionMember2, + unionMember3, + unionMember4, + unionMember5, + unionMember6, + unionMember7, + ) + + override fun toString(): String = + when { + unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" + unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" + unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" + unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" + unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" + unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" + unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" + unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" + _json != null -> "ElementalNode{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ElementalNode") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) + + /** + * The channel element allows a notification to be customized based on which channel it is + * sent through. For example, you may want to display a detailed message when the + * notification is sent through email, and a more concise message in a push notification. + * Channel elements are only valid as top-level elements; you cannot nest channel elements. + * If there is a channel element specified at the top-level of the document, all sibling + * elements must be channel elements. Note: As an alternative, most elements support a + * `channel` property. Which allows you to selectively display an individual element on a + * per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) + + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) + + @JvmStatic + fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) + + @JvmStatic + fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) + + /** + * Allows you to group elements together. This can be useful when used in combination with + * "if" or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + @JvmStatic + fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) + + @JvmStatic + fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) + } + + /** + * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * The channel element allows a notification to be customized based on which channel it is + * sent through. For example, you may want to display a detailed message when the + * notification is sent through email, and a more concise message in a push notification. + * Channel elements are only valid as top-level elements; you cannot nest channel elements. + * If there is a channel element specified at the top-level of the document, all sibling + * elements must be channel elements. Note: As an alternative, most elements support a + * `channel` property. Which allows you to selectively display an individual element on a + * per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUnionMember3(unionMember3: UnionMember3): T + + fun visitUnionMember4(unionMember4: UnionMember4): T + + fun visitUnionMember5(unionMember5: UnionMember5): T + + /** + * Allows you to group elements together. This can be useful when used in combination with + * "if" or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun visitUnionMember6(unionMember6: UnionMember6): T + + fun visitUnionMember7(unionMember7: UnionMember7): T + + /** + * Maps an unknown variant of [ElementalNode] to a value of type [T]. + * + * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ElementalNode: $json") + } + } + + internal class Deserializer : BaseDeserializer(ElementalNode::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember4 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember5 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember6 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember7 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ElementalNode(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ElementalNode::class) { + + override fun serialize( + value: ElementalNode, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) + value.unionMember4 != null -> generator.writeObject(value.unionMember4) + value.unionMember5 != null -> generator.writeObject(value.unionMember5) + value.unionMember6 != null -> generator.writeObject(value.unionMember6) + value.unionMember7 != null -> generator.writeObject(value.unionMember7) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ElementalNode") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + channels = unionMember0.channels.map { it.toMutableList() } + if_ = unionMember0.if_ + loop = unionMember0.loop + ref = unionMember0.ref + type = unionMember0.type + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + channels = unionMember1.channels.map { it.toMutableList() } + if_ = unionMember1.if_ + loop = unionMember1.loop + ref = unionMember1.ref + type = unionMember1.type + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val META = of("meta") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + META + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + META, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + META -> Value.META + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + META -> Known.META + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val channels: JsonField>, + private val elements: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val raw: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("raw") + @ExcludeMissing + raw: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channel, channels, elements, if_, loop, raw, ref, type, mutableMapOf()) + + fun toElementalChannelNode(): ElementalChannelNode = + ElementalChannelNode.builder() + .channel(channel) + .channels(channels) + .elements(elements) + .if_(if_) + .loop(loop) + .raw(raw) + .ref(ref) + .build() + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` + * is `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elements(): Optional> = elements.getOptional("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember2]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channels: JsonField>? = null + private var elements: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + channel = unionMember2.channel + channels = unionMember2.channels.map { it.toMutableList() } + elements = unionMember2.elements.map { it.toMutableList() } + if_ = unionMember2.if_ + loop = unionMember2.loop + raw = unionMember2.raw + ref = unionMember2.ref + type = unionMember2.type + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + /** + * The channel the contents of this element should be applied to. Can be `email`, + * `push`, `direct_message`, `sms` or a provider such as slack + */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, + * `elements` is `required`. + */ + fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) + + /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ + fun elements(elements: Optional>) = elements(elements.getOrNull()) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + */ + fun raw(raw: ElementalChannelNode.Raw?) = raw(JsonField.ofNullable(raw)) + + /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ + fun raw(raw: Optional) = raw(raw.getOrNull()) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [ElementalChannelNode.Raw] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember2 = + UnionMember2( + checkRequired("channel", channel), + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + (elements ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + raw, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + channel() + channels() + elements().ifPresent { it.forEach { it.validate() } } + if_() + loop() + raw().ifPresent { it.validate() } + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (raw.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHANNEL = of("channel") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CHANNEL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHANNEL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHANNEL -> Value.CHANNEL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHANNEL -> Known.CHANNEL + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + channel == other.channel && + channels == other.channels && + elements == other.elements && + if_ == other.if_ && + loop == other.loop && + raw == other.raw && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + channel, + channels, + elements, + if_, + loop, + raw, + ref, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + channels = unionMember3.channels.map { it.toMutableList() } + if_ = unionMember3.if_ + loop = unionMember3.loop + ref = unionMember3.ref + type = unionMember3.type + additionalProperties = unionMember3.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = + UnionMember3( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IMAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IMAGE -> Value.IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IMAGE -> Known.IMAGE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember4 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember4]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember4: UnionMember4) = apply { + channels = unionMember4.channels.map { it.toMutableList() } + if_ = unionMember4.if_ + loop = unionMember4.loop + ref = unionMember4.ref + type = unionMember4.type + additionalProperties = unionMember4.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember4]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember4 = + UnionMember4( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember4 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTION = of("action") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACTION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTION, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTION -> Value.ACTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTION -> Known.ACTION + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember4 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember5 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember5]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember5: UnionMember5) = apply { + channels = unionMember5.channels.map { it.toMutableList() } + if_ = unionMember5.if_ + loop = unionMember5.loop + ref = unionMember5.ref + type = unionMember5.type + additionalProperties = unionMember5.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember5]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember5 = + UnionMember5( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember5 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DIVIDER = of("divider") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIVIDER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDER -> Value.DIVIDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DIVIDER -> Known.DIVIDER + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember5 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + class UnionMember6 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val elements: JsonField>, + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(elements, channels, if_, loop, ref, type, mutableMapOf()) + + fun toElementalGroupNode(): ElementalGroupNode = + ElementalGroupNode.builder() + .elements(elements) + .channels(channels) + .if_(if_) + .loop(loop) + .ref(ref) + .build() + + /** + * Sub elements to render. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember6]. + * + * The following fields are required: + * ```java + * .elements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember6]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember6: UnionMember6) = apply { + elements = unionMember6.elements.map { it.toMutableList() } + channels = unionMember6.channels.map { it.toMutableList() } + if_ = unionMember6.if_ + loop = unionMember6.loop + ref = unionMember6.ref + type = unionMember6.type + additionalProperties = unionMember6.additionalProperties.toMutableMap() + } + + /** Sub elements to render. */ + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember6]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember6 = + UnionMember6( + checkRequired("elements", elements).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember6 = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUP = of("group") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GROUP + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUP, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUP -> Value.GROUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUP -> Known.GROUP + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember6 && + elements == other.elements && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember6{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember7 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember7]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember7: UnionMember7) = apply { + channels = unionMember7.channels.map { it.toMutableList() } + if_ = unionMember7.if_ + loop = unionMember7.loop + ref = unionMember7.ref + type = unionMember7.type + additionalProperties = unionMember7.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember7]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember7 = + UnionMember7( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember7 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val QUOTE = of("quote") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + QUOTE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + QUOTE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUOTE -> Value.QUOTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUOTE -> Known.QUOTE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember7 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt new file mode 100644 index 00000000..d9a75557 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt @@ -0,0 +1,1873 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.bulk.UserRecipient +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Describes the content of the message in a way that will work for email, push, chat, or any + * channel. + */ +@JsonDeserialize(using = Message.Deserializer::class) +@JsonSerialize(using = Message.Serializer::class) +class Message +private constructor( + private val content: ContentMessage? = null, + private val template: TemplateMessage? = null, + private val _json: JsonValue? = null, +) { + + /** + * Describes the content of the message in a way that will work for email, push, chat, or any + * channel. + */ + fun content(): Optional = Optional.ofNullable(content) + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + fun template(): Optional = Optional.ofNullable(template) + + fun isContent(): Boolean = content != null + + fun isTemplate(): Boolean = template != null + + /** + * Describes the content of the message in a way that will work for email, push, chat, or any + * channel. + */ + fun asContent(): ContentMessage = content.getOrThrow("content") + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + fun asTemplate(): TemplateMessage = template.getOrThrow("template") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + content != null -> visitor.visitContent(content) + template != null -> visitor.visitTemplate(template) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitContent(content: ContentMessage) { + content.validate() + } + + override fun visitTemplate(template: TemplateMessage) { + template.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitContent(content: ContentMessage) = content.validity() + + override fun visitTemplate(template: TemplateMessage) = template.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Message && content == other.content && template == other.template + } + + override fun hashCode(): Int = Objects.hash(content, template) + + override fun toString(): String = + when { + content != null -> "Message{content=$content}" + template != null -> "Message{template=$template}" + _json != null -> "Message{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Message") + } + + companion object { + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. + */ + @JvmStatic fun ofContent(content: ContentMessage) = Message(content = content) + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + @JvmStatic fun ofTemplate(template: TemplateMessage) = Message(template = template) + } + + /** An interface that defines how to map each variant of [Message] to a value of type [T]. */ + interface Visitor { + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. + */ + fun visitContent(content: ContentMessage): T + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + fun visitTemplate(template: TemplateMessage): T + + /** + * Maps an unknown variant of [Message] to a value of type [T]. + * + * An instance of [Message] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version than + * the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Message: $json") + } + } + + internal class Deserializer : BaseDeserializer(Message::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Message { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Message(content = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Message(template = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> Message(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Message::class) { + + override fun serialize( + value: Message, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.content != null -> generator.writeObject(value.content) + value.template != null -> generator.writeObject(value.template) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Message") + } + } + } + + /** + * Describes the content of the message in a way that will work for email, push, chat, or any + * channel. + */ + class ContentMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brandId: JsonField, + private val channels: JsonField, + private val context: JsonField, + private val data: JsonField, + private val delay: JsonField, + private val expiry: JsonField, + private val metadata: JsonField, + private val preferences: JsonField, + private val providers: JsonField, + private val routing: JsonField, + private val timeout: JsonField, + private val to: JsonField, + private val content: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("delay") + @ExcludeMissing + delay: JsonField = JsonMissing.of(), + @JsonProperty("expiry") + @ExcludeMissing + expiry: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + @JsonProperty("routing") + @ExcludeMissing + routing: JsonField = JsonMissing.of(), + @JsonProperty("timeout") + @ExcludeMissing + timeout: JsonField = JsonMissing.of(), + @JsonProperty("to") + @ExcludeMissing + to: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + ) : this( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + content, + mutableMapOf(), + ) + + fun toBaseMessage(): BaseMessage = + BaseMessage.builder() + .brandId(brandId) + .channels(channels) + .context(context) + .data(data) + .delay(delay) + .expiry(expiry) + .metadata(metadata) + .preferences(preferences) + .providers(providers) + .routing(routing) + .timeout(timeout) + .build() + + fun toBaseMessageSendTo(): BaseMessageSendTo = BaseMessageSendTo.builder().to(to).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * "Define run-time configuration for one or more channels. If you don't specify channels, + * the default configuration for each channel will be used. Valid ChannelId's are: email, + * sms, push, inbox, direct_message, banner, and webhook." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * Context to load with this recipient. Will override any context set on message.context. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * An arbitrary object that includes any data you want to pass to the message. The data will + * populate the corresponding template or elements variables. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an ISO + * 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap + * opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun delay(): Optional = delay.getOptional("delay") + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. Note: + * This is only valid for the Courier Inbox channel as of 12-08-2022." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiry(): Optional = expiry.getOptional("expiry") + + /** + * Metadata such as utm tracking attached with the notification through this channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = + preferences.getOptional("preferences") + + /** + * An object whose keys are valid provider identifiers which map to an object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the message. If + * no routing key is specified, Courier will use the default routing configuration or + * routing defined by the template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routing(): Optional = routing.getOptional("routing") + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * The recipient or a list of recipients of the message + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + + /** + * Describes the content of the message in a way that will work for email, push, chat, or + * any channel. Either this or template must be specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): Content = content.getRequired("content") + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [delay]. + * + * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay + + /** + * Returns the raw JSON value of [expiry]. + * + * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry") + @ExcludeMissing + fun _expiry(): JsonField = expiry + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField = providers + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") + @ExcludeMissing + fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") + @ExcludeMissing + fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ContentMessage]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContentMessage]. */ + class Builder internal constructor() { + + private var brandId: JsonField = JsonMissing.of() + private var channels: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var delay: JsonField = JsonMissing.of() + private var expiry: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var routing: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() + private var content: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contentMessage: ContentMessage) = apply { + brandId = contentMessage.brandId + channels = contentMessage.channels + context = contentMessage.context + data = contentMessage.data + delay = contentMessage.delay + expiry = contentMessage.expiry + metadata = contentMessage.metadata + preferences = contentMessage.preferences + providers = contentMessage.providers + routing = contentMessage.routing + timeout = contentMessage.timeout + to = contentMessage.to + content = contentMessage.content + additionalProperties = contentMessage.additionalProperties.toMutableMap() + } + + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * "Define run-time configuration for one or more channels. If you don't specify + * channels, the default configuration for each channel will be used. Valid ChannelId's + * are: email, sms, push, inbox, direct_message, banner, and webhook." + */ + fun channels(channels: BaseMessage.Channels?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed [BaseMessage.Channels] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channels(channels: JsonField) = apply { + this.channels = channels + } + + /** + * Context to load with this recipient. Will override any context set on + * message.context. + */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + /** + * An arbitrary object that includes any data you want to pass to the message. The data + * will populate the corresponding template or elements variables. + */ + fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an + * ISO 8601 timestamp that specifies when it should be delivered. Until with an + * OpenStreetMap opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) + + /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ + fun delay(delay: Optional) = delay(delay.getOrNull()) + + /** + * Sets [Builder.delay] to an arbitrary JSON value. + * + * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun delay(delay: JsonField) = apply { this.delay = delay } + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. + * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." + */ + fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) + + /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ + fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) + + /** + * Sets [Builder.expiry] to an arbitrary JSON value. + * + * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiry(expiry: JsonField) = apply { this.expiry = expiry } + + /** + * Metadata such as utm tracking attached with the notification through this channel. + */ + fun metadata(metadata: BaseMessage.Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [BaseMessage.Metadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun preferences(preferences: BaseMessage.Preferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [BaseMessage.Preferences] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** An object whose keys are valid provider identifiers which map to an object. */ + fun providers(providers: BaseMessage.Providers?) = + providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = + providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed [BaseMessage.Providers] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun providers(providers: JsonField) = apply { + this.providers = providers + } + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the + * message. If no routing key is specified, Courier will use the default routing + * configuration or routing defined by the template. + */ + fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) + + /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ + fun routing(routing: Optional) = routing(routing.getOrNull()) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routing(routing: JsonField) = apply { this.routing = routing } + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + */ + fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + /** The recipient or a list of recipients of the message */ + fun to(to: BaseMessageSendTo.To?) = to(JsonField.ofNullable(to)) + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.getOrNull()) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [BaseMessageSendTo.To] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun to(to: JsonField) = apply { this.to = to } + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)`. + */ + fun to(audienceRecipient: BaseMessageSendTo.To.AudienceRecipient) = + to(BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)) + + /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember1(unionMember1)`. */ + fun to(unionMember1: BaseMessageSendTo.To.UnionMember1) = + to(BaseMessageSendTo.To.ofUnionMember1(unionMember1)) + + /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember2(unionMember2)`. */ + fun to(unionMember2: BaseMessageSendTo.To.UnionMember2) = + to(BaseMessageSendTo.To.ofUnionMember2(unionMember2)) + + /** + * Alias for calling [to] with `BaseMessageSendTo.To.ofUserRecipient(userRecipient)`. + */ + fun to(userRecipient: UserRecipient) = + to(BaseMessageSendTo.To.ofUserRecipient(userRecipient)) + + /** + * Alias for calling [to] with `BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)`. + */ + fun to(slackRecipient: BaseMessageSendTo.To.SlackRecipient) = + to(BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)) + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)`. + */ + fun to(msTeamsRecipient: BaseMessageSendTo.To.MsTeamsRecipient) = + to(BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)) + + /** + * Alias for calling [to] with `BaseMessageSendTo.To.ofRecipientData(recipientData)`. + */ + fun to(recipientData: BaseMessageSendTo.To.RecipientData) = + to(BaseMessageSendTo.To.ofRecipientData(recipientData)) + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)`. + */ + fun to(pagerdutyRecipient: BaseMessageSendTo.To.PagerdutyRecipient) = + to(BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)) + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)`. + */ + fun to(webhookRecipient: BaseMessageSendTo.To.WebhookRecipient) = + to(BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)) + + /** Alias for calling [to] with `BaseMessageSendTo.To.ofRecipients(recipients)`. */ + fun toOfRecipients(recipients: List) = + to(BaseMessageSendTo.To.ofRecipients(recipients)) + + /** + * Describes the content of the message in a way that will work for email, push, chat, + * or any channel. Either this or template must be specified. + */ + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ + fun content(elemental: Content.ElementalContent) = + content(Content.ofElemental(elemental)) + + /** + * Alias for calling [content] with + * `Content.ofElementalContentSugar(elementalContentSugar)`. + */ + fun content(elementalContentSugar: Content.ElementalContentSugar) = + content(Content.ofElementalContentSugar(elementalContentSugar)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContentMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ContentMessage = + ContentMessage( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + checkRequired("content", content), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ContentMessage = apply { + if (validated) { + return@apply + } + + brandId() + channels().ifPresent { it.validate() } + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + delay().ifPresent { it.validate() } + expiry().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + preferences().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + routing().ifPresent { it.validate() } + timeout().ifPresent { it.validate() } + to().ifPresent { it.validate() } + content().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brandId.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (delay.asKnown().getOrNull()?.validity() ?: 0) + + (expiry.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (to.asKnown().getOrNull()?.validity() ?: 0) + + (content.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContentMessage && + brandId == other.brandId && + channels == other.channels && + context == other.context && + data == other.data && + delay == other.delay && + expiry == other.expiry && + metadata == other.metadata && + preferences == other.preferences && + providers == other.providers && + routing == other.routing && + timeout == other.timeout && + to == other.to && + content == other.content && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + content, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContentMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, to=$to, content=$content, additionalProperties=$additionalProperties}" + } + + /** + * A template for a type of message that can be sent more than once. For example, you might + * create an "Appointment Reminder" Notification or “Reset Password” Notifications. + */ + class TemplateMessage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brandId: JsonField, + private val channels: JsonField, + private val context: JsonField, + private val data: JsonField, + private val delay: JsonField, + private val expiry: JsonField, + private val metadata: JsonField, + private val preferences: JsonField, + private val providers: JsonField, + private val routing: JsonField, + private val timeout: JsonField, + private val to: JsonField, + private val template: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + data: JsonField = JsonMissing.of(), + @JsonProperty("delay") + @ExcludeMissing + delay: JsonField = JsonMissing.of(), + @JsonProperty("expiry") + @ExcludeMissing + expiry: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + @JsonProperty("routing") + @ExcludeMissing + routing: JsonField = JsonMissing.of(), + @JsonProperty("timeout") + @ExcludeMissing + timeout: JsonField = JsonMissing.of(), + @JsonProperty("to") + @ExcludeMissing + to: JsonField = JsonMissing.of(), + @JsonProperty("template") @ExcludeMissing template: JsonField = JsonMissing.of(), + ) : this( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + template, + mutableMapOf(), + ) + + fun toBaseMessage(): BaseMessage = + BaseMessage.builder() + .brandId(brandId) + .channels(channels) + .context(context) + .data(data) + .delay(delay) + .expiry(expiry) + .metadata(metadata) + .preferences(preferences) + .providers(providers) + .routing(routing) + .timeout(timeout) + .build() + + fun toBaseMessageSendTo(): BaseMessageSendTo = BaseMessageSendTo.builder().to(to).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * "Define run-time configuration for one or more channels. If you don't specify channels, + * the default configuration for each channel will be used. Valid ChannelId's are: email, + * sms, push, inbox, direct_message, banner, and webhook." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * Context to load with this recipient. Will override any context set on message.context. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * An arbitrary object that includes any data you want to pass to the message. The data will + * populate the corresponding template or elements variables. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an ISO + * 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap + * opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun delay(): Optional = delay.getOptional("delay") + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. Note: + * This is only valid for the Courier Inbox channel as of 12-08-2022." + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiry(): Optional = expiry.getOptional("expiry") + + /** + * Metadata such as utm tracking attached with the notification through this channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = + preferences.getOptional("preferences") + + /** + * An object whose keys are valid provider identifiers which map to an object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the message. If + * no routing key is specified, Courier will use the default routing configuration or + * routing defined by the template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routing(): Optional = routing.getOptional("routing") + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * The recipient or a list of recipients of the message + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + + /** + * The id of the notification template to be rendered and sent to the recipient(s). This + * field or the content field must be supplied. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun template(): String = template.getRequired("template") + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [delay]. + * + * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay + + /** + * Returns the raw JSON value of [expiry]. + * + * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry") + @ExcludeMissing + fun _expiry(): JsonField = expiry + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField = providers + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") + @ExcludeMissing + fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") + @ExcludeMissing + fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + /** + * Returns the raw JSON value of [template]. + * + * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TemplateMessage]. + * + * The following fields are required: + * ```java + * .template() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TemplateMessage]. */ + class Builder internal constructor() { + + private var brandId: JsonField = JsonMissing.of() + private var channels: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var delay: JsonField = JsonMissing.of() + private var expiry: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var routing: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() + private var template: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(templateMessage: TemplateMessage) = apply { + brandId = templateMessage.brandId + channels = templateMessage.channels + context = templateMessage.context + data = templateMessage.data + delay = templateMessage.delay + expiry = templateMessage.expiry + metadata = templateMessage.metadata + preferences = templateMessage.preferences + providers = templateMessage.providers + routing = templateMessage.routing + timeout = templateMessage.timeout + to = templateMessage.to + template = templateMessage.template + additionalProperties = templateMessage.additionalProperties.toMutableMap() + } + + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * "Define run-time configuration for one or more channels. If you don't specify + * channels, the default configuration for each channel will be used. Valid ChannelId's + * are: email, sms, push, inbox, direct_message, banner, and webhook." + */ + fun channels(channels: BaseMessage.Channels?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed [BaseMessage.Channels] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channels(channels: JsonField) = apply { + this.channels = channels + } + + /** + * Context to load with this recipient. Will override any context set on + * message.context. + */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + /** + * An arbitrary object that includes any data you want to pass to the message. The data + * will populate the corresponding template or elements variables. + */ + fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + /** + * Defines the time to wait before delivering the message. You can specify one of the + * following options. Duration with the number of milliseconds to delay. Until with an + * ISO 8601 timestamp that specifies when it should be delivered. Until with an + * OpenStreetMap opening_hours-like format that specifies the + * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) + * (e.g., 'Mo-Fr 08:00-18:00pm') + */ + fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) + + /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ + fun delay(delay: Optional) = delay(delay.getOrNull()) + + /** + * Sets [Builder.delay] to an arbitrary JSON value. + * + * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun delay(delay: JsonField) = apply { this.delay = delay } + + /** + * "Expiry allows you to set an absolute or relative time in which a message expires. + * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." + */ + fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) + + /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ + fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) + + /** + * Sets [Builder.expiry] to an arbitrary JSON value. + * + * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiry(expiry: JsonField) = apply { this.expiry = expiry } + + /** + * Metadata such as utm tracking attached with the notification through this channel. + */ + fun metadata(metadata: BaseMessage.Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [BaseMessage.Metadata] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun preferences(preferences: BaseMessage.Preferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed + * [BaseMessage.Preferences] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** An object whose keys are valid provider identifiers which map to an object. */ + fun providers(providers: BaseMessage.Providers?) = + providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = + providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed [BaseMessage.Providers] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun providers(providers: JsonField) = apply { + this.providers = providers + } + + /** + * Allows you to customize which channel(s) Courier will potentially deliver the + * message. If no routing key is specified, Courier will use the default routing + * configuration or routing defined by the template. + */ + fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) + + /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ + fun routing(routing: Optional) = routing(routing.getOrNull()) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun routing(routing: JsonField) = apply { this.routing = routing } + + /** + * Time in ms to attempt the channel before failing over to the next available channel. + */ + fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + /** The recipient or a list of recipients of the message */ + fun to(to: BaseMessageSendTo.To?) = to(JsonField.ofNullable(to)) + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.getOrNull()) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [BaseMessageSendTo.To] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun to(to: JsonField) = apply { this.to = to } + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)`. + */ + fun to(audienceRecipient: BaseMessageSendTo.To.AudienceRecipient) = + to(BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)) + + /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember1(unionMember1)`. */ + fun to(unionMember1: BaseMessageSendTo.To.UnionMember1) = + to(BaseMessageSendTo.To.ofUnionMember1(unionMember1)) + + /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember2(unionMember2)`. */ + fun to(unionMember2: BaseMessageSendTo.To.UnionMember2) = + to(BaseMessageSendTo.To.ofUnionMember2(unionMember2)) + + /** + * Alias for calling [to] with `BaseMessageSendTo.To.ofUserRecipient(userRecipient)`. + */ + fun to(userRecipient: UserRecipient) = + to(BaseMessageSendTo.To.ofUserRecipient(userRecipient)) + + /** + * Alias for calling [to] with `BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)`. + */ + fun to(slackRecipient: BaseMessageSendTo.To.SlackRecipient) = + to(BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)) + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)`. + */ + fun to(msTeamsRecipient: BaseMessageSendTo.To.MsTeamsRecipient) = + to(BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)) + + /** + * Alias for calling [to] with `BaseMessageSendTo.To.ofRecipientData(recipientData)`. + */ + fun to(recipientData: BaseMessageSendTo.To.RecipientData) = + to(BaseMessageSendTo.To.ofRecipientData(recipientData)) + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)`. + */ + fun to(pagerdutyRecipient: BaseMessageSendTo.To.PagerdutyRecipient) = + to(BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)) + + /** + * Alias for calling [to] with + * `BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)`. + */ + fun to(webhookRecipient: BaseMessageSendTo.To.WebhookRecipient) = + to(BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)) + + /** Alias for calling [to] with `BaseMessageSendTo.To.ofRecipients(recipients)`. */ + fun toOfRecipients(recipients: List) = + to(BaseMessageSendTo.To.ofRecipients(recipients)) + + /** + * The id of the notification template to be rendered and sent to the recipient(s). This + * field or the content field must be supplied. + */ + fun template(template: String) = template(JsonField.of(template)) + + /** + * Sets [Builder.template] to an arbitrary JSON value. + * + * You should usually call [Builder.template] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun template(template: JsonField) = apply { this.template = template } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TemplateMessage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .template() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TemplateMessage = + TemplateMessage( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + checkRequired("template", template), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TemplateMessage = apply { + if (validated) { + return@apply + } + + brandId() + channels().ifPresent { it.validate() } + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + delay().ifPresent { it.validate() } + expiry().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + preferences().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + routing().ifPresent { it.validate() } + timeout().ifPresent { it.validate() } + to().ifPresent { it.validate() } + template() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brandId.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (delay.asKnown().getOrNull()?.validity() ?: 0) + + (expiry.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (to.asKnown().getOrNull()?.validity() ?: 0) + + (if (template.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TemplateMessage && + brandId == other.brandId && + channels == other.channels && + context == other.context && + data == other.data && + delay == other.delay && + expiry == other.expiry && + metadata == other.metadata && + preferences == other.preferences && + providers == other.providers && + routing == other.routing && + timeout == other.timeout && + to == other.to && + template == other.template && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + template, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TemplateMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, to=$to, template=$template, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt new file mode 100644 index 00000000..aeee3dbe --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class MessageContext +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tenantId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of() + ) : this(tenantId, mutableMapOf()) + + /** + * An id of a tenant, see [tenants api docs](https://www.courier.com/docs/reference/tenants/). + * Will load brand, default preferences and any other base context data associated with this + * tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tenantId(): Optional = tenantId.getOptional("tenant_id") + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MessageContext]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MessageContext]. */ + class Builder internal constructor() { + + private var tenantId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(messageContext: MessageContext) = apply { + tenantId = messageContext.tenantId + additionalProperties = messageContext.additionalProperties.toMutableMap() + } + + /** + * An id of a tenant, see + * [tenants api docs](https://www.courier.com/docs/reference/tenants/). Will load brand, + * default preferences and any other base context data associated with this tenant. + */ + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MessageContext]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MessageContext = MessageContext(tenantId, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): MessageContext = apply { + if (validated) { + return@apply + } + + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MessageContext && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tenantId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MessageContext{tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt new file mode 100644 index 00000000..80a88a0f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class MsTeamsBaseProperties +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("service_url") @ExcludeMissing fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MsTeamsBaseProperties]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MsTeamsBaseProperties]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(msTeamsBaseProperties: MsTeamsBaseProperties) = apply { + serviceUrl = msTeamsBaseProperties.serviceUrl + tenantId = msTeamsBaseProperties.tenantId + additionalProperties = msTeamsBaseProperties.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { this.serviceUrl = serviceUrl } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MsTeamsBaseProperties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MsTeamsBaseProperties = + MsTeamsBaseProperties( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MsTeamsBaseProperties = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MsTeamsBaseProperties && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(serviceUrl, tenantId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MsTeamsBaseProperties{serviceUrl=$serviceUrl, tenantId=$tenantId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt new file mode 100644 index 00000000..4c0a61b7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt @@ -0,0 +1,7064 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.bulk.UserRecipient +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = Recipient.Deserializer::class) +@JsonSerialize(using = Recipient.Serializer::class) +class Recipient +private constructor( + private val audience: AudienceRecipient? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val user: UserRecipient? = null, + private val slack: SlackRecipient? = null, + private val msTeams: MsTeamsRecipient? = null, + private val data: RecipientData? = null, + private val pagerduty: PagerdutyRecipient? = null, + private val webhook: WebhookRecipient? = null, + private val _json: JsonValue? = null, +) { + + fun audience(): Optional = Optional.ofNullable(audience) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun user(): Optional = Optional.ofNullable(user) + + fun slack(): Optional = Optional.ofNullable(slack) + + fun msTeams(): Optional = Optional.ofNullable(msTeams) + + fun data(): Optional = Optional.ofNullable(data) + + fun pagerduty(): Optional = Optional.ofNullable(pagerduty) + + fun webhook(): Optional = Optional.ofNullable(webhook) + + fun isAudience(): Boolean = audience != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUser(): Boolean = user != null + + fun isSlack(): Boolean = slack != null + + fun isMsTeams(): Boolean = msTeams != null + + fun isData(): Boolean = data != null + + fun isPagerduty(): Boolean = pagerduty != null + + fun isWebhook(): Boolean = webhook != null + + fun asAudience(): AudienceRecipient = audience.getOrThrow("audience") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUser(): UserRecipient = user.getOrThrow("user") + + fun asSlack(): SlackRecipient = slack.getOrThrow("slack") + + fun asMsTeams(): MsTeamsRecipient = msTeams.getOrThrow("msTeams") + + fun asData(): RecipientData = data.getOrThrow("data") + + fun asPagerduty(): PagerdutyRecipient = pagerduty.getOrThrow("pagerduty") + + fun asWebhook(): WebhookRecipient = webhook.getOrThrow("webhook") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + audience != null -> visitor.visitAudience(audience) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + user != null -> visitor.visitUser(user) + slack != null -> visitor.visitSlack(slack) + msTeams != null -> visitor.visitMsTeams(msTeams) + data != null -> visitor.visitData(data) + pagerduty != null -> visitor.visitPagerduty(pagerduty) + webhook != null -> visitor.visitWebhook(webhook) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Recipient = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitAudience(audience: AudienceRecipient) { + audience.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUser(user: UserRecipient) { + user.validate() + } + + override fun visitSlack(slack: SlackRecipient) { + slack.validate() + } + + override fun visitMsTeams(msTeams: MsTeamsRecipient) { + msTeams.validate() + } + + override fun visitData(data: RecipientData) { + data.validate() + } + + override fun visitPagerduty(pagerduty: PagerdutyRecipient) { + pagerduty.validate() + } + + override fun visitWebhook(webhook: WebhookRecipient) { + webhook.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitAudience(audience: AudienceRecipient) = audience.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + + override fun visitUser(user: UserRecipient) = user.validity() + + override fun visitSlack(slack: SlackRecipient) = slack.validity() + + override fun visitMsTeams(msTeams: MsTeamsRecipient) = msTeams.validity() + + override fun visitData(data: RecipientData) = data.validity() + + override fun visitPagerduty(pagerduty: PagerdutyRecipient) = pagerduty.validity() + + override fun visitWebhook(webhook: WebhookRecipient) = webhook.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Recipient && + audience == other.audience && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + user == other.user && + slack == other.slack && + msTeams == other.msTeams && + data == other.data && + pagerduty == other.pagerduty && + webhook == other.webhook + } + + override fun hashCode(): Int = + Objects.hash( + audience, + unionMember1, + unionMember2, + user, + slack, + msTeams, + data, + pagerduty, + webhook, + ) + + override fun toString(): String = + when { + audience != null -> "Recipient{audience=$audience}" + unionMember1 != null -> "Recipient{unionMember1=$unionMember1}" + unionMember2 != null -> "Recipient{unionMember2=$unionMember2}" + user != null -> "Recipient{user=$user}" + slack != null -> "Recipient{slack=$slack}" + msTeams != null -> "Recipient{msTeams=$msTeams}" + data != null -> "Recipient{data=$data}" + pagerduty != null -> "Recipient{pagerduty=$pagerduty}" + webhook != null -> "Recipient{webhook=$webhook}" + _json != null -> "Recipient{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Recipient") + } + + companion object { + + @JvmStatic fun ofAudience(audience: AudienceRecipient) = Recipient(audience = audience) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = Recipient(unionMember1 = unionMember1) + + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = Recipient(unionMember2 = unionMember2) + + @JvmStatic fun ofUser(user: UserRecipient) = Recipient(user = user) + + @JvmStatic fun ofSlack(slack: SlackRecipient) = Recipient(slack = slack) + + @JvmStatic fun ofMsTeams(msTeams: MsTeamsRecipient) = Recipient(msTeams = msTeams) + + @JvmStatic fun ofData(data: RecipientData) = Recipient(data = data) + + @JvmStatic fun ofPagerduty(pagerduty: PagerdutyRecipient) = Recipient(pagerduty = pagerduty) + + @JvmStatic fun ofWebhook(webhook: WebhookRecipient) = Recipient(webhook = webhook) + } + + /** An interface that defines how to map each variant of [Recipient] to a value of type [T]. */ + interface Visitor { + + fun visitAudience(audience: AudienceRecipient): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUser(user: UserRecipient): T + + fun visitSlack(slack: SlackRecipient): T + + fun visitMsTeams(msTeams: MsTeamsRecipient): T + + fun visitData(data: RecipientData): T + + fun visitPagerduty(pagerduty: PagerdutyRecipient): T + + fun visitWebhook(webhook: WebhookRecipient): T + + /** + * Maps an unknown variant of [Recipient] to a value of type [T]. + * + * An instance of [Recipient] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Recipient: $json") + } + } + + internal class Deserializer : BaseDeserializer(Recipient::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Recipient { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(audience = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(user = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(slack = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(msTeams = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(data = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(pagerduty = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Recipient(webhook = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> Recipient(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Recipient::class) { + + override fun serialize( + value: Recipient, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.audience != null -> generator.writeObject(value.audience) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.user != null -> generator.writeObject(value.user) + value.slack != null -> generator.writeObject(value.slack) + value.msTeams != null -> generator.writeObject(value.msTeams) + value.data != null -> generator.writeObject(value.data) + value.pagerduty != null -> generator.writeObject(value.pagerduty) + value.webhook != null -> generator.writeObject(value.webhook) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Recipient") + } + } + } + + class AudienceRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val audienceId: JsonField, + private val data: JsonField, + private val filters: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("audience_id") + @ExcludeMissing + audienceId: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + ) : this(audienceId, data, filters, mutableMapOf()) + + /** + * A unique identifier associated with an Audience. A message will be sent to each user in + * the audience. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun audienceId(): String = audienceId.getRequired("audience_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filters(): Optional> = filters.getOptional("filters") + + /** + * Returns the raw JSON value of [audienceId]. + * + * Unlike [audienceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("audience_id") + @ExcludeMissing + fun _audienceId(): JsonField = audienceId + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AudienceRecipient]. + * + * The following fields are required: + * ```java + * .audienceId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AudienceRecipient]. */ + class Builder internal constructor() { + + private var audienceId: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var filters: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(audienceRecipient: AudienceRecipient) = apply { + audienceId = audienceRecipient.audienceId + data = audienceRecipient.data + filters = audienceRecipient.filters.map { it.toMutableList() } + additionalProperties = audienceRecipient.additionalProperties.toMutableMap() + } + + /** + * A unique identifier associated with an Audience. A message will be sent to each user + * in the audience. + */ + fun audienceId(audienceId: String) = audienceId(JsonField.of(audienceId)) + + /** + * Sets [Builder.audienceId] to an arbitrary JSON value. + * + * You should usually call [Builder.audienceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun audienceId(audienceId: JsonField) = apply { this.audienceId = audienceId } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional>) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AudienceRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .audienceId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AudienceRecipient = + AudienceRecipient( + checkRequired("audienceId", audienceId), + data, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AudienceRecipient = apply { + if (validated) { + return@apply + } + + audienceId() + data().ifPresent { it.validate() } + filters().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (audienceId.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val operator: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(operator, path, value, mutableMapOf()) + + /** + * Send to users only if they are member of the account + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun path(): Path = path.getRequired("path") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + operator = filter.operator + path = filter.path + value = filter.value + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Send to users only if they are member of the account */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun path(path: Path) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [Path] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("operator", operator), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + operator().validate() + path().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (path.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Send to users only if they are member of the account */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MEMBER_OF = of("MEMBER_OF") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + MEMBER_OF + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMBER_OF, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMBER_OF -> Value.MEMBER_OF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MEMBER_OF -> Known.MEMBER_OF + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Path @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACCOUNT_ID = of("account_id") + + @JvmStatic fun of(value: String) = Path(JsonField.of(value)) + } + + /** An enum containing [Path]'s known values. */ + enum class Known { + ACCOUNT_ID + } + + /** + * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Path] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ID, + /** + * An enum member indicating that [Path] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ID -> Value.ACCOUNT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_ID -> Known.ACCOUNT_ID + else -> throw CourierInvalidDataException("Unknown Path: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Path = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Path && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + operator == other.operator && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(operator, path, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AudienceRecipient && + audienceId == other.audienceId && + data == other.data && + filters == other.filters && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(audienceId, data, filters, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AudienceRecipient{audienceId=$audienceId, data=$data, filters=$filters, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val filters: JsonField>, + private val listId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("filters") + @ExcludeMissing + filters: JsonField> = JsonMissing.of(), + @JsonProperty("list_id") @ExcludeMissing listId: JsonField = JsonMissing.of(), + ) : this(data, filters, listId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filters(): Optional> = filters.getOptional("filters") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun listId(): Optional = listId.getOptional("list_id") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [filters]. + * + * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + + /** + * Returns the raw JSON value of [listId]. + * + * Unlike [listId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list_id") @ExcludeMissing fun _listId(): JsonField = listId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var filters: JsonField>? = null + private var listId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + data = unionMember1.data + filters = unionMember1.filters.map { it.toMutableList() } + listId = unionMember1.listId + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + + /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ + fun filters(filters: Optional>) = filters(filters.getOrNull()) + + /** + * Sets [Builder.filters] to an arbitrary JSON value. + * + * You should usually call [Builder.filters] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filters(filters: JsonField>) = apply { + this.filters = filters.map { it.toMutableList() } + } + + /** + * Adds a single [Filter] to [filters]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFilter(filter: Filter) = apply { + filters = + (filters ?: JsonField.of(mutableListOf())).also { + checkKnown("filters", it).add(filter) + } + } + + fun listId(listId: String?) = listId(JsonField.ofNullable(listId)) + + /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ + fun listId(listId: Optional) = listId(listId.getOrNull()) + + /** + * Sets [Builder.listId] to an arbitrary JSON value. + * + * You should usually call [Builder.listId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun listId(listId: JsonField) = apply { this.listId = listId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + data, + (filters ?: JsonMissing.of()).map { it.toImmutable() }, + listId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + filters().ifPresent { it.forEach { it.validate() } } + listId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.validity() ?: 0) + + (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (listId.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Filter + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val operator: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("operator") + @ExcludeMissing + operator: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(operator, path, value, mutableMapOf()) + + /** + * Send to users only if they are member of the account + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun operator(): Operator = operator.getRequired("operator") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun path(): Path = path.getRequired("path") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [operator]. + * + * Unlike [operator], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("operator") + @ExcludeMissing + fun _operator(): JsonField = operator + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Filter]. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Filter]. */ + class Builder internal constructor() { + + private var operator: JsonField? = null + private var path: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(filter: Filter) = apply { + operator = filter.operator + path = filter.path + value = filter.value + additionalProperties = filter.additionalProperties.toMutableMap() + } + + /** Send to users only if they are member of the account */ + fun operator(operator: Operator) = operator(JsonField.of(operator)) + + /** + * Sets [Builder.operator] to an arbitrary JSON value. + * + * You should usually call [Builder.operator] with a well-typed [Operator] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun operator(operator: JsonField) = apply { this.operator = operator } + + fun path(path: Path) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [Path] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun path(path: JsonField) = apply { this.path = path } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Filter]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .operator() + * .path() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Filter = + Filter( + checkRequired("operator", operator), + checkRequired("path", path), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Filter = apply { + if (validated) { + return@apply + } + + operator().validate() + path().validate() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (operator.asKnown().getOrNull()?.validity() ?: 0) + + (path.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Send to users only if they are member of the account */ + class Operator @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val MEMBER_OF = of("MEMBER_OF") + + @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) + } + + /** An enum containing [Operator]'s known values. */ + enum class Known { + MEMBER_OF + } + + /** + * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Operator] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + MEMBER_OF, + /** + * An enum member indicating that [Operator] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + MEMBER_OF -> Value.MEMBER_OF + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + MEMBER_OF -> Known.MEMBER_OF + else -> throw CourierInvalidDataException("Unknown Operator: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Operator = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Operator && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Path @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACCOUNT_ID = of("account_id") + + @JvmStatic fun of(value: String) = Path(JsonField.of(value)) + } + + /** An enum containing [Path]'s known values. */ + enum class Known { + ACCOUNT_ID + } + + /** + * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Path] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCOUNT_ID, + /** + * An enum member indicating that [Path] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCOUNT_ID -> Value.ACCOUNT_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACCOUNT_ID -> Known.ACCOUNT_ID + else -> throw CourierInvalidDataException("Unknown Path: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Path = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Path && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Filter && + operator == other.operator && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(operator, path, value, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + data == other.data && + filters == other.filters && + listId == other.listId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(data, filters, listId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{data=$data, filters=$filters, listId=$listId, additionalProperties=$additionalProperties}" + } + + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val data: JsonField, + private val listPattern: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("list_pattern") + @ExcludeMissing + listPattern: JsonField = JsonMissing.of(), + ) : this(data, listPattern, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun listPattern(): Optional = listPattern.getOptional("list_pattern") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [listPattern]. + * + * Unlike [listPattern], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("list_pattern") + @ExcludeMissing + fun _listPattern(): JsonField = listPattern + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var listPattern: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + data = unionMember2.data + listPattern = unionMember2.listPattern + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun listPattern(listPattern: String?) = listPattern(JsonField.ofNullable(listPattern)) + + /** Alias for calling [Builder.listPattern] with `listPattern.orElse(null)`. */ + fun listPattern(listPattern: Optional) = listPattern(listPattern.getOrNull()) + + /** + * Sets [Builder.listPattern] to an arbitrary JSON value. + * + * You should usually call [Builder.listPattern] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun listPattern(listPattern: JsonField) = apply { + this.listPattern = listPattern + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = + UnionMember2(data, listPattern, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + listPattern() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (listPattern.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + data == other.data && + listPattern == other.listPattern && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, listPattern, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{data=$data, listPattern=$listPattern, additionalProperties=$additionalProperties}" + } + + class SlackRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val slack: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("slack") @ExcludeMissing slack: JsonField = JsonMissing.of() + ) : this(slack, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun slack(): Slack = slack.getRequired("slack") + + /** + * Returns the raw JSON value of [slack]. + * + * Unlike [slack], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("slack") @ExcludeMissing fun _slack(): JsonField = slack + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SlackRecipient]. + * + * The following fields are required: + * ```java + * .slack() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SlackRecipient]. */ + class Builder internal constructor() { + + private var slack: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(slackRecipient: SlackRecipient) = apply { + slack = slackRecipient.slack + additionalProperties = slackRecipient.additionalProperties.toMutableMap() + } + + fun slack(slack: Slack) = slack(JsonField.of(slack)) + + /** + * Sets [Builder.slack] to an arbitrary JSON value. + * + * You should usually call [Builder.slack] with a well-typed [Slack] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun slack(slack: JsonField) = apply { this.slack = slack } + + /** Alias for calling [slack] with `Slack.ofSendToSlackChannel(sendToSlackChannel)`. */ + fun slack(sendToSlackChannel: Slack.SendToSlackChannel) = + slack(Slack.ofSendToSlackChannel(sendToSlackChannel)) + + /** Alias for calling [slack] with `Slack.ofSendToSlackEmail(sendToSlackEmail)`. */ + fun slack(sendToSlackEmail: Slack.SendToSlackEmail) = + slack(Slack.ofSendToSlackEmail(sendToSlackEmail)) + + /** Alias for calling [slack] with `Slack.ofSendToSlackUserId(sendToSlackUserId)`. */ + fun slack(sendToSlackUserId: Slack.SendToSlackUserId) = + slack(Slack.ofSendToSlackUserId(sendToSlackUserId)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SlackRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .slack() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SlackRecipient = + SlackRecipient(checkRequired("slack", slack), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): SlackRecipient = apply { + if (validated) { + return@apply + } + + slack().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (slack.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = Slack.Deserializer::class) + @JsonSerialize(using = Slack.Serializer::class) + class Slack + private constructor( + private val sendToSlackChannel: SendToSlackChannel? = null, + private val sendToSlackEmail: SendToSlackEmail? = null, + private val sendToSlackUserId: SendToSlackUserId? = null, + private val _json: JsonValue? = null, + ) { + + fun sendToSlackChannel(): Optional = + Optional.ofNullable(sendToSlackChannel) + + fun sendToSlackEmail(): Optional = + Optional.ofNullable(sendToSlackEmail) + + fun sendToSlackUserId(): Optional = + Optional.ofNullable(sendToSlackUserId) + + fun isSendToSlackChannel(): Boolean = sendToSlackChannel != null + + fun isSendToSlackEmail(): Boolean = sendToSlackEmail != null + + fun isSendToSlackUserId(): Boolean = sendToSlackUserId != null + + fun asSendToSlackChannel(): SendToSlackChannel = + sendToSlackChannel.getOrThrow("sendToSlackChannel") + + fun asSendToSlackEmail(): SendToSlackEmail = + sendToSlackEmail.getOrThrow("sendToSlackEmail") + + fun asSendToSlackUserId(): SendToSlackUserId = + sendToSlackUserId.getOrThrow("sendToSlackUserId") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + sendToSlackChannel != null -> + visitor.visitSendToSlackChannel(sendToSlackChannel) + sendToSlackEmail != null -> visitor.visitSendToSlackEmail(sendToSlackEmail) + sendToSlackUserId != null -> visitor.visitSendToSlackUserId(sendToSlackUserId) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Slack = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSendToSlackChannel( + sendToSlackChannel: SendToSlackChannel + ) { + sendToSlackChannel.validate() + } + + override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) { + sendToSlackEmail.validate() + } + + override fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) { + sendToSlackUserId.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSendToSlackChannel( + sendToSlackChannel: SendToSlackChannel + ) = sendToSlackChannel.validity() + + override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = + sendToSlackEmail.validity() + + override fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) = + sendToSlackUserId.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Slack && + sendToSlackChannel == other.sendToSlackChannel && + sendToSlackEmail == other.sendToSlackEmail && + sendToSlackUserId == other.sendToSlackUserId + } + + override fun hashCode(): Int = + Objects.hash(sendToSlackChannel, sendToSlackEmail, sendToSlackUserId) + + override fun toString(): String = + when { + sendToSlackChannel != null -> "Slack{sendToSlackChannel=$sendToSlackChannel}" + sendToSlackEmail != null -> "Slack{sendToSlackEmail=$sendToSlackEmail}" + sendToSlackUserId != null -> "Slack{sendToSlackUserId=$sendToSlackUserId}" + _json != null -> "Slack{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Slack") + } + + companion object { + + @JvmStatic + fun ofSendToSlackChannel(sendToSlackChannel: SendToSlackChannel) = + Slack(sendToSlackChannel = sendToSlackChannel) + + @JvmStatic + fun ofSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = + Slack(sendToSlackEmail = sendToSlackEmail) + + @JvmStatic + fun ofSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) = + Slack(sendToSlackUserId = sendToSlackUserId) + } + + /** + * An interface that defines how to map each variant of [Slack] to a value of type [T]. + */ + interface Visitor { + + fun visitSendToSlackChannel(sendToSlackChannel: SendToSlackChannel): T + + fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail): T + + fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId): T + + /** + * Maps an unknown variant of [Slack] to a value of type [T]. + * + * An instance of [Slack] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Slack: $json") + } + } + + internal class Deserializer : BaseDeserializer(Slack::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Slack { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Slack(sendToSlackChannel = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Slack(sendToSlackEmail = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Slack(sendToSlackUserId = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Slack(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Slack::class) { + + override fun serialize( + value: Slack, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.sendToSlackChannel != null -> + generator.writeObject(value.sendToSlackChannel) + value.sendToSlackEmail != null -> + generator.writeObject(value.sendToSlackEmail) + value.sendToSlackUserId != null -> + generator.writeObject(value.sendToSlackUserId) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Slack") + } + } + } + + class SendToSlackChannel + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessToken: JsonField, + private val channel: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + ) : this(accessToken, channel, mutableMapOf()) + + fun toSlackBaseProperties(): SlackBaseProperties = + SlackBaseProperties.builder().accessToken(accessToken).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToSlackChannel]. + * + * The following fields are required: + * ```java + * .accessToken() + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToSlackChannel]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var channel: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToSlackChannel: SendToSlackChannel) = apply { + accessToken = sendToSlackChannel.accessToken + channel = sendToSlackChannel.channel + additionalProperties = + sendToSlackChannel.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessToken(accessToken: JsonField) = apply { + this.accessToken = accessToken + } + + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToSlackChannel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToSlackChannel = + SendToSlackChannel( + checkRequired("accessToken", accessToken), + checkRequired("channel", channel), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToSlackChannel = apply { + if (validated) { + return@apply + } + + accessToken() + channel() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (channel.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToSlackChannel && + accessToken == other.accessToken && + channel == other.channel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, channel, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToSlackChannel{accessToken=$accessToken, channel=$channel, additionalProperties=$additionalProperties}" + } + + class SendToSlackEmail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessToken: JsonField, + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + ) : this(accessToken, email, mutableMapOf()) + + fun toSlackBaseProperties(): SlackBaseProperties = + SlackBaseProperties.builder().accessToken(accessToken).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SendToSlackEmail]. + * + * The following fields are required: + * ```java + * .accessToken() + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToSlackEmail]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var email: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToSlackEmail: SendToSlackEmail) = apply { + accessToken = sendToSlackEmail.accessToken + email = sendToSlackEmail.email + additionalProperties = sendToSlackEmail.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessToken(accessToken: JsonField) = apply { + this.accessToken = accessToken + } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToSlackEmail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToSlackEmail = + SendToSlackEmail( + checkRequired("accessToken", accessToken), + checkRequired("email", email), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToSlackEmail = apply { + if (validated) { + return@apply + } + + accessToken() + email() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToSlackEmail && + accessToken == other.accessToken && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, email, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToSlackEmail{accessToken=$accessToken, email=$email, additionalProperties=$additionalProperties}" + } + + class SendToSlackUserId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accessToken: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + userId: JsonField = JsonMissing.of(), + ) : this(accessToken, userId, mutableMapOf()) + + fun toSlackBaseProperties(): SlackBaseProperties = + SlackBaseProperties.builder().accessToken(accessToken).build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToSlackUserId]. + * + * The following fields are required: + * ```java + * .accessToken() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToSlackUserId]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var userId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToSlackUserId: SendToSlackUserId) = apply { + accessToken = sendToSlackUserId.accessToken + userId = sendToSlackUserId.userId + additionalProperties = sendToSlackUserId.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun accessToken(accessToken: JsonField) = apply { + this.accessToken = accessToken + } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToSlackUserId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToSlackUserId = + SendToSlackUserId( + checkRequired("accessToken", accessToken), + checkRequired("userId", userId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToSlackUserId = apply { + if (validated) { + return@apply + } + + accessToken() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToSlackUserId && + accessToken == other.accessToken && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToSlackUserId{accessToken=$accessToken, userId=$userId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SlackRecipient && + slack == other.slack && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(slack, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SlackRecipient{slack=$slack, additionalProperties=$additionalProperties}" + } + + class MsTeamsRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val msTeams: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ms_teams") @ExcludeMissing msTeams: JsonField = JsonMissing.of() + ) : this(msTeams, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun msTeams(): MsTeams = msTeams.getRequired("ms_teams") + + /** + * Returns the raw JSON value of [msTeams]. + * + * Unlike [msTeams], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ms_teams") @ExcludeMissing fun _msTeams(): JsonField = msTeams + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MsTeamsRecipient]. + * + * The following fields are required: + * ```java + * .msTeams() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MsTeamsRecipient]. */ + class Builder internal constructor() { + + private var msTeams: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(msTeamsRecipient: MsTeamsRecipient) = apply { + msTeams = msTeamsRecipient.msTeams + additionalProperties = msTeamsRecipient.additionalProperties.toMutableMap() + } + + fun msTeams(msTeams: MsTeams) = msTeams(JsonField.of(msTeams)) + + /** + * Sets [Builder.msTeams] to an arbitrary JSON value. + * + * You should usually call [Builder.msTeams] with a well-typed [MsTeams] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun msTeams(msTeams: JsonField) = apply { this.msTeams = msTeams } + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)`. + */ + fun msTeams(sendToMsTeamsUserId: MsTeams.SendToMsTeamsUserId) = + msTeams(MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)) + + /** + * Alias for calling [msTeams] with `MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)`. + */ + fun msTeams(sendToMsTeamsEmail: MsTeams.SendToMsTeamsEmail) = + msTeams(MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)`. + */ + fun msTeams(sendToMsTeamsChannelId: MsTeams.SendToMsTeamsChannelId) = + msTeams(MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)`. + */ + fun msTeams(sendToMsTeamsConversationId: MsTeams.SendToMsTeamsConversationId) = + msTeams(MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)) + + /** + * Alias for calling [msTeams] with + * `MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)`. + */ + fun msTeams(sendToMsTeamsChannelName: MsTeams.SendToMsTeamsChannelName) = + msTeams(MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MsTeamsRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .msTeams() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MsTeamsRecipient = + MsTeamsRecipient( + checkRequired("msTeams", msTeams), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MsTeamsRecipient = apply { + if (validated) { + return@apply + } + + msTeams().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (msTeams.asKnown().getOrNull()?.validity() ?: 0) + + @JsonDeserialize(using = MsTeams.Deserializer::class) + @JsonSerialize(using = MsTeams.Serializer::class) + class MsTeams + private constructor( + private val sendToMsTeamsUserId: SendToMsTeamsUserId? = null, + private val sendToMsTeamsEmail: SendToMsTeamsEmail? = null, + private val sendToMsTeamsChannelId: SendToMsTeamsChannelId? = null, + private val sendToMsTeamsConversationId: SendToMsTeamsConversationId? = null, + private val sendToMsTeamsChannelName: SendToMsTeamsChannelName? = null, + private val _json: JsonValue? = null, + ) { + + fun sendToMsTeamsUserId(): Optional = + Optional.ofNullable(sendToMsTeamsUserId) + + fun sendToMsTeamsEmail(): Optional = + Optional.ofNullable(sendToMsTeamsEmail) + + fun sendToMsTeamsChannelId(): Optional = + Optional.ofNullable(sendToMsTeamsChannelId) + + fun sendToMsTeamsConversationId(): Optional = + Optional.ofNullable(sendToMsTeamsConversationId) + + fun sendToMsTeamsChannelName(): Optional = + Optional.ofNullable(sendToMsTeamsChannelName) + + fun isSendToMsTeamsUserId(): Boolean = sendToMsTeamsUserId != null + + fun isSendToMsTeamsEmail(): Boolean = sendToMsTeamsEmail != null + + fun isSendToMsTeamsChannelId(): Boolean = sendToMsTeamsChannelId != null + + fun isSendToMsTeamsConversationId(): Boolean = sendToMsTeamsConversationId != null + + fun isSendToMsTeamsChannelName(): Boolean = sendToMsTeamsChannelName != null + + fun asSendToMsTeamsUserId(): SendToMsTeamsUserId = + sendToMsTeamsUserId.getOrThrow("sendToMsTeamsUserId") + + fun asSendToMsTeamsEmail(): SendToMsTeamsEmail = + sendToMsTeamsEmail.getOrThrow("sendToMsTeamsEmail") + + fun asSendToMsTeamsChannelId(): SendToMsTeamsChannelId = + sendToMsTeamsChannelId.getOrThrow("sendToMsTeamsChannelId") + + fun asSendToMsTeamsConversationId(): SendToMsTeamsConversationId = + sendToMsTeamsConversationId.getOrThrow("sendToMsTeamsConversationId") + + fun asSendToMsTeamsChannelName(): SendToMsTeamsChannelName = + sendToMsTeamsChannelName.getOrThrow("sendToMsTeamsChannelName") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + sendToMsTeamsUserId != null -> + visitor.visitSendToMsTeamsUserId(sendToMsTeamsUserId) + sendToMsTeamsEmail != null -> + visitor.visitSendToMsTeamsEmail(sendToMsTeamsEmail) + sendToMsTeamsChannelId != null -> + visitor.visitSendToMsTeamsChannelId(sendToMsTeamsChannelId) + sendToMsTeamsConversationId != null -> + visitor.visitSendToMsTeamsConversationId(sendToMsTeamsConversationId) + sendToMsTeamsChannelName != null -> + visitor.visitSendToMsTeamsChannelName(sendToMsTeamsChannelName) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MsTeams = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitSendToMsTeamsUserId( + sendToMsTeamsUserId: SendToMsTeamsUserId + ) { + sendToMsTeamsUserId.validate() + } + + override fun visitSendToMsTeamsEmail( + sendToMsTeamsEmail: SendToMsTeamsEmail + ) { + sendToMsTeamsEmail.validate() + } + + override fun visitSendToMsTeamsChannelId( + sendToMsTeamsChannelId: SendToMsTeamsChannelId + ) { + sendToMsTeamsChannelId.validate() + } + + override fun visitSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) { + sendToMsTeamsConversationId.validate() + } + + override fun visitSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ) { + sendToMsTeamsChannelName.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitSendToMsTeamsUserId( + sendToMsTeamsUserId: SendToMsTeamsUserId + ) = sendToMsTeamsUserId.validity() + + override fun visitSendToMsTeamsEmail( + sendToMsTeamsEmail: SendToMsTeamsEmail + ) = sendToMsTeamsEmail.validity() + + override fun visitSendToMsTeamsChannelId( + sendToMsTeamsChannelId: SendToMsTeamsChannelId + ) = sendToMsTeamsChannelId.validity() + + override fun visitSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) = sendToMsTeamsConversationId.validity() + + override fun visitSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ) = sendToMsTeamsChannelName.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MsTeams && + sendToMsTeamsUserId == other.sendToMsTeamsUserId && + sendToMsTeamsEmail == other.sendToMsTeamsEmail && + sendToMsTeamsChannelId == other.sendToMsTeamsChannelId && + sendToMsTeamsConversationId == other.sendToMsTeamsConversationId && + sendToMsTeamsChannelName == other.sendToMsTeamsChannelName + } + + override fun hashCode(): Int = + Objects.hash( + sendToMsTeamsUserId, + sendToMsTeamsEmail, + sendToMsTeamsChannelId, + sendToMsTeamsConversationId, + sendToMsTeamsChannelName, + ) + + override fun toString(): String = + when { + sendToMsTeamsUserId != null -> + "MsTeams{sendToMsTeamsUserId=$sendToMsTeamsUserId}" + sendToMsTeamsEmail != null -> "MsTeams{sendToMsTeamsEmail=$sendToMsTeamsEmail}" + sendToMsTeamsChannelId != null -> + "MsTeams{sendToMsTeamsChannelId=$sendToMsTeamsChannelId}" + sendToMsTeamsConversationId != null -> + "MsTeams{sendToMsTeamsConversationId=$sendToMsTeamsConversationId}" + sendToMsTeamsChannelName != null -> + "MsTeams{sendToMsTeamsChannelName=$sendToMsTeamsChannelName}" + _json != null -> "MsTeams{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MsTeams") + } + + companion object { + + @JvmStatic + fun ofSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId) = + MsTeams(sendToMsTeamsUserId = sendToMsTeamsUserId) + + @JvmStatic + fun ofSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail) = + MsTeams(sendToMsTeamsEmail = sendToMsTeamsEmail) + + @JvmStatic + fun ofSendToMsTeamsChannelId(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = + MsTeams(sendToMsTeamsChannelId = sendToMsTeamsChannelId) + + @JvmStatic + fun ofSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ) = MsTeams(sendToMsTeamsConversationId = sendToMsTeamsConversationId) + + @JvmStatic + fun ofSendToMsTeamsChannelName(sendToMsTeamsChannelName: SendToMsTeamsChannelName) = + MsTeams(sendToMsTeamsChannelName = sendToMsTeamsChannelName) + } + + /** + * An interface that defines how to map each variant of [MsTeams] to a value of type + * [T]. + */ + interface Visitor { + + fun visitSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId): T + + fun visitSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail): T + + fun visitSendToMsTeamsChannelId(sendToMsTeamsChannelId: SendToMsTeamsChannelId): T + + fun visitSendToMsTeamsConversationId( + sendToMsTeamsConversationId: SendToMsTeamsConversationId + ): T + + fun visitSendToMsTeamsChannelName( + sendToMsTeamsChannelName: SendToMsTeamsChannelName + ): T + + /** + * Maps an unknown variant of [MsTeams] to a value of type [T]. + * + * An instance of [MsTeams] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown MsTeams: $json") + } + } + + internal class Deserializer : BaseDeserializer(MsTeams::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MsTeams { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MsTeams(sendToMsTeamsUserId = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MsTeams(sendToMsTeamsEmail = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { MsTeams(sendToMsTeamsChannelId = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { + MsTeams(sendToMsTeamsConversationId = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { MsTeams(sendToMsTeamsChannelName = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> MsTeams(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MsTeams::class) { + + override fun serialize( + value: MsTeams, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.sendToMsTeamsUserId != null -> + generator.writeObject(value.sendToMsTeamsUserId) + value.sendToMsTeamsEmail != null -> + generator.writeObject(value.sendToMsTeamsEmail) + value.sendToMsTeamsChannelId != null -> + generator.writeObject(value.sendToMsTeamsChannelId) + value.sendToMsTeamsConversationId != null -> + generator.writeObject(value.sendToMsTeamsConversationId) + value.sendToMsTeamsChannelName != null -> + generator.writeObject(value.sendToMsTeamsChannelName) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MsTeams") + } + } + } + + class SendToMsTeamsUserId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + userId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, userId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun userId(): String = userId.getRequired("user_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsUserId]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsUserId]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var userId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsUserId: SendToMsTeamsUserId) = apply { + serviceUrl = sendToMsTeamsUserId.serviceUrl + tenantId = sendToMsTeamsUserId.tenantId + userId = sendToMsTeamsUserId.userId + additionalProperties = + sendToMsTeamsUserId.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsUserId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsUserId = + SendToMsTeamsUserId( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("userId", userId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsUserId = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsUserId && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsUserId{serviceUrl=$serviceUrl, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsEmail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val email: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, email, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsEmail]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .email() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsEmail]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var email: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsEmail: SendToMsTeamsEmail) = apply { + serviceUrl = sendToMsTeamsEmail.serviceUrl + tenantId = sendToMsTeamsEmail.tenantId + email = sendToMsTeamsEmail.email + additionalProperties = + sendToMsTeamsEmail.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsEmail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .email() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsEmail = + SendToMsTeamsEmail( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("email", email), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsEmail = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + email() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsEmail && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + email == other.email && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, email, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsEmail{serviceUrl=$serviceUrl, tenantId=$tenantId, email=$email, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsChannelId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val channelId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("channel_id") + @ExcludeMissing + channelId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, channelId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channelId(): String = channelId.getRequired("channel_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [channelId]. + * + * Unlike [channelId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel_id") + @ExcludeMissing + fun _channelId(): JsonField = channelId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsChannelId]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsChannelId]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var channelId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = apply { + serviceUrl = sendToMsTeamsChannelId.serviceUrl + tenantId = sendToMsTeamsChannelId.tenantId + channelId = sendToMsTeamsChannelId.channelId + additionalProperties = + sendToMsTeamsChannelId.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun channelId(channelId: String) = channelId(JsonField.of(channelId)) + + /** + * Sets [Builder.channelId] to an arbitrary JSON value. + * + * You should usually call [Builder.channelId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun channelId(channelId: JsonField) = apply { + this.channelId = channelId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsChannelId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsChannelId = + SendToMsTeamsChannelId( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("channelId", channelId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsChannelId = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + channelId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (channelId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsChannelId && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + channelId == other.channelId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, channelId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsChannelId{serviceUrl=$serviceUrl, tenantId=$tenantId, channelId=$channelId, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsConversationId + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val conversationId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("conversation_id") + @ExcludeMissing + conversationId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, conversationId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun conversationId(): String = conversationId.getRequired("conversation_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [conversationId]. + * + * Unlike [conversationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("conversation_id") + @ExcludeMissing + fun _conversationId(): JsonField = conversationId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsConversationId]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .conversationId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsConversationId]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var conversationId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsConversationId: SendToMsTeamsConversationId) = + apply { + serviceUrl = sendToMsTeamsConversationId.serviceUrl + tenantId = sendToMsTeamsConversationId.tenantId + conversationId = sendToMsTeamsConversationId.conversationId + additionalProperties = + sendToMsTeamsConversationId.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun conversationId(conversationId: String) = + conversationId(JsonField.of(conversationId)) + + /** + * Sets [Builder.conversationId] to an arbitrary JSON value. + * + * You should usually call [Builder.conversationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun conversationId(conversationId: JsonField) = apply { + this.conversationId = conversationId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsConversationId]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .conversationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsConversationId = + SendToMsTeamsConversationId( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("conversationId", conversationId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsConversationId = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + conversationId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (conversationId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsConversationId && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + conversationId == other.conversationId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, conversationId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsConversationId{serviceUrl=$serviceUrl, tenantId=$tenantId, conversationId=$conversationId, additionalProperties=$additionalProperties}" + } + + class SendToMsTeamsChannelName + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val serviceUrl: JsonField, + private val tenantId: JsonField, + private val channelName: JsonField, + private val teamId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("service_url") + @ExcludeMissing + serviceUrl: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("channel_name") + @ExcludeMissing + channelName: JsonField = JsonMissing.of(), + @JsonProperty("team_id") + @ExcludeMissing + teamId: JsonField = JsonMissing.of(), + ) : this(serviceUrl, tenantId, channelName, teamId, mutableMapOf()) + + fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = + MsTeamsBaseProperties.builder() + .serviceUrl(serviceUrl) + .tenantId(tenantId) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun serviceUrl(): String = serviceUrl.getRequired("service_url") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun channelName(): String = channelName.getRequired("channel_name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun teamId(): String = teamId.getRequired("team_id") + + /** + * Returns the raw JSON value of [serviceUrl]. + * + * Unlike [serviceUrl], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_url") + @ExcludeMissing + fun _serviceUrl(): JsonField = serviceUrl + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [channelName]. + * + * Unlike [channelName], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("channel_name") + @ExcludeMissing + fun _channelName(): JsonField = channelName + + /** + * Returns the raw JSON value of [teamId]. + * + * Unlike [teamId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("team_id") @ExcludeMissing fun _teamId(): JsonField = teamId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [SendToMsTeamsChannelName]. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelName() + * .teamId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendToMsTeamsChannelName]. */ + class Builder internal constructor() { + + private var serviceUrl: JsonField? = null + private var tenantId: JsonField? = null + private var channelName: JsonField? = null + private var teamId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendToMsTeamsChannelName: SendToMsTeamsChannelName) = apply { + serviceUrl = sendToMsTeamsChannelName.serviceUrl + tenantId = sendToMsTeamsChannelName.tenantId + channelName = sendToMsTeamsChannelName.channelName + teamId = sendToMsTeamsChannelName.teamId + additionalProperties = + sendToMsTeamsChannelName.additionalProperties.toMutableMap() + } + + fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) + + /** + * Sets [Builder.serviceUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun serviceUrl(serviceUrl: JsonField) = apply { + this.serviceUrl = serviceUrl + } + + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun channelName(channelName: String) = channelName(JsonField.of(channelName)) + + /** + * Sets [Builder.channelName] to an arbitrary JSON value. + * + * You should usually call [Builder.channelName] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channelName(channelName: JsonField) = apply { + this.channelName = channelName + } + + fun teamId(teamId: String) = teamId(JsonField.of(teamId)) + + /** + * Sets [Builder.teamId] to an arbitrary JSON value. + * + * You should usually call [Builder.teamId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun teamId(teamId: JsonField) = apply { this.teamId = teamId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendToMsTeamsChannelName]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .serviceUrl() + * .tenantId() + * .channelName() + * .teamId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendToMsTeamsChannelName = + SendToMsTeamsChannelName( + checkRequired("serviceUrl", serviceUrl), + checkRequired("tenantId", tenantId), + checkRequired("channelName", channelName), + checkRequired("teamId", teamId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendToMsTeamsChannelName = apply { + if (validated) { + return@apply + } + + serviceUrl() + tenantId() + channelName() + teamId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (serviceUrl.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (channelName.asKnown().isPresent) 1 else 0) + + (if (teamId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendToMsTeamsChannelName && + serviceUrl == other.serviceUrl && + tenantId == other.tenantId && + channelName == other.channelName && + teamId == other.teamId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(serviceUrl, tenantId, channelName, teamId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendToMsTeamsChannelName{serviceUrl=$serviceUrl, tenantId=$tenantId, channelName=$channelName, teamId=$teamId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MsTeamsRecipient && + msTeams == other.msTeams && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(msTeams, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MsTeamsRecipient{msTeams=$msTeams, additionalProperties=$additionalProperties}" + } + + class RecipientData + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [RecipientData]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RecipientData]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(recipientData: RecipientData) = apply { + additionalProperties = recipientData.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [RecipientData]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): RecipientData = RecipientData(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): RecipientData = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RecipientData && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "RecipientData{additionalProperties=$additionalProperties}" + } + + class PagerdutyRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val pagerduty: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("pagerduty") + @ExcludeMissing + pagerduty: JsonField = JsonMissing.of() + ) : this(pagerduty, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pagerduty(): Pagerduty = pagerduty.getRequired("pagerduty") + + /** + * Returns the raw JSON value of [pagerduty]. + * + * Unlike [pagerduty], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pagerduty") + @ExcludeMissing + fun _pagerduty(): JsonField = pagerduty + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PagerdutyRecipient]. + * + * The following fields are required: + * ```java + * .pagerduty() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PagerdutyRecipient]. */ + class Builder internal constructor() { + + private var pagerduty: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pagerdutyRecipient: PagerdutyRecipient) = apply { + pagerduty = pagerdutyRecipient.pagerduty + additionalProperties = pagerdutyRecipient.additionalProperties.toMutableMap() + } + + fun pagerduty(pagerduty: Pagerduty) = pagerduty(JsonField.of(pagerduty)) + + /** + * Sets [Builder.pagerduty] to an arbitrary JSON value. + * + * You should usually call [Builder.pagerduty] with a well-typed [Pagerduty] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pagerduty(pagerduty: JsonField) = apply { this.pagerduty = pagerduty } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PagerdutyRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .pagerduty() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PagerdutyRecipient = + PagerdutyRecipient( + checkRequired("pagerduty", pagerduty), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PagerdutyRecipient = apply { + if (validated) { + return@apply + } + + pagerduty().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (pagerduty.asKnown().getOrNull()?.validity() ?: 0) + + class Pagerduty + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val eventAction: JsonField, + private val routingKey: JsonField, + private val severity: JsonField, + private val source: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event_action") + @ExcludeMissing + eventAction: JsonField = JsonMissing.of(), + @JsonProperty("routing_key") + @ExcludeMissing + routingKey: JsonField = JsonMissing.of(), + @JsonProperty("severity") + @ExcludeMissing + severity: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(eventAction, routingKey, severity, source, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun eventAction(): Optional = eventAction.getOptional("event_action") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun routingKey(): Optional = routingKey.getOptional("routing_key") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun severity(): Optional = severity.getOptional("severity") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [eventAction]. + * + * Unlike [eventAction], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("event_action") + @ExcludeMissing + fun _eventAction(): JsonField = eventAction + + /** + * Returns the raw JSON value of [routingKey]. + * + * Unlike [routingKey], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("routing_key") + @ExcludeMissing + fun _routingKey(): JsonField = routingKey + + /** + * Returns the raw JSON value of [severity]. + * + * Unlike [severity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("severity") @ExcludeMissing fun _severity(): JsonField = severity + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Pagerduty]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Pagerduty]. */ + class Builder internal constructor() { + + private var eventAction: JsonField = JsonMissing.of() + private var routingKey: JsonField = JsonMissing.of() + private var severity: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(pagerduty: Pagerduty) = apply { + eventAction = pagerduty.eventAction + routingKey = pagerduty.routingKey + severity = pagerduty.severity + source = pagerduty.source + additionalProperties = pagerduty.additionalProperties.toMutableMap() + } + + fun eventAction(eventAction: String?) = + eventAction(JsonField.ofNullable(eventAction)) + + /** Alias for calling [Builder.eventAction] with `eventAction.orElse(null)`. */ + fun eventAction(eventAction: Optional) = + eventAction(eventAction.getOrNull()) + + /** + * Sets [Builder.eventAction] to an arbitrary JSON value. + * + * You should usually call [Builder.eventAction] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun eventAction(eventAction: JsonField) = apply { + this.eventAction = eventAction + } + + fun routingKey(routingKey: String?) = routingKey(JsonField.ofNullable(routingKey)) + + /** Alias for calling [Builder.routingKey] with `routingKey.orElse(null)`. */ + fun routingKey(routingKey: Optional) = routingKey(routingKey.getOrNull()) + + /** + * Sets [Builder.routingKey] to an arbitrary JSON value. + * + * You should usually call [Builder.routingKey] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun routingKey(routingKey: JsonField) = apply { + this.routingKey = routingKey + } + + fun severity(severity: String?) = severity(JsonField.ofNullable(severity)) + + /** Alias for calling [Builder.severity] with `severity.orElse(null)`. */ + fun severity(severity: Optional) = severity(severity.getOrNull()) + + /** + * Sets [Builder.severity] to an arbitrary JSON value. + * + * You should usually call [Builder.severity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun severity(severity: JsonField) = apply { this.severity = severity } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Pagerduty]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Pagerduty = + Pagerduty( + eventAction, + routingKey, + severity, + source, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Pagerduty = apply { + if (validated) { + return@apply + } + + eventAction() + routingKey() + severity() + source() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (eventAction.asKnown().isPresent) 1 else 0) + + (if (routingKey.asKnown().isPresent) 1 else 0) + + (if (severity.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Pagerduty && + eventAction == other.eventAction && + routingKey == other.routingKey && + severity == other.severity && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(eventAction, routingKey, severity, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Pagerduty{eventAction=$eventAction, routingKey=$routingKey, severity=$severity, source=$source, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PagerdutyRecipient && + pagerduty == other.pagerduty && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(pagerduty, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PagerdutyRecipient{pagerduty=$pagerduty, additionalProperties=$additionalProperties}" + } + + class WebhookRecipient + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val webhook: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("webhook") @ExcludeMissing webhook: JsonField = JsonMissing.of() + ) : this(webhook, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun webhook(): Webhook = webhook.getRequired("webhook") + + /** + * Returns the raw JSON value of [webhook]. + * + * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook") @ExcludeMissing fun _webhook(): JsonField = webhook + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebhookRecipient]. + * + * The following fields are required: + * ```java + * .webhook() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookRecipient]. */ + class Builder internal constructor() { + + private var webhook: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookRecipient: WebhookRecipient) = apply { + webhook = webhookRecipient.webhook + additionalProperties = webhookRecipient.additionalProperties.toMutableMap() + } + + fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) + + /** + * Sets [Builder.webhook] to an arbitrary JSON value. + * + * You should usually call [Builder.webhook] with a well-typed [Webhook] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhook(webhook: JsonField) = apply { this.webhook = webhook } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [WebhookRecipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .webhook() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebhookRecipient = + WebhookRecipient( + checkRequired("webhook", webhook), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): WebhookRecipient = apply { + if (validated) { + return@apply + } + + webhook().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (webhook.asKnown().getOrNull()?.validity() ?: 0) + + class Webhook + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val url: JsonField, + private val authentication: JsonField, + private val headers: JsonField, + private val method: JsonField, + private val profile: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("authentication") + @ExcludeMissing + authentication: JsonField = JsonMissing.of(), + @JsonProperty("headers") + @ExcludeMissing + headers: JsonField = JsonMissing.of(), + @JsonProperty("method") + @ExcludeMissing + method: JsonField = JsonMissing.of(), + @JsonProperty("profile") + @ExcludeMissing + profile: JsonField = JsonMissing.of(), + ) : this(url, authentication, headers, method, profile, mutableMapOf()) + + /** + * The URL to send the webhook request to. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun url(): String = url.getRequired("url") + + /** + * Authentication configuration for the webhook request. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun authentication(): Optional = + authentication.getOptional("authentication") + + /** + * Custom headers to include in the webhook request. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun headers(): Optional = headers.getOptional("headers") + + /** + * The HTTP method to use for the webhook request. Defaults to POST if not specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun method(): Optional = method.getOptional("method") + + /** + * Specifies what profile information is included in the request payload. Defaults to + * 'limited' if not specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun profile(): Optional = profile.getOptional("profile") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [authentication]. + * + * Unlike [authentication], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("authentication") + @ExcludeMissing + fun _authentication(): JsonField = authentication + + /** + * Returns the raw JSON value of [headers]. + * + * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Webhook]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Webhook]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var authentication: JsonField = JsonMissing.of() + private var headers: JsonField = JsonMissing.of() + private var method: JsonField = JsonMissing.of() + private var profile: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhook: Webhook) = apply { + url = webhook.url + authentication = webhook.authentication + headers = webhook.headers + method = webhook.method + profile = webhook.profile + additionalProperties = webhook.additionalProperties.toMutableMap() + } + + /** The URL to send the webhook request to. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Authentication configuration for the webhook request. */ + fun authentication(authentication: Authentication?) = + authentication(JsonField.ofNullable(authentication)) + + /** + * Alias for calling [Builder.authentication] with `authentication.orElse(null)`. + */ + fun authentication(authentication: Optional) = + authentication(authentication.getOrNull()) + + /** + * Sets [Builder.authentication] to an arbitrary JSON value. + * + * You should usually call [Builder.authentication] with a well-typed + * [Authentication] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun authentication(authentication: JsonField) = apply { + this.authentication = authentication + } + + /** Custom headers to include in the webhook request. */ + fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) + + /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ + fun headers(headers: Optional) = headers(headers.getOrNull()) + + /** + * Sets [Builder.headers] to an arbitrary JSON value. + * + * You should usually call [Builder.headers] with a well-typed [Headers] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun headers(headers: JsonField) = apply { this.headers = headers } + + /** + * The HTTP method to use for the webhook request. Defaults to POST if not + * specified. + */ + fun method(method: Method?) = method(JsonField.ofNullable(method)) + + /** Alias for calling [Builder.method] with `method.orElse(null)`. */ + fun method(method: Optional) = method(method.getOrNull()) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** + * Specifies what profile information is included in the request payload. Defaults + * to 'limited' if not specified. + */ + fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) + + /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ + fun profile(profile: Optional) = profile(profile.getOrNull()) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Webhook]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Webhook = + Webhook( + checkRequired("url", url), + authentication, + headers, + method, + profile, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Webhook = apply { + if (validated) { + return@apply + } + + url() + authentication().ifPresent { it.validate() } + headers().ifPresent { it.validate() } + method().ifPresent { it.validate() } + profile().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (url.asKnown().isPresent) 1 else 0) + + (authentication.asKnown().getOrNull()?.validity() ?: 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + (profile.asKnown().getOrNull()?.validity() ?: 0) + + /** Authentication configuration for the webhook request. */ + class Authentication + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val mode: JsonField, + private val token: JsonField, + private val password: JsonField, + private val username: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("token") + @ExcludeMissing + token: JsonField = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField = JsonMissing.of(), + @JsonProperty("username") + @ExcludeMissing + username: JsonField = JsonMissing.of(), + ) : this(mode, token, password, username, mutableMapOf()) + + /** + * The authentication mode to use. Defaults to 'none' if not specified. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun mode(): Mode = mode.getRequired("mode") + + /** + * Token for bearer authentication. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Password for basic authentication. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun password(): Optional = password.getOptional("password") + + /** + * Username for basic authentication. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun username(): Optional = username.getOptional("username") + + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("password") + @ExcludeMissing + fun _password(): JsonField = password + + /** + * Returns the raw JSON value of [username]. + * + * Unlike [username], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("username") + @ExcludeMissing + fun _username(): JsonField = username + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Authentication]. + * + * The following fields are required: + * ```java + * .mode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Authentication]. */ + class Builder internal constructor() { + + private var mode: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var password: JsonField = JsonMissing.of() + private var username: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authentication: Authentication) = apply { + mode = authentication.mode + token = authentication.token + password = authentication.password + username = authentication.username + additionalProperties = authentication.additionalProperties.toMutableMap() + } + + /** The authentication mode to use. Defaults to 'none' if not specified. */ + fun mode(mode: Mode) = mode(JsonField.of(mode)) + + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [Mode] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + /** Token for bearer authentication. */ + fun token(token: String?) = token(JsonField.ofNullable(token)) + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Password for basic authentication. */ + fun password(password: String?) = password(JsonField.ofNullable(password)) + + /** Alias for calling [Builder.password] with `password.orElse(null)`. */ + fun password(password: Optional) = password(password.getOrNull()) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun password(password: JsonField) = apply { this.password = password } + + /** Username for basic authentication. */ + fun username(username: String?) = username(JsonField.ofNullable(username)) + + /** Alias for calling [Builder.username] with `username.orElse(null)`. */ + fun username(username: Optional) = username(username.getOrNull()) + + /** + * Sets [Builder.username] to an arbitrary JSON value. + * + * You should usually call [Builder.username] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun username(username: JsonField) = apply { this.username = username } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Authentication]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .mode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Authentication = + Authentication( + checkRequired("mode", mode), + token, + password, + username, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Authentication = apply { + if (validated) { + return@apply + } + + mode().validate() + token() + password() + username() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (mode.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (username.asKnown().isPresent) 1 else 0) + + /** The authentication mode to use. Defaults to 'none' if not specified. */ + class Mode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val NONE = of("none") + + @JvmField val BASIC = of("basic") + + @JvmField val BEARER = of("bearer") + + @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) + } + + /** An enum containing [Mode]'s known values. */ + enum class Known { + NONE, + BASIC, + BEARER, + } + + /** + * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Mode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NONE, + BASIC, + BEARER, + /** + * An enum member indicating that [Mode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NONE -> Value.NONE + BASIC -> Value.BASIC + BEARER -> Value.BEARER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NONE -> Known.NONE + BASIC -> Known.BASIC + BEARER -> Known.BEARER + else -> throw CourierInvalidDataException("Unknown Mode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Mode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Mode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Authentication && + mode == other.mode && + token == other.token && + password == other.password && + username == other.username && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(mode, token, password, username, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Authentication{mode=$mode, token=$token, password=$password, username=$username, additionalProperties=$additionalProperties}" + } + + /** Custom headers to include in the webhook request. */ + class Headers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Headers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Headers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(headers: Headers) = apply { + additionalProperties = headers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Headers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Headers = Headers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Headers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Headers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Headers{additionalProperties=$additionalProperties}" + } + + /** + * The HTTP method to use for the webhook request. Defaults to POST if not specified. + */ + class Method @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val POST = of("POST") + + @JvmField val PUT = of("PUT") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + POST, + PUT, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + POST, + PUT, + /** + * An enum member indicating that [Method] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + POST -> Value.POST + PUT -> Value.PUT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + POST -> Known.POST + PUT -> Known.PUT + else -> throw CourierInvalidDataException("Unknown Method: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Method && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Specifies what profile information is included in the request payload. Defaults to + * 'limited' if not specified. + */ + class Profile @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIMITED = of("limited") + + @JvmField val EXPANDED = of("expanded") + + @JvmStatic fun of(value: String) = Profile(JsonField.of(value)) + } + + /** An enum containing [Profile]'s known values. */ + enum class Known { + LIMITED, + EXPANDED, + } + + /** + * An enum containing [Profile]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Profile] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIMITED, + EXPANDED, + /** + * An enum member indicating that [Profile] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIMITED -> Value.LIMITED + EXPANDED -> Value.EXPANDED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + LIMITED -> Known.LIMITED + EXPANDED -> Known.EXPANDED + else -> throw CourierInvalidDataException("Unknown Profile: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Webhook && + url == other.url && + authentication == other.authentication && + headers == other.headers && + method == other.method && + profile == other.profile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(url, authentication, headers, method, profile, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Webhook{url=$url, authentication=$authentication, headers=$headers, method=$method, profile=$profile, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebhookRecipient && + webhook == other.webhook && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(webhook, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookRecipient{webhook=$webhook, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt new file mode 100644 index 00000000..3ac4d508 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.Enum +import com.courier.api.core.JsonField +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +class RoutingMethod @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ALL = of("all") + + @JvmField val SINGLE = of("single") + + @JvmStatic fun of(value: String) = RoutingMethod(JsonField.of(value)) + } + + /** An enum containing [RoutingMethod]'s known values. */ + enum class Known { + ALL, + SINGLE, + } + + /** + * An enum containing [RoutingMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [RoutingMethod] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + SINGLE, + /** + * An enum member indicating that [RoutingMethod] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + SINGLE -> Value.SINGLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + SINGLE -> Known.SINGLE + else -> throw CourierInvalidDataException("Unknown RoutingMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): RoutingMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RoutingMethod && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt new file mode 100644 index 00000000..dde35b57 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt @@ -0,0 +1,429 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +/** Use the send API to send a message to one or more recipients. */ +class SendSendMessageParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Defines the message to be delivered + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = body.message() + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _message(): JsonField = body._message() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SendSendMessageParams]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendSendMessageParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sendSendMessageParams: SendSendMessageParams) = apply { + body = sendSendMessageParams.body.toBuilder() + additionalHeaders = sendSendMessageParams.additionalHeaders.toBuilder() + additionalQueryParams = sendSendMessageParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [message] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Defines the message to be delivered */ + fun message(message: Message) = apply { body.message(message) } + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { body.message(message) } + + /** Alias for calling [message] with `Message.ofContent(content)`. */ + fun message(content: Message.ContentMessage) = apply { body.message(content) } + + /** Alias for calling [message] with `Message.ofTemplate(template)`. */ + fun message(template: Message.TemplateMessage) = apply { body.message(template) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SendSendMessageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendSendMessageParams = + SendSendMessageParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val message: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of() + ) : this(message, mutableMapOf()) + + /** + * Defines the message to be delivered + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + message = body.message + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Defines the message to be delivered */ + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + /** Alias for calling [message] with `Message.ofContent(content)`. */ + fun message(content: Message.ContentMessage) = message(Message.ofContent(content)) + + /** Alias for calling [message] with `Message.ofTemplate(template)`. */ + fun message(template: Message.TemplateMessage) = message(Message.ofTemplate(template)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("message", message), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + message().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (message.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{message=$message, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendSendMessageParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SendSendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt new file mode 100644 index 00000000..1a094b8c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class SendSendMessageResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val requestId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("requestId") @ExcludeMissing requestId: JsonField = JsonMissing.of() + ) : this(requestId, mutableMapOf()) + + /** + * A successful call to `POST /send` returns a `202` status code along with a `requestId` in the + * response body. + * + * For send requests that have a single recipient, the `requestId` is assigned to the derived + * message as its message_id. Therefore the `requestId` can be supplied to the Message's API for + * single recipient messages. + * + * For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier + * assigns a unique id to each derived message as its `message_id`. Therefore the `requestId` + * cannot be supplied to the Message's API for single-recipient messages. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun requestId(): String = requestId.getRequired("requestId") + + /** + * Returns the raw JSON value of [requestId]. + * + * Unlike [requestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("requestId") @ExcludeMissing fun _requestId(): JsonField = requestId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SendSendMessageResponse]. + * + * The following fields are required: + * ```java + * .requestId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendSendMessageResponse]. */ + class Builder internal constructor() { + + private var requestId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(sendSendMessageResponse: SendSendMessageResponse) = apply { + requestId = sendSendMessageResponse.requestId + additionalProperties = sendSendMessageResponse.additionalProperties.toMutableMap() + } + + /** + * A successful call to `POST /send` returns a `202` status code along with a `requestId` in + * the response body. + * + * For send requests that have a single recipient, the `requestId` is assigned to the + * derived message as its message_id. Therefore the `requestId` can be supplied to the + * Message's API for single recipient messages. + * + * For send requests that have multiple recipients (accounts, audiences, lists, etc.), + * Courier assigns a unique id to each derived message as its `message_id`. Therefore the + * `requestId` cannot be supplied to the Message's API for single-recipient messages. + */ + fun requestId(requestId: String) = requestId(JsonField.of(requestId)) + + /** + * Sets [Builder.requestId] to an arbitrary JSON value. + * + * You should usually call [Builder.requestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun requestId(requestId: JsonField) = apply { this.requestId = requestId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SendSendMessageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .requestId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendSendMessageResponse = + SendSendMessageResponse( + checkRequired("requestId", requestId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SendSendMessageResponse = apply { + if (validated) { + return@apply + } + + requestId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (requestId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendSendMessageResponse && + requestId == other.requestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(requestId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SendSendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt new file mode 100644 index 00000000..4eb4bddc --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class SlackBaseProperties +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accessToken: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of() + ) : this(accessToken, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun accessToken(): String = accessToken.getRequired("access_token") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SlackBaseProperties]. + * + * The following fields are required: + * ```java + * .accessToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SlackBaseProperties]. */ + class Builder internal constructor() { + + private var accessToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(slackBaseProperties: SlackBaseProperties) = apply { + accessToken = slackBaseProperties.accessToken + additionalProperties = slackBaseProperties.additionalProperties.toMutableMap() + } + + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SlackBaseProperties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .accessToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SlackBaseProperties = + SlackBaseProperties( + checkRequired("accessToken", accessToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SlackBaseProperties = apply { + if (validated) { + return@apply + } + + accessToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (accessToken.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SlackBaseProperties && + accessToken == other.accessToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(accessToken, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SlackBaseProperties{accessToken=$accessToken, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt new file mode 100644 index 00000000..8504b223 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Utm +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val campaign: JsonField, + private val content: JsonField, + private val medium: JsonField, + private val source: JsonField, + private val term: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("campaign") @ExcludeMissing campaign: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("medium") @ExcludeMissing medium: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), + ) : this(campaign, content, medium, source, term, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun campaign(): Optional = campaign.getOptional("campaign") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun medium(): Optional = medium.getOptional("medium") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun term(): Optional = term.getOptional("term") + + /** + * Returns the raw JSON value of [campaign]. + * + * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [medium]. + * + * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [term]. + * + * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Utm]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Utm]. */ + class Builder internal constructor() { + + private var campaign: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var medium: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var term: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(utm: Utm) = apply { + campaign = utm.campaign + content = utm.content + medium = utm.medium + source = utm.source + term = utm.term + additionalProperties = utm.additionalProperties.toMutableMap() + } + + fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) + + /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ + fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) + + /** + * Sets [Builder.campaign] to an arbitrary JSON value. + * + * You should usually call [Builder.campaign] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun campaign(campaign: JsonField) = apply { this.campaign = campaign } + + fun content(content: String?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) + + /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ + fun medium(medium: Optional) = medium(medium.getOrNull()) + + /** + * Sets [Builder.medium] to an arbitrary JSON value. + * + * You should usually call [Builder.medium] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun medium(medium: JsonField) = apply { this.medium = medium } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun term(term: String?) = term(JsonField.ofNullable(term)) + + /** Alias for calling [Builder.term] with `term.orElse(null)`. */ + fun term(term: Optional) = term(term.getOrNull()) + + /** + * Sets [Builder.term] to an arbitrary JSON value. + * + * You should usually call [Builder.term] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun term(term: JsonField) = apply { this.term = term } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Utm]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Utm = + Utm(campaign, content, medium, source, term, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Utm = apply { + if (validated) { + return@apply + } + + campaign() + content() + medium() + source() + term() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (campaign.asKnown().isPresent) 1 else 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (if (medium.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (term.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Utm && + campaign == other.campaign && + content == other.content && + medium == other.medium && + source == other.source && + term == other.term && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(campaign, content, medium, source, term, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt new file mode 100644 index 00000000..7de80040 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt @@ -0,0 +1,512 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class DefaultPreferences +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + ) : this(items, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("items") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [DefaultPreferences]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DefaultPreferences]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(defaultPreferences: DefaultPreferences) = apply { + items = defaultPreferences.items.map { it.toMutableList() } + additionalProperties = defaultPreferences.additionalProperties.toMutableMap() + } + + fun items(items: List?) = items(JsonField.ofNullable(items)) + + /** Alias for calling [Builder.items] with `items.orElse(null)`. */ + fun items(items: Optional>) = items(items.getOrNull()) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DefaultPreferences]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DefaultPreferences = + DefaultPreferences( + (items ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DefaultPreferences = apply { + if (validated) { + return@apply + } + + items().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val customRouting: JsonField>, + private val hasCustomRouting: JsonField, + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("custom_routing") + @ExcludeMissing + customRouting: JsonField> = JsonMissing.of(), + @JsonProperty("has_custom_routing") + @ExcludeMissing + hasCustomRouting: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + ) : this(status, customRouting, hasCustomRouting, id, mutableMapOf()) + + fun toSubscriptionTopicNew(): SubscriptionTopicNew = + SubscriptionTopicNew.builder() + .status(status) + .customRouting(customRouting) + .hasCustomRouting(hasCustomRouting) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): SubscriptionTopicNew.Status = status.getRequired("status") + + /** + * The default channels to send to this tenant when has_custom_routing is enabled + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customRouting(): Optional> = + customRouting.getOptional("custom_routing") + + /** + * Override channel routing with custom preferences. This will override any template + * prefernces that are set, but a user can still customize their preferences + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasCustomRouting(): Optional = + hasCustomRouting.getOptional("has_custom_routing") + + /** + * Topic ID + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [customRouting]. + * + * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_routing") + @ExcludeMissing + fun _customRouting(): JsonField> = customRouting + + /** + * Returns the raw JSON value of [hasCustomRouting]. + * + * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("has_custom_routing") + @ExcludeMissing + fun _hasCustomRouting(): JsonField = hasCustomRouting + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .status() + * .id() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var customRouting: JsonField>? = null + private var hasCustomRouting: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + status = item.status + customRouting = item.customRouting.map { it.toMutableList() } + hasCustomRouting = item.hasCustomRouting + id = item.id + additionalProperties = item.additionalProperties.toMutableMap() + } + + fun status(status: SubscriptionTopicNew.Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed + * [SubscriptionTopicNew.Status] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { + this.status = status + } + + /** The default channels to send to this tenant when has_custom_routing is enabled */ + fun customRouting(customRouting: List?) = + customRouting(JsonField.ofNullable(customRouting)) + + /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ + fun customRouting(customRouting: Optional>) = + customRouting(customRouting.getOrNull()) + + /** + * Sets [Builder.customRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.customRouting] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customRouting(customRouting: JsonField>) = apply { + this.customRouting = customRouting.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelClassification] to [Builder.customRouting]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomRouting(customRouting: ChannelClassification) = apply { + this.customRouting = + (this.customRouting ?: JsonField.of(mutableListOf())).also { + checkKnown("customRouting", it).add(customRouting) + } + } + + /** + * Override channel routing with custom preferences. This will override any template + * prefernces that are set, but a user can still customize their preferences + */ + fun hasCustomRouting(hasCustomRouting: Boolean?) = + hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) + + /** + * Alias for [Builder.hasCustomRouting]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasCustomRouting(hasCustomRouting: Boolean) = + hasCustomRouting(hasCustomRouting as Boolean?) + + /** + * Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. + */ + fun hasCustomRouting(hasCustomRouting: Optional) = + hasCustomRouting(hasCustomRouting.getOrNull()) + + /** + * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasCustomRouting(hasCustomRouting: JsonField) = apply { + this.hasCustomRouting = hasCustomRouting + } + + /** Topic ID */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("status", status), + (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, + hasCustomRouting, + checkRequired("id", id), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + status().validate() + customRouting().ifPresent { it.forEach { it.validate() } } + hasCustomRouting() + id() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + status == other.status && + customRouting == other.customRouting && + hasCustomRouting == other.hasCustomRouting && + id == other.id && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(status, customRouting, hasCustomRouting, id, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{status=$status, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, id=$id, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DefaultPreferences && + items == other.items && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DefaultPreferences{items=$items, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt new file mode 100644 index 00000000..0b5f3a3b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt @@ -0,0 +1,655 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Tenant +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val brandId: JsonField, + private val defaultPreferences: JsonField, + private val parentTenantId: JsonField, + private val properties: JsonField, + private val userProfile: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), + @JsonProperty("default_preferences") + @ExcludeMissing + defaultPreferences: JsonField = JsonMissing.of(), + @JsonProperty("parent_tenant_id") + @ExcludeMissing + parentTenantId: JsonField = JsonMissing.of(), + @JsonProperty("properties") + @ExcludeMissing + properties: JsonField = JsonMissing.of(), + @JsonProperty("user_profile") + @ExcludeMissing + userProfile: JsonField = JsonMissing.of(), + ) : this( + id, + name, + brandId, + defaultPreferences, + parentTenantId, + properties, + userProfile, + mutableMapOf(), + ) + + /** + * Id of the tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * Name of the tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Brand to be used for the account when one is not specified by the send call. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * Defines the preferences used for the account when the user hasn't specified their own. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultPreferences(): Optional = + defaultPreferences.getOptional("default_preferences") + + /** + * Tenant's parent id (if any). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parentTenantId(): Optional = parentTenantId.getOptional("parent_tenant_id") + + /** + * Arbitrary properties accessible to a template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun properties(): Optional = properties.getOptional("properties") + + /** + * A user profile object merged with user profile on send. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userProfile(): Optional = userProfile.getOptional("user_profile") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [defaultPreferences]. + * + * Unlike [defaultPreferences], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("default_preferences") + @ExcludeMissing + fun _defaultPreferences(): JsonField = defaultPreferences + + /** + * Returns the raw JSON value of [parentTenantId]. + * + * Unlike [parentTenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parent_tenant_id") + @ExcludeMissing + fun _parentTenantId(): JsonField = parentTenantId + + /** + * Returns the raw JSON value of [properties]. + * + * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("properties") + @ExcludeMissing + fun _properties(): JsonField = properties + + /** + * Returns the raw JSON value of [userProfile]. + * + * Unlike [userProfile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_profile") + @ExcludeMissing + fun _userProfile(): JsonField = userProfile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tenant]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tenant]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var brandId: JsonField = JsonMissing.of() + private var defaultPreferences: JsonField = JsonMissing.of() + private var parentTenantId: JsonField = JsonMissing.of() + private var properties: JsonField = JsonMissing.of() + private var userProfile: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenant: Tenant) = apply { + id = tenant.id + name = tenant.name + brandId = tenant.brandId + defaultPreferences = tenant.defaultPreferences + parentTenantId = tenant.parentTenantId + properties = tenant.properties + userProfile = tenant.userProfile + additionalProperties = tenant.additionalProperties.toMutableMap() + } + + /** Id of the tenant. */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** Name of the tenant. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Brand to be used for the account when one is not specified by the send call. */ + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * Defines the preferences used for the account when the user hasn't specified their own. + */ + fun defaultPreferences(defaultPreferences: DefaultPreferences?) = + defaultPreferences(JsonField.ofNullable(defaultPreferences)) + + /** + * Alias for calling [Builder.defaultPreferences] with `defaultPreferences.orElse(null)`. + */ + fun defaultPreferences(defaultPreferences: Optional) = + defaultPreferences(defaultPreferences.getOrNull()) + + /** + * Sets [Builder.defaultPreferences] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultPreferences] with a well-typed + * [DefaultPreferences] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultPreferences(defaultPreferences: JsonField) = apply { + this.defaultPreferences = defaultPreferences + } + + /** Tenant's parent id (if any). */ + fun parentTenantId(parentTenantId: String?) = + parentTenantId(JsonField.ofNullable(parentTenantId)) + + /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ + fun parentTenantId(parentTenantId: Optional) = + parentTenantId(parentTenantId.getOrNull()) + + /** + * Sets [Builder.parentTenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentTenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentTenantId(parentTenantId: JsonField) = apply { + this.parentTenantId = parentTenantId + } + + /** Arbitrary properties accessible to a template. */ + fun properties(properties: Properties?) = properties(JsonField.ofNullable(properties)) + + /** Alias for calling [Builder.properties] with `properties.orElse(null)`. */ + fun properties(properties: Optional) = properties(properties.getOrNull()) + + /** + * Sets [Builder.properties] to an arbitrary JSON value. + * + * You should usually call [Builder.properties] with a well-typed [Properties] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun properties(properties: JsonField) = apply { this.properties = properties } + + /** A user profile object merged with user profile on send. */ + fun userProfile(userProfile: UserProfile?) = userProfile(JsonField.ofNullable(userProfile)) + + /** Alias for calling [Builder.userProfile] with `userProfile.orElse(null)`. */ + fun userProfile(userProfile: Optional) = userProfile(userProfile.getOrNull()) + + /** + * Sets [Builder.userProfile] to an arbitrary JSON value. + * + * You should usually call [Builder.userProfile] with a well-typed [UserProfile] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userProfile(userProfile: JsonField) = apply { + this.userProfile = userProfile + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tenant]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tenant = + Tenant( + checkRequired("id", id), + checkRequired("name", name), + brandId, + defaultPreferences, + parentTenantId, + properties, + userProfile, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tenant = apply { + if (validated) { + return@apply + } + + id() + name() + brandId() + defaultPreferences().ifPresent { it.validate() } + parentTenantId() + properties().ifPresent { it.validate() } + userProfile().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (brandId.asKnown().isPresent) 1 else 0) + + (defaultPreferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (parentTenantId.asKnown().isPresent) 1 else 0) + + (properties.asKnown().getOrNull()?.validity() ?: 0) + + (userProfile.asKnown().getOrNull()?.validity() ?: 0) + + /** Arbitrary properties accessible to a template. */ + class Properties + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Properties]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Properties]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(properties: Properties) = apply { + additionalProperties = properties.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Properties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Properties = Properties(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Properties = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Properties && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Properties{additionalProperties=$additionalProperties}" + } + + /** A user profile object merged with user profile on send. */ + class UserProfile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UserProfile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserProfile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userProfile: UserProfile) = apply { + additionalProperties = userProfile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserProfile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserProfile = UserProfile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UserProfile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserProfile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UserProfile{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tenant && + id == other.id && + name == other.name && + brandId == other.brandId && + defaultPreferences == other.defaultPreferences && + parentTenantId == other.parentTenantId && + properties == other.properties && + userProfile == other.userProfile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + brandId, + defaultPreferences, + parentTenantId, + properties, + userProfile, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tenant{id=$id, name=$name, brandId=$brandId, defaultPreferences=$defaultPreferences, parentTenantId=$parentTenantId, properties=$properties, userProfile=$userProfile, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt new file mode 100644 index 00000000..01fe752f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete a Tenant */ +class TenantDeleteParams +private constructor( + private val tenantId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantDeleteParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantDeleteParams: TenantDeleteParams) = apply { + tenantId = tenantDeleteParams.tenantId + additionalHeaders = tenantDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = tenantDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TenantDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantDeleteParams = + TenantDeleteParams( + tenantId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantDeleteParams && + tenantId == other.tenantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(tenantId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "TenantDeleteParams{tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt new file mode 100644 index 00000000..ef1b6f01 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt @@ -0,0 +1,234 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a List of Tenants */ +class TenantListParams +private constructor( + private val cursor: String?, + private val limit: Long?, + private val parentTenantId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Continue the pagination with the next cursor */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The number of tenants to return (defaults to 20, maximum value of 100) */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Filter the list of tenants by parent_id */ + fun parentTenantId(): Optional = Optional.ofNullable(parentTenantId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListParams]. */ + class Builder internal constructor() { + + private var cursor: String? = null + private var limit: Long? = null + private var parentTenantId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantListParams: TenantListParams) = apply { + cursor = tenantListParams.cursor + limit = tenantListParams.limit + parentTenantId = tenantListParams.parentTenantId + additionalHeaders = tenantListParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantListParams.additionalQueryParams.toBuilder() + } + + /** Continue the pagination with the next cursor */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The number of tenants to return (defaults to 20, maximum value of 100) */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + /** Filter the list of tenants by parent_id */ + fun parentTenantId(parentTenantId: String?) = apply { this.parentTenantId = parentTenantId } + + /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ + fun parentTenantId(parentTenantId: Optional) = + parentTenantId(parentTenantId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantListParams = + TenantListParams( + cursor, + limit, + parentTenantId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + parentTenantId?.let { put("parent_tenant_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListParams && + cursor == other.cursor && + limit == other.limit && + parentTenantId == other.parentTenantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cursor, limit, parentTenantId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantListParams{cursor=$cursor, limit=$limit, parentTenantId=$parentTenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt new file mode 100644 index 00000000..3e8c7532 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt @@ -0,0 +1,501 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TenantListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasMore: JsonField, + private val items: JsonField>, + private val type: JsonField, + private val url: JsonField, + private val cursor: JsonField, + private val nextUrl: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), + ) : this(hasMore, items, type, url, cursor, nextUrl, mutableMapOf()) + + /** + * Set to true when there are more pages that can be retrieved. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + /** + * An array of Tenants + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * Always set to "list". Represents the type of this object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A url that may be used to generate these results. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * A pointer to the next page of results. Defined only when has_more is set to true. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * A url that may be used to generate fetch the next set of results. Defined only when has_more + * is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextUrl(): Optional = nextUrl.getOptional("next_url") + + /** + * Returns the raw JSON value of [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [nextUrl]. + * + * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantListResponse]. + * + * The following fields are required: + * ```java + * .hasMore() + * .items() + * .type() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListResponse]. */ + class Builder internal constructor() { + + private var hasMore: JsonField? = null + private var items: JsonField>? = null + private var type: JsonField? = null + private var url: JsonField? = null + private var cursor: JsonField = JsonMissing.of() + private var nextUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantListResponse: TenantListResponse) = apply { + hasMore = tenantListResponse.hasMore + items = tenantListResponse.items.map { it.toMutableList() } + type = tenantListResponse.type + url = tenantListResponse.url + cursor = tenantListResponse.cursor + nextUrl = tenantListResponse.nextUrl + additionalProperties = tenantListResponse.additionalProperties.toMutableMap() + } + + /** Set to true when there are more pages that can be retrieved. */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + /** An array of Tenants */ + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Tenant] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Tenant) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** Always set to "list". Represents the type of this object. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A url that may be used to generate these results. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** A pointer to the next page of results. Defined only when has_more is set to true. */ + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * has_more is set to true + */ + fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) + + /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ + fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) + + /** + * Sets [Builder.nextUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TenantListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasMore() + * .items() + * .type() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantListResponse = + TenantListResponse( + checkRequired("hasMore", hasMore), + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("type", type), + checkRequired("url", url), + cursor, + nextUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TenantListResponse = apply { + if (validated) { + return@apply + } + + hasMore() + items().forEach { it.validate() } + type().validate() + url() + cursor() + nextUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (hasMore.asKnown().isPresent) 1 else 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (if (nextUrl.asKnown().isPresent) 1 else 0) + + /** Always set to "list". Represents the type of this object. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST = of("list") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + LIST + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST -> Value.LIST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIST -> Known.LIST + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListResponse && + hasMore == other.hasMore && + items == other.items && + type == other.type && + url == other.url && + cursor == other.cursor && + nextUrl == other.nextUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasMore, items, type, url, cursor, nextUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TenantListResponse{hasMore=$hasMore, items=$items, type=$type, url=$url, cursor=$cursor, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt new file mode 100644 index 00000000..2f7aa8aa --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get Users in Tenant */ +class TenantListUsersParams +private constructor( + private val tenantId: String?, + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Continue the pagination with the next cursor */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The number of accounts to return (defaults to 20, maximum value of 100) */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantListUsersParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantListUsersParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListUsersParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantListUsersParams: TenantListUsersParams) = apply { + tenantId = tenantListUsersParams.tenantId + cursor = tenantListUsersParams.cursor + limit = tenantListUsersParams.limit + additionalHeaders = tenantListUsersParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantListUsersParams.additionalQueryParams.toBuilder() + } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** Continue the pagination with the next cursor */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The number of accounts to return (defaults to 20, maximum value of 100) */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantListUsersParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantListUsersParams = + TenantListUsersParams( + tenantId, + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListUsersParams && + tenantId == other.tenantId && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tenantId, cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantListUsersParams{tenantId=$tenantId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt new file mode 100644 index 00000000..124df60a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt @@ -0,0 +1,502 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.users.tenants.TenantAssociation +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TenantListUsersResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasMore: JsonField, + private val type: JsonField, + private val url: JsonField, + private val cursor: JsonField, + private val items: JsonField>, + private val nextUrl: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of(), + @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), + ) : this(hasMore, type, url, cursor, items, nextUrl, mutableMapOf()) + + /** + * Set to true when there are more pages that can be retrieved. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + /** + * Always set to `list`. Represents the type of this object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A url that may be used to generate these results. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * A pointer to the next page of results. Defined only when `has_more` is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("items") + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * `has_more` is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextUrl(): Optional = nextUrl.getOptional("next_url") + + /** + * Returns the raw JSON value of [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [nextUrl]. + * + * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantListUsersResponse]. + * + * The following fields are required: + * ```java + * .hasMore() + * .type() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListUsersResponse]. */ + class Builder internal constructor() { + + private var hasMore: JsonField? = null + private var type: JsonField? = null + private var url: JsonField? = null + private var cursor: JsonField = JsonMissing.of() + private var items: JsonField>? = null + private var nextUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantListUsersResponse: TenantListUsersResponse) = apply { + hasMore = tenantListUsersResponse.hasMore + type = tenantListUsersResponse.type + url = tenantListUsersResponse.url + cursor = tenantListUsersResponse.cursor + items = tenantListUsersResponse.items.map { it.toMutableList() } + nextUrl = tenantListUsersResponse.nextUrl + additionalProperties = tenantListUsersResponse.additionalProperties.toMutableMap() + } + + /** Set to true when there are more pages that can be retrieved. */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + /** Always set to `list`. Represents the type of this object. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A url that may be used to generate these results. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** A pointer to the next page of results. Defined only when `has_more` is set to true */ + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun items(items: List?) = items(JsonField.ofNullable(items)) + + /** Alias for calling [Builder.items] with `items.orElse(null)`. */ + fun items(items: Optional>) = items(items.getOrNull()) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [TenantAssociation] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: TenantAssociation) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * `has_more` is set to true + */ + fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) + + /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ + fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) + + /** + * Sets [Builder.nextUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TenantListUsersResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasMore() + * .type() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantListUsersResponse = + TenantListUsersResponse( + checkRequired("hasMore", hasMore), + checkRequired("type", type), + checkRequired("url", url), + cursor, + (items ?: JsonMissing.of()).map { it.toImmutable() }, + nextUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TenantListUsersResponse = apply { + if (validated) { + return@apply + } + + hasMore() + type().validate() + url() + cursor() + items().ifPresent { it.forEach { it.validate() } } + nextUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (hasMore.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextUrl.asKnown().isPresent) 1 else 0) + + /** Always set to `list`. Represents the type of this object. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST = of("list") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + LIST + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST -> Value.LIST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIST -> Known.LIST + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListUsersResponse && + hasMore == other.hasMore && + type == other.type && + url == other.url && + cursor == other.cursor && + items == other.items && + nextUrl == other.nextUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasMore, type, url, cursor, items, nextUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TenantListUsersResponse{hasMore=$hasMore, type=$type, url=$url, cursor=$cursor, items=$items, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt new file mode 100644 index 00000000..700f1525 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a Tenant */ +class TenantRetrieveParams +private constructor( + private val tenantId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantRetrieveParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantRetrieveParams: TenantRetrieveParams) = apply { + tenantId = tenantRetrieveParams.tenantId + additionalHeaders = tenantRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantRetrieveParams.additionalQueryParams.toBuilder() + } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantRetrieveParams = + TenantRetrieveParams(tenantId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantRetrieveParams && + tenantId == other.tenantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(tenantId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantRetrieveParams{tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt new file mode 100644 index 00000000..43eef9c4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt @@ -0,0 +1,1055 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create or Replace a Tenant */ +class TenantUpdateParams +private constructor( + private val tenantId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** + * Name of the tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = body.name() + + /** + * Brand to be used for the account when one is not specified by the send call. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = body.brandId() + + /** + * Defines the preferences used for the tenant when the user hasn't specified their own. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultPreferences(): Optional = body.defaultPreferences() + + /** + * Tenant's parent id (if any). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parentTenantId(): Optional = body.parentTenantId() + + /** + * Arbitrary properties accessible to a template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun properties(): Optional = body.properties() + + /** + * A user profile object merged with user profile on send. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userProfile(): Optional = body.userProfile() + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _name(): JsonField = body._name() + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _brandId(): JsonField = body._brandId() + + /** + * Returns the raw JSON value of [defaultPreferences]. + * + * Unlike [defaultPreferences], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _defaultPreferences(): JsonField = body._defaultPreferences() + + /** + * Returns the raw JSON value of [parentTenantId]. + * + * Unlike [parentTenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _parentTenantId(): JsonField = body._parentTenantId() + + /** + * Returns the raw JSON value of [properties]. + * + * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _properties(): JsonField = body._properties() + + /** + * Returns the raw JSON value of [userProfile]. + * + * Unlike [userProfile], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _userProfile(): JsonField = body._userProfile() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantUpdateParams]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantUpdateParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantUpdateParams: TenantUpdateParams) = apply { + tenantId = tenantUpdateParams.tenantId + body = tenantUpdateParams.body.toBuilder() + additionalHeaders = tenantUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantUpdateParams.additionalQueryParams.toBuilder() + } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [name] + * - [brandId] + * - [defaultPreferences] + * - [parentTenantId] + * - [properties] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Name of the tenant. */ + fun name(name: String) = apply { body.name(name) } + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { body.name(name) } + + /** Brand to be used for the account when one is not specified by the send call. */ + fun brandId(brandId: String?) = apply { body.brandId(brandId) } + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun brandId(brandId: JsonField) = apply { body.brandId(brandId) } + + /** Defines the preferences used for the tenant when the user hasn't specified their own. */ + fun defaultPreferences(defaultPreferences: DefaultPreferences?) = apply { + body.defaultPreferences(defaultPreferences) + } + + /** + * Alias for calling [Builder.defaultPreferences] with `defaultPreferences.orElse(null)`. + */ + fun defaultPreferences(defaultPreferences: Optional) = + defaultPreferences(defaultPreferences.getOrNull()) + + /** + * Sets [Builder.defaultPreferences] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultPreferences] with a well-typed + * [DefaultPreferences] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun defaultPreferences(defaultPreferences: JsonField) = apply { + body.defaultPreferences(defaultPreferences) + } + + /** Tenant's parent id (if any). */ + fun parentTenantId(parentTenantId: String?) = apply { body.parentTenantId(parentTenantId) } + + /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ + fun parentTenantId(parentTenantId: Optional) = + parentTenantId(parentTenantId.getOrNull()) + + /** + * Sets [Builder.parentTenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentTenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentTenantId(parentTenantId: JsonField) = apply { + body.parentTenantId(parentTenantId) + } + + /** Arbitrary properties accessible to a template. */ + fun properties(properties: Properties?) = apply { body.properties(properties) } + + /** Alias for calling [Builder.properties] with `properties.orElse(null)`. */ + fun properties(properties: Optional) = properties(properties.getOrNull()) + + /** + * Sets [Builder.properties] to an arbitrary JSON value. + * + * You should usually call [Builder.properties] with a well-typed [Properties] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun properties(properties: JsonField) = apply { body.properties(properties) } + + /** A user profile object merged with user profile on send. */ + fun userProfile(userProfile: UserProfile?) = apply { body.userProfile(userProfile) } + + /** Alias for calling [Builder.userProfile] with `userProfile.orElse(null)`. */ + fun userProfile(userProfile: Optional) = userProfile(userProfile.getOrNull()) + + /** + * Sets [Builder.userProfile] to an arbitrary JSON value. + * + * You should usually call [Builder.userProfile] with a well-typed [UserProfile] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userProfile(userProfile: JsonField) = apply { + body.userProfile(userProfile) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantUpdateParams = + TenantUpdateParams( + tenantId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val name: JsonField, + private val brandId: JsonField, + private val defaultPreferences: JsonField, + private val parentTenantId: JsonField, + private val properties: JsonField, + private val userProfile: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), + @JsonProperty("default_preferences") + @ExcludeMissing + defaultPreferences: JsonField = JsonMissing.of(), + @JsonProperty("parent_tenant_id") + @ExcludeMissing + parentTenantId: JsonField = JsonMissing.of(), + @JsonProperty("properties") + @ExcludeMissing + properties: JsonField = JsonMissing.of(), + @JsonProperty("user_profile") + @ExcludeMissing + userProfile: JsonField = JsonMissing.of(), + ) : this( + name, + brandId, + defaultPreferences, + parentTenantId, + properties, + userProfile, + mutableMapOf(), + ) + + /** + * Name of the tenant. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Brand to be used for the account when one is not specified by the send call. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * Defines the preferences used for the tenant when the user hasn't specified their own. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun defaultPreferences(): Optional = + defaultPreferences.getOptional("default_preferences") + + /** + * Tenant's parent id (if any). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parentTenantId(): Optional = parentTenantId.getOptional("parent_tenant_id") + + /** + * Arbitrary properties accessible to a template. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun properties(): Optional = properties.getOptional("properties") + + /** + * A user profile object merged with user profile on send. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userProfile(): Optional = userProfile.getOptional("user_profile") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [defaultPreferences]. + * + * Unlike [defaultPreferences], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("default_preferences") + @ExcludeMissing + fun _defaultPreferences(): JsonField = defaultPreferences + + /** + * Returns the raw JSON value of [parentTenantId]. + * + * Unlike [parentTenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parent_tenant_id") + @ExcludeMissing + fun _parentTenantId(): JsonField = parentTenantId + + /** + * Returns the raw JSON value of [properties]. + * + * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("properties") + @ExcludeMissing + fun _properties(): JsonField = properties + + /** + * Returns the raw JSON value of [userProfile]. + * + * Unlike [userProfile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_profile") + @ExcludeMissing + fun _userProfile(): JsonField = userProfile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var brandId: JsonField = JsonMissing.of() + private var defaultPreferences: JsonField = JsonMissing.of() + private var parentTenantId: JsonField = JsonMissing.of() + private var properties: JsonField = JsonMissing.of() + private var userProfile: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + name = body.name + brandId = body.brandId + defaultPreferences = body.defaultPreferences + parentTenantId = body.parentTenantId + properties = body.properties + userProfile = body.userProfile + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Name of the tenant. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Brand to be used for the account when one is not specified by the send call. */ + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * Defines the preferences used for the tenant when the user hasn't specified their own. + */ + fun defaultPreferences(defaultPreferences: DefaultPreferences?) = + defaultPreferences(JsonField.ofNullable(defaultPreferences)) + + /** + * Alias for calling [Builder.defaultPreferences] with + * `defaultPreferences.orElse(null)`. + */ + fun defaultPreferences(defaultPreferences: Optional) = + defaultPreferences(defaultPreferences.getOrNull()) + + /** + * Sets [Builder.defaultPreferences] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultPreferences] with a well-typed + * [DefaultPreferences] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun defaultPreferences(defaultPreferences: JsonField) = apply { + this.defaultPreferences = defaultPreferences + } + + /** Tenant's parent id (if any). */ + fun parentTenantId(parentTenantId: String?) = + parentTenantId(JsonField.ofNullable(parentTenantId)) + + /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ + fun parentTenantId(parentTenantId: Optional) = + parentTenantId(parentTenantId.getOrNull()) + + /** + * Sets [Builder.parentTenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.parentTenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parentTenantId(parentTenantId: JsonField) = apply { + this.parentTenantId = parentTenantId + } + + /** Arbitrary properties accessible to a template. */ + fun properties(properties: Properties?) = properties(JsonField.ofNullable(properties)) + + /** Alias for calling [Builder.properties] with `properties.orElse(null)`. */ + fun properties(properties: Optional) = properties(properties.getOrNull()) + + /** + * Sets [Builder.properties] to an arbitrary JSON value. + * + * You should usually call [Builder.properties] with a well-typed [Properties] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun properties(properties: JsonField) = apply { + this.properties = properties + } + + /** A user profile object merged with user profile on send. */ + fun userProfile(userProfile: UserProfile?) = + userProfile(JsonField.ofNullable(userProfile)) + + /** Alias for calling [Builder.userProfile] with `userProfile.orElse(null)`. */ + fun userProfile(userProfile: Optional) = + userProfile(userProfile.getOrNull()) + + /** + * Sets [Builder.userProfile] to an arbitrary JSON value. + * + * You should usually call [Builder.userProfile] with a well-typed [UserProfile] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun userProfile(userProfile: JsonField) = apply { + this.userProfile = userProfile + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("name", name), + brandId, + defaultPreferences, + parentTenantId, + properties, + userProfile, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + name() + brandId() + defaultPreferences().ifPresent { it.validate() } + parentTenantId() + properties().ifPresent { it.validate() } + userProfile().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (if (brandId.asKnown().isPresent) 1 else 0) + + (defaultPreferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (parentTenantId.asKnown().isPresent) 1 else 0) + + (properties.asKnown().getOrNull()?.validity() ?: 0) + + (userProfile.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + name == other.name && + brandId == other.brandId && + defaultPreferences == other.defaultPreferences && + parentTenantId == other.parentTenantId && + properties == other.properties && + userProfile == other.userProfile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + name, + brandId, + defaultPreferences, + parentTenantId, + properties, + userProfile, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{name=$name, brandId=$brandId, defaultPreferences=$defaultPreferences, parentTenantId=$parentTenantId, properties=$properties, userProfile=$userProfile, additionalProperties=$additionalProperties}" + } + + /** Arbitrary properties accessible to a template. */ + class Properties + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Properties]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Properties]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(properties: Properties) = apply { + additionalProperties = properties.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Properties]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Properties = Properties(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Properties = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Properties && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Properties{additionalProperties=$additionalProperties}" + } + + /** A user profile object merged with user profile on send. */ + class UserProfile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UserProfile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserProfile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userProfile: UserProfile) = apply { + additionalProperties = userProfile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserProfile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserProfile = UserProfile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): UserProfile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserProfile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UserProfile{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantUpdateParams && + tenantId == other.tenantId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tenantId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantUpdateParams{tenantId=$tenantId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt new file mode 100644 index 00000000..e2c2b2ee --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import com.courier.api.core.Enum +import com.courier.api.core.JsonField +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +class ChannelClassification @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DIRECT_MESSAGE = of("direct_message") + + @JvmField val EMAIL = of("email") + + @JvmField val PUSH = of("push") + + @JvmField val SMS = of("sms") + + @JvmField val WEBHOOK = of("webhook") + + @JvmField val INBOX = of("inbox") + + @JvmStatic fun of(value: String) = ChannelClassification(JsonField.of(value)) + } + + /** An enum containing [ChannelClassification]'s known values. */ + enum class Known { + DIRECT_MESSAGE, + EMAIL, + PUSH, + SMS, + WEBHOOK, + INBOX, + } + + /** + * An enum containing [ChannelClassification]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ChannelClassification] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIRECT_MESSAGE, + EMAIL, + PUSH, + SMS, + WEBHOOK, + INBOX, + /** + * An enum member indicating that [ChannelClassification] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIRECT_MESSAGE -> Value.DIRECT_MESSAGE + EMAIL -> Value.EMAIL + PUSH -> Value.PUSH + SMS -> Value.SMS + WEBHOOK -> Value.WEBHOOK + INBOX -> Value.INBOX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + DIRECT_MESSAGE -> Known.DIRECT_MESSAGE + EMAIL -> Known.EMAIL + PUSH -> Known.PUSH + SMS -> Known.SMS + WEBHOOK -> Known.WEBHOOK + INBOX -> Known.INBOX + else -> throw CourierInvalidDataException("Unknown ChannelClassification: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ChannelClassification = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChannelClassification && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt new file mode 100644 index 00000000..f485c84c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Remove Default Preferences For Topic */ +class ItemDeleteParams +private constructor( + private val tenantId: String, + private val topicId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun tenantId(): String = tenantId + + fun topicId(): Optional = Optional.ofNullable(topicId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemDeleteParams]. + * + * The following fields are required: + * ```java + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemDeleteParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var topicId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(itemDeleteParams: ItemDeleteParams) = apply { + tenantId = itemDeleteParams.tenantId + topicId = itemDeleteParams.topicId + additionalHeaders = itemDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = itemDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = itemDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun tenantId(tenantId: String) = apply { this.tenantId = tenantId } + + fun topicId(topicId: String?) = apply { this.topicId = topicId } + + /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ + fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [ItemDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemDeleteParams = + ItemDeleteParams( + checkRequired("tenantId", tenantId), + topicId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId + 1 -> topicId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemDeleteParams && + tenantId == other.tenantId && + topicId == other.topicId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + tenantId, + topicId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "ItemDeleteParams{tenantId=$tenantId, topicId=$topicId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt new file mode 100644 index 00000000..df367cb9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt @@ -0,0 +1,242 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Create or Replace Default Preferences For Topic */ +class ItemUpdateParams +private constructor( + private val tenantId: String, + private val topicId: String?, + private val subscriptionTopicNew: SubscriptionTopicNew, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tenantId(): String = tenantId + + fun topicId(): Optional = Optional.ofNullable(topicId) + + fun subscriptionTopicNew(): SubscriptionTopicNew = subscriptionTopicNew + + fun _additionalBodyProperties(): Map = + subscriptionTopicNew._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ItemUpdateParams]. + * + * The following fields are required: + * ```java + * .tenantId() + * .subscriptionTopicNew() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ItemUpdateParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var topicId: String? = null + private var subscriptionTopicNew: SubscriptionTopicNew? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(itemUpdateParams: ItemUpdateParams) = apply { + tenantId = itemUpdateParams.tenantId + topicId = itemUpdateParams.topicId + subscriptionTopicNew = itemUpdateParams.subscriptionTopicNew + additionalHeaders = itemUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = itemUpdateParams.additionalQueryParams.toBuilder() + } + + fun tenantId(tenantId: String) = apply { this.tenantId = tenantId } + + fun topicId(topicId: String?) = apply { this.topicId = topicId } + + /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ + fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) + + fun subscriptionTopicNew(subscriptionTopicNew: SubscriptionTopicNew) = apply { + this.subscriptionTopicNew = subscriptionTopicNew + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ItemUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenantId() + * .subscriptionTopicNew() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ItemUpdateParams = + ItemUpdateParams( + checkRequired("tenantId", tenantId), + topicId, + checkRequired("subscriptionTopicNew", subscriptionTopicNew), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): SubscriptionTopicNew = subscriptionTopicNew + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId + 1 -> topicId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ItemUpdateParams && + tenantId == other.tenantId && + topicId == other.topicId && + subscriptionTopicNew == other.subscriptionTopicNew && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + tenantId, + topicId, + subscriptionTopicNew, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "ItemUpdateParams{tenantId=$tenantId, topicId=$topicId, subscriptionTopicNew=$subscriptionTopicNew, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt new file mode 100644 index 00000000..3c2f7358 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class SubscriptionTopicNew +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val customRouting: JsonField>, + private val hasCustomRouting: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("custom_routing") + @ExcludeMissing + customRouting: JsonField> = JsonMissing.of(), + @JsonProperty("has_custom_routing") + @ExcludeMissing + hasCustomRouting: JsonField = JsonMissing.of(), + ) : this(status, customRouting, hasCustomRouting, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * The default channels to send to this tenant when has_custom_routing is enabled + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customRouting(): Optional> = + customRouting.getOptional("custom_routing") + + /** + * Override channel routing with custom preferences. This will override any template prefernces + * that are set, but a user can still customize their preferences + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasCustomRouting(): Optional = hasCustomRouting.getOptional("has_custom_routing") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [customRouting]. + * + * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("custom_routing") + @ExcludeMissing + fun _customRouting(): JsonField> = customRouting + + /** + * Returns the raw JSON value of [hasCustomRouting]. + * + * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("has_custom_routing") + @ExcludeMissing + fun _hasCustomRouting(): JsonField = hasCustomRouting + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SubscriptionTopicNew]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SubscriptionTopicNew]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var customRouting: JsonField>? = null + private var hasCustomRouting: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(subscriptionTopicNew: SubscriptionTopicNew) = apply { + status = subscriptionTopicNew.status + customRouting = subscriptionTopicNew.customRouting.map { it.toMutableList() } + hasCustomRouting = subscriptionTopicNew.hasCustomRouting + additionalProperties = subscriptionTopicNew.additionalProperties.toMutableMap() + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The default channels to send to this tenant when has_custom_routing is enabled */ + fun customRouting(customRouting: List?) = + customRouting(JsonField.ofNullable(customRouting)) + + /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ + fun customRouting(customRouting: Optional>) = + customRouting(customRouting.getOrNull()) + + /** + * Sets [Builder.customRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.customRouting] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customRouting(customRouting: JsonField>) = apply { + this.customRouting = customRouting.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelClassification] to [Builder.customRouting]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomRouting(customRouting: ChannelClassification) = apply { + this.customRouting = + (this.customRouting ?: JsonField.of(mutableListOf())).also { + checkKnown("customRouting", it).add(customRouting) + } + } + + /** + * Override channel routing with custom preferences. This will override any template + * prefernces that are set, but a user can still customize their preferences + */ + fun hasCustomRouting(hasCustomRouting: Boolean?) = + hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) + + /** + * Alias for [Builder.hasCustomRouting]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasCustomRouting(hasCustomRouting: Boolean) = + hasCustomRouting(hasCustomRouting as Boolean?) + + /** Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. */ + fun hasCustomRouting(hasCustomRouting: Optional) = + hasCustomRouting(hasCustomRouting.getOrNull()) + + /** + * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasCustomRouting(hasCustomRouting: JsonField) = apply { + this.hasCustomRouting = hasCustomRouting + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [SubscriptionTopicNew]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SubscriptionTopicNew = + SubscriptionTopicNew( + checkRequired("status", status), + (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, + hasCustomRouting, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): SubscriptionTopicNew = apply { + if (validated) { + return@apply + } + + status().validate() + customRouting().ifPresent { it.forEach { it.validate() } } + hasCustomRouting() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OPTED_OUT = of("OPTED_OUT") + + @JvmField val OPTED_IN = of("OPTED_IN") + + @JvmField val REQUIRED = of("REQUIRED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + OPTED_OUT, + OPTED_IN, + REQUIRED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPTED_OUT, + OPTED_IN, + REQUIRED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPTED_OUT -> Value.OPTED_OUT + OPTED_IN -> Value.OPTED_IN + REQUIRED -> Value.REQUIRED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OPTED_OUT -> Known.OPTED_OUT + OPTED_IN -> Known.OPTED_IN + REQUIRED -> Known.REQUIRED + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SubscriptionTopicNew && + status == other.status && + customRouting == other.customRouting && + hasCustomRouting == other.hasCustomRouting && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(status, customRouting, hasCustomRouting, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SubscriptionTopicNew{status=$status, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt new file mode 100644 index 00000000..1742f669 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.translations + +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get translations by locale */ +class TranslationRetrieveParams +private constructor( + private val domain: String, + private val locale: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun domain(): String = domain + + fun locale(): Optional = Optional.ofNullable(locale) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TranslationRetrieveParams]. + * + * The following fields are required: + * ```java + * .domain() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TranslationRetrieveParams]. */ + class Builder internal constructor() { + + private var domain: String? = null + private var locale: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(translationRetrieveParams: TranslationRetrieveParams) = apply { + domain = translationRetrieveParams.domain + locale = translationRetrieveParams.locale + additionalHeaders = translationRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = translationRetrieveParams.additionalQueryParams.toBuilder() + } + + fun domain(domain: String) = apply { this.domain = domain } + + fun locale(locale: String?) = apply { this.locale = locale } + + /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ + fun locale(locale: Optional) = locale(locale.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TranslationRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .domain() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TranslationRetrieveParams = + TranslationRetrieveParams( + checkRequired("domain", domain), + locale, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> domain + 1 -> locale ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TranslationRetrieveParams && + domain == other.domain && + locale == other.locale && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(domain, locale, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TranslationRetrieveParams{domain=$domain, locale=$locale, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt new file mode 100644 index 00000000..437e07e5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.translations + +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update a translation */ +class TranslationUpdateParams +private constructor( + private val domain: String, + private val locale: String?, + private val body: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun domain(): String = domain + + fun locale(): Optional = Optional.ofNullable(locale) + + fun body(): String = body + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TranslationUpdateParams]. + * + * The following fields are required: + * ```java + * .domain() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TranslationUpdateParams]. */ + class Builder internal constructor() { + + private var domain: String? = null + private var locale: String? = null + private var body: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(translationUpdateParams: TranslationUpdateParams) = apply { + domain = translationUpdateParams.domain + locale = translationUpdateParams.locale + body = translationUpdateParams.body + additionalHeaders = translationUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = translationUpdateParams.additionalQueryParams.toBuilder() + } + + fun domain(domain: String) = apply { this.domain = domain } + + fun locale(locale: String?) = apply { this.locale = locale } + + /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ + fun locale(locale: Optional) = locale(locale.getOrNull()) + + fun body(body: String) = apply { this.body = body } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TranslationUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .domain() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TranslationUpdateParams = + TranslationUpdateParams( + checkRequired("domain", domain), + locale, + checkRequired("body", body), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): String = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> domain + 1 -> locale ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TranslationUpdateParams && + domain == other.domain && + locale == other.locale && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(domain, locale, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TranslationUpdateParams{domain=$domain, locale=$locale, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt new file mode 100644 index 00000000..0346f3c8 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch all user preferences. */ +class PreferenceRetrieveParams +private constructor( + private val userId: String?, + private val tenantId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Query the preferences of a user for this specific tenant context. */ + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): PreferenceRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [PreferenceRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceRetrieveParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var tenantId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(preferenceRetrieveParams: PreferenceRetrieveParams) = apply { + userId = preferenceRetrieveParams.userId + tenantId = preferenceRetrieveParams.tenantId + additionalHeaders = preferenceRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = preferenceRetrieveParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** Query the preferences of a user for this specific tenant context. */ + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PreferenceRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): PreferenceRetrieveParams = + PreferenceRetrieveParams( + userId, + tenantId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + tenantId?.let { put("tenant_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceRetrieveParams && + userId == other.userId && + tenantId == other.tenantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, tenantId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PreferenceRetrieveParams{userId=$userId, tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt new file mode 100644 index 00000000..d0a335ea --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PreferenceRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val items: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(items, paging, mutableMapOf()) + + /** + * The Preferences associated with the user_id. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun items(): List = items.getRequired("items") + + /** + * Deprecated - Paging not implemented on this endpoint + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun paging(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PreferenceRetrieveResponse]. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceRetrieveResponse]. */ + class Builder internal constructor() { + + private var items: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferenceRetrieveResponse: PreferenceRetrieveResponse) = apply { + items = preferenceRetrieveResponse.items.map { it.toMutableList() } + paging = preferenceRetrieveResponse.paging + additionalProperties = preferenceRetrieveResponse.additionalProperties.toMutableMap() + } + + /** The Preferences associated with the user_id. */ + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [TopicPreference] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: TopicPreference) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** Deprecated - Paging not implemented on this endpoint */ + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PreferenceRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .items() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceRetrieveResponse = + PreferenceRetrieveResponse( + checkRequired("items", items).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PreferenceRetrieveResponse = apply { + if (validated) { + return@apply + } + + items().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceRetrieveResponse && + items == other.items && + paging == other.paging && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PreferenceRetrieveResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt new file mode 100644 index 00000000..c0cf1b3a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Fetch user preferences for a specific subscription topic. */ +class PreferenceRetrieveTopicParams +private constructor( + private val userId: String, + private val topicId: String?, + private val tenantId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): String = userId + + fun topicId(): Optional = Optional.ofNullable(topicId) + + /** Query the preferences of a user for this specific tenant context. */ + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PreferenceRetrieveTopicParams]. + * + * The following fields are required: + * ```java + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceRetrieveTopicParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var topicId: String? = null + private var tenantId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(preferenceRetrieveTopicParams: PreferenceRetrieveTopicParams) = apply { + userId = preferenceRetrieveTopicParams.userId + topicId = preferenceRetrieveTopicParams.topicId + tenantId = preferenceRetrieveTopicParams.tenantId + additionalHeaders = preferenceRetrieveTopicParams.additionalHeaders.toBuilder() + additionalQueryParams = preferenceRetrieveTopicParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun topicId(topicId: String?) = apply { this.topicId = topicId } + + /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ + fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) + + /** Query the preferences of a user for this specific tenant context. */ + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PreferenceRetrieveTopicParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceRetrieveTopicParams = + PreferenceRetrieveTopicParams( + checkRequired("userId", userId), + topicId, + tenantId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> topicId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + tenantId?.let { put("tenant_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceRetrieveTopicParams && + userId == other.userId && + topicId == other.topicId && + tenantId == other.tenantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, topicId, tenantId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PreferenceRetrieveTopicParams{userId=$userId, topicId=$topicId, tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt new file mode 100644 index 00000000..76484333 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PreferenceRetrieveTopicResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val topic: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of() + ) : this(topic, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topic(): TopicPreference = topic.getRequired("topic") + + /** + * Returns the raw JSON value of [topic]. + * + * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PreferenceRetrieveTopicResponse]. + * + * The following fields are required: + * ```java + * .topic() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceRetrieveTopicResponse]. */ + class Builder internal constructor() { + + private var topic: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferenceRetrieveTopicResponse: PreferenceRetrieveTopicResponse) = + apply { + topic = preferenceRetrieveTopicResponse.topic + additionalProperties = + preferenceRetrieveTopicResponse.additionalProperties.toMutableMap() + } + + fun topic(topic: TopicPreference) = topic(JsonField.of(topic)) + + /** + * Sets [Builder.topic] to an arbitrary JSON value. + * + * You should usually call [Builder.topic] with a well-typed [TopicPreference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun topic(topic: JsonField) = apply { this.topic = topic } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PreferenceRetrieveTopicResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .topic() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceRetrieveTopicResponse = + PreferenceRetrieveTopicResponse( + checkRequired("topic", topic), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PreferenceRetrieveTopicResponse = apply { + if (validated) { + return@apply + } + + topic().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (topic.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceRetrieveTopicResponse && + topic == other.topic && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(topic, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PreferenceRetrieveTopicResponse{topic=$topic, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt new file mode 100644 index 00000000..9d7c1ad6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.Enum +import com.courier.api.core.JsonField +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator + +class PreferenceStatus @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't match + * any known member, and you want to know that value. For example, if the SDK is on an older + * version than the API, then the API may respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OPTED_IN = of("OPTED_IN") + + @JvmField val OPTED_OUT = of("OPTED_OUT") + + @JvmField val REQUIRED = of("REQUIRED") + + @JvmStatic fun of(value: String) = PreferenceStatus(JsonField.of(value)) + } + + /** An enum containing [PreferenceStatus]'s known values. */ + enum class Known { + OPTED_IN, + OPTED_OUT, + REQUIRED, + } + + /** + * An enum containing [PreferenceStatus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PreferenceStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the SDK + * is on an older version than the API, then the API may respond with new members that the SDK + * is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPTED_IN, + OPTED_OUT, + REQUIRED, + /** + * An enum member indicating that [PreferenceStatus] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if + * the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want to + * throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPTED_IN -> Value.OPTED_IN + OPTED_OUT -> Value.OPTED_OUT + REQUIRED -> Value.REQUIRED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't want + * to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + OPTED_IN -> Known.OPTED_IN + OPTED_OUT -> Known.OPTED_OUT + REQUIRED -> Known.REQUIRED + else -> throw CourierInvalidDataException("Unknown PreferenceStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging and + * generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the expected + * primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PreferenceStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceStatus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt new file mode 100644 index 00000000..1c42555d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt @@ -0,0 +1,745 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Update or Create user preferences for a specific subscription topic. */ +class PreferenceUpdateOrCreateTopicParams +private constructor( + private val userId: String, + private val topicId: String?, + private val tenantId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): String = userId + + fun topicId(): Optional = Optional.ofNullable(topicId) + + /** Update the preferences of a user for this specific tenant context. */ + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topic(): Topic = body.topic() + + /** + * Returns the raw JSON value of [topic]. + * + * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _topic(): JsonField = body._topic() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PreferenceUpdateOrCreateTopicParams]. + * + * The following fields are required: + * ```java + * .userId() + * .topic() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceUpdateOrCreateTopicParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var topicId: String? = null + private var tenantId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + preferenceUpdateOrCreateTopicParams: PreferenceUpdateOrCreateTopicParams + ) = apply { + userId = preferenceUpdateOrCreateTopicParams.userId + topicId = preferenceUpdateOrCreateTopicParams.topicId + tenantId = preferenceUpdateOrCreateTopicParams.tenantId + body = preferenceUpdateOrCreateTopicParams.body.toBuilder() + additionalHeaders = preferenceUpdateOrCreateTopicParams.additionalHeaders.toBuilder() + additionalQueryParams = + preferenceUpdateOrCreateTopicParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun topicId(topicId: String?) = apply { this.topicId = topicId } + + /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ + fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) + + /** Update the preferences of a user for this specific tenant context. */ + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [topic] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun topic(topic: Topic) = apply { body.topic(topic) } + + /** + * Sets [Builder.topic] to an arbitrary JSON value. + * + * You should usually call [Builder.topic] with a well-typed [Topic] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topic(topic: JsonField) = apply { body.topic(topic) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [PreferenceUpdateOrCreateTopicParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * .topic() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceUpdateOrCreateTopicParams = + PreferenceUpdateOrCreateTopicParams( + checkRequired("userId", userId), + topicId, + tenantId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> topicId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + tenantId?.let { put("tenant_id", it) } + putAll(additionalQueryParams) + } + .build() + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val topic: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of() + ) : this(topic, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topic(): Topic = topic.getRequired("topic") + + /** + * Returns the raw JSON value of [topic]. + * + * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .topic() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var topic: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + topic = body.topic + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun topic(topic: Topic) = topic(JsonField.of(topic)) + + /** + * Sets [Builder.topic] to an arbitrary JSON value. + * + * You should usually call [Builder.topic] with a well-typed [Topic] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topic(topic: JsonField) = apply { this.topic = topic } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .topic() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("topic", topic), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + topic().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (topic.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + topic == other.topic && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(topic, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{topic=$topic, additionalProperties=$additionalProperties}" + } + + class Topic + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val status: JsonField, + private val customRouting: JsonField>, + private val hasCustomRouting: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("custom_routing") + @ExcludeMissing + customRouting: JsonField> = JsonMissing.of(), + @JsonProperty("has_custom_routing") + @ExcludeMissing + hasCustomRouting: JsonField = JsonMissing.of(), + ) : this(status, customRouting, hasCustomRouting, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): PreferenceStatus = status.getRequired("status") + + /** + * The Channels a user has chosen to receive notifications through for this topic + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customRouting(): Optional> = + customRouting.getOptional("custom_routing") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasCustomRouting(): Optional = + hasCustomRouting.getOptional("has_custom_routing") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [customRouting]. + * + * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("custom_routing") + @ExcludeMissing + fun _customRouting(): JsonField> = customRouting + + /** + * Returns the raw JSON value of [hasCustomRouting]. + * + * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("has_custom_routing") + @ExcludeMissing + fun _hasCustomRouting(): JsonField = hasCustomRouting + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Topic]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Topic]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var customRouting: JsonField>? = null + private var hasCustomRouting: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topic: Topic) = apply { + status = topic.status + customRouting = topic.customRouting.map { it.toMutableList() } + hasCustomRouting = topic.hasCustomRouting + additionalProperties = topic.additionalProperties.toMutableMap() + } + + fun status(status: PreferenceStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The Channels a user has chosen to receive notifications through for this topic */ + fun customRouting(customRouting: List?) = + customRouting(JsonField.ofNullable(customRouting)) + + /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ + fun customRouting(customRouting: Optional>) = + customRouting(customRouting.getOrNull()) + + /** + * Sets [Builder.customRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.customRouting] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customRouting(customRouting: JsonField>) = apply { + this.customRouting = customRouting.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelClassification] to [Builder.customRouting]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomRouting(customRouting: ChannelClassification) = apply { + this.customRouting = + (this.customRouting ?: JsonField.of(mutableListOf())).also { + checkKnown("customRouting", it).add(customRouting) + } + } + + fun hasCustomRouting(hasCustomRouting: Boolean?) = + hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) + + /** + * Alias for [Builder.hasCustomRouting]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasCustomRouting(hasCustomRouting: Boolean) = + hasCustomRouting(hasCustomRouting as Boolean?) + + /** + * Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. + */ + fun hasCustomRouting(hasCustomRouting: Optional) = + hasCustomRouting(hasCustomRouting.getOrNull()) + + /** + * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasCustomRouting(hasCustomRouting: JsonField) = apply { + this.hasCustomRouting = hasCustomRouting + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Topic]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Topic = + Topic( + checkRequired("status", status), + (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, + hasCustomRouting, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Topic = apply { + if (validated) { + return@apply + } + + status().validate() + customRouting().ifPresent { it.forEach { it.validate() } } + hasCustomRouting() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Topic && + status == other.status && + customRouting == other.customRouting && + hasCustomRouting == other.hasCustomRouting && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(status, customRouting, hasCustomRouting, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Topic{status=$status, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceUpdateOrCreateTopicParams && + userId == other.userId && + topicId == other.topicId && + tenantId == other.tenantId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, topicId, tenantId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "PreferenceUpdateOrCreateTopicParams{userId=$userId, topicId=$topicId, tenantId=$tenantId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt new file mode 100644 index 00000000..84fb4447 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class PreferenceUpdateOrCreateTopicResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val message: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of() + ) : this(message, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PreferenceUpdateOrCreateTopicResponse]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PreferenceUpdateOrCreateTopicResponse]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + preferenceUpdateOrCreateTopicResponse: PreferenceUpdateOrCreateTopicResponse + ) = apply { + message = preferenceUpdateOrCreateTopicResponse.message + additionalProperties = + preferenceUpdateOrCreateTopicResponse.additionalProperties.toMutableMap() + } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PreferenceUpdateOrCreateTopicResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PreferenceUpdateOrCreateTopicResponse = + PreferenceUpdateOrCreateTopicResponse( + checkRequired("message", message), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PreferenceUpdateOrCreateTopicResponse = apply { + if (validated) { + return@apply + } + + message() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (message.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PreferenceUpdateOrCreateTopicResponse && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PreferenceUpdateOrCreateTopicResponse{message=$message, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt new file mode 100644 index 00000000..8f537432 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt @@ -0,0 +1,417 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TopicPreference +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val defaultStatus: JsonField, + private val status: JsonField, + private val topicId: JsonField, + private val topicName: JsonField, + private val customRouting: JsonField>, + private val hasCustomRouting: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("default_status") + @ExcludeMissing + defaultStatus: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("topic_id") @ExcludeMissing topicId: JsonField = JsonMissing.of(), + @JsonProperty("topic_name") @ExcludeMissing topicName: JsonField = JsonMissing.of(), + @JsonProperty("custom_routing") + @ExcludeMissing + customRouting: JsonField> = JsonMissing.of(), + @JsonProperty("has_custom_routing") + @ExcludeMissing + hasCustomRouting: JsonField = JsonMissing.of(), + ) : this( + defaultStatus, + status, + topicId, + topicName, + customRouting, + hasCustomRouting, + mutableMapOf(), + ) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun defaultStatus(): PreferenceStatus = defaultStatus.getRequired("default_status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): PreferenceStatus = status.getRequired("status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topicId(): String = topicId.getRequired("topic_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun topicName(): String = topicName.getRequired("topic_name") + + /** + * The Channels a user has chosen to receive notifications through for this topic + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customRouting(): Optional> = + customRouting.getOptional("custom_routing") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hasCustomRouting(): Optional = hasCustomRouting.getOptional("has_custom_routing") + + /** + * Returns the raw JSON value of [defaultStatus]. + * + * Unlike [defaultStatus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("default_status") + @ExcludeMissing + fun _defaultStatus(): JsonField = defaultStatus + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [topicId]. + * + * Unlike [topicId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic_id") @ExcludeMissing fun _topicId(): JsonField = topicId + + /** + * Returns the raw JSON value of [topicName]. + * + * Unlike [topicName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("topic_name") @ExcludeMissing fun _topicName(): JsonField = topicName + + /** + * Returns the raw JSON value of [customRouting]. + * + * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("custom_routing") + @ExcludeMissing + fun _customRouting(): JsonField> = customRouting + + /** + * Returns the raw JSON value of [hasCustomRouting]. + * + * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("has_custom_routing") + @ExcludeMissing + fun _hasCustomRouting(): JsonField = hasCustomRouting + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TopicPreference]. + * + * The following fields are required: + * ```java + * .defaultStatus() + * .status() + * .topicId() + * .topicName() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TopicPreference]. */ + class Builder internal constructor() { + + private var defaultStatus: JsonField? = null + private var status: JsonField? = null + private var topicId: JsonField? = null + private var topicName: JsonField? = null + private var customRouting: JsonField>? = null + private var hasCustomRouting: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(topicPreference: TopicPreference) = apply { + defaultStatus = topicPreference.defaultStatus + status = topicPreference.status + topicId = topicPreference.topicId + topicName = topicPreference.topicName + customRouting = topicPreference.customRouting.map { it.toMutableList() } + hasCustomRouting = topicPreference.hasCustomRouting + additionalProperties = topicPreference.additionalProperties.toMutableMap() + } + + fun defaultStatus(defaultStatus: PreferenceStatus) = + defaultStatus(JsonField.of(defaultStatus)) + + /** + * Sets [Builder.defaultStatus] to an arbitrary JSON value. + * + * You should usually call [Builder.defaultStatus] with a well-typed [PreferenceStatus] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun defaultStatus(defaultStatus: JsonField) = apply { + this.defaultStatus = defaultStatus + } + + fun status(status: PreferenceStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun topicId(topicId: String) = topicId(JsonField.of(topicId)) + + /** + * Sets [Builder.topicId] to an arbitrary JSON value. + * + * You should usually call [Builder.topicId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun topicId(topicId: JsonField) = apply { this.topicId = topicId } + + fun topicName(topicName: String) = topicName(JsonField.of(topicName)) + + /** + * Sets [Builder.topicName] to an arbitrary JSON value. + * + * You should usually call [Builder.topicName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun topicName(topicName: JsonField) = apply { this.topicName = topicName } + + /** The Channels a user has chosen to receive notifications through for this topic */ + fun customRouting(customRouting: List?) = + customRouting(JsonField.ofNullable(customRouting)) + + /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ + fun customRouting(customRouting: Optional>) = + customRouting(customRouting.getOrNull()) + + /** + * Sets [Builder.customRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.customRouting] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun customRouting(customRouting: JsonField>) = apply { + this.customRouting = customRouting.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelClassification] to [Builder.customRouting]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomRouting(customRouting: ChannelClassification) = apply { + this.customRouting = + (this.customRouting ?: JsonField.of(mutableListOf())).also { + checkKnown("customRouting", it).add(customRouting) + } + } + + fun hasCustomRouting(hasCustomRouting: Boolean?) = + hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) + + /** + * Alias for [Builder.hasCustomRouting]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hasCustomRouting(hasCustomRouting: Boolean) = + hasCustomRouting(hasCustomRouting as Boolean?) + + /** Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. */ + fun hasCustomRouting(hasCustomRouting: Optional) = + hasCustomRouting(hasCustomRouting.getOrNull()) + + /** + * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. + * + * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hasCustomRouting(hasCustomRouting: JsonField) = apply { + this.hasCustomRouting = hasCustomRouting + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TopicPreference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .defaultStatus() + * .status() + * .topicId() + * .topicName() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TopicPreference = + TopicPreference( + checkRequired("defaultStatus", defaultStatus), + checkRequired("status", status), + checkRequired("topicId", topicId), + checkRequired("topicName", topicName), + (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, + hasCustomRouting, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TopicPreference = apply { + if (validated) { + return@apply + } + + defaultStatus().validate() + status().validate() + topicId() + topicName() + customRouting().ifPresent { it.forEach { it.validate() } } + hasCustomRouting() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (defaultStatus.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (topicId.asKnown().isPresent) 1 else 0) + + (if (topicName.asKnown().isPresent) 1 else 0) + + (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TopicPreference && + defaultStatus == other.defaultStatus && + status == other.status && + topicId == other.topicId && + topicName == other.topicName && + customRouting == other.customRouting && + hasCustomRouting == other.hasCustomRouting && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + defaultStatus, + status, + topicId, + topicName, + customRouting, + hasCustomRouting, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TopicPreference{defaultStatus=$defaultStatus, status=$status, topicId=$topicId, topicName=$topicName, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt new file mode 100644 index 00000000..de433ce2 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt @@ -0,0 +1,467 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint is used to add a user to multiple tenants in one call. A custom profile can also be + * supplied for each tenant. This profile will be merged with the user's main profile when sending + * to the user with that tenant. + */ +class TenantAddMultipleParams +private constructor( + private val userId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenants(): List = body.tenants() + + /** + * Returns the raw JSON value of [tenants]. + * + * Unlike [tenants], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _tenants(): JsonField> = body._tenants() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantAddMultipleParams]. + * + * The following fields are required: + * ```java + * .tenants() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantAddMultipleParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantAddMultipleParams: TenantAddMultipleParams) = apply { + userId = tenantAddMultipleParams.userId + body = tenantAddMultipleParams.body.toBuilder() + additionalHeaders = tenantAddMultipleParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantAddMultipleParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [tenants] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun tenants(tenants: List) = apply { body.tenants(tenants) } + + /** + * Sets [Builder.tenants] to an arbitrary JSON value. + * + * You should usually call [Builder.tenants] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tenants(tenants: JsonField>) = apply { body.tenants(tenants) } + + /** + * Adds a single [TenantAssociation] to [tenants]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTenant(tenant: TenantAssociation) = apply { body.addTenant(tenant) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantAddMultipleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenants() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantAddMultipleParams = + TenantAddMultipleParams( + userId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val tenants: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("tenants") + @ExcludeMissing + tenants: JsonField> = JsonMissing.of() + ) : this(tenants, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenants(): List = tenants.getRequired("tenants") + + /** + * Returns the raw JSON value of [tenants]. + * + * Unlike [tenants], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenants") + @ExcludeMissing + fun _tenants(): JsonField> = tenants + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .tenants() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var tenants: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + tenants = body.tenants.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun tenants(tenants: List) = tenants(JsonField.of(tenants)) + + /** + * Sets [Builder.tenants] to an arbitrary JSON value. + * + * You should usually call [Builder.tenants] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenants(tenants: JsonField>) = apply { + this.tenants = tenants.map { it.toMutableList() } + } + + /** + * Adds a single [TenantAssociation] to [tenants]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTenant(tenant: TenantAssociation) = apply { + tenants = + (tenants ?: JsonField.of(mutableListOf())).also { + checkKnown("tenants", it).add(tenant) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenants() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("tenants", tenants).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + tenants().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (tenants.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + tenants == other.tenants && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tenants, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{tenants=$tenants, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantAddMultipleParams && + userId == other.userId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantAddMultipleParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt new file mode 100644 index 00000000..b4f8f878 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt @@ -0,0 +1,537 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * This endpoint is used to add a single tenant. + * + * A custom profile can also be supplied with the tenant. This profile will be merged with the + * user's main profile when sending to the user with that tenant. + */ +class TenantAddSingleParams +private constructor( + private val userId: String, + private val tenantId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): String = userId + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun profile(): Optional = body.profile() + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _profile(): JsonField = body._profile() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantAddSingleParams]. + * + * The following fields are required: + * ```java + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantAddSingleParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var tenantId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantAddSingleParams: TenantAddSingleParams) = apply { + userId = tenantAddSingleParams.userId + tenantId = tenantAddSingleParams.tenantId + body = tenantAddSingleParams.body.toBuilder() + additionalHeaders = tenantAddSingleParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantAddSingleParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [profile] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun profile(profile: Profile?) = apply { body.profile(profile) } + + /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ + fun profile(profile: Optional) = profile(profile.getOrNull()) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun profile(profile: JsonField) = apply { body.profile(profile) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantAddSingleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantAddSingleParams = + TenantAddSingleParams( + checkRequired("userId", userId), + tenantId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val profile: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of() + ) : this(profile, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun profile(): Optional = profile.getOptional("profile") + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var profile: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + profile = body.profile + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) + + /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ + fun profile(profile: Optional) = profile(profile.getOrNull()) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(profile, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + profile().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (profile.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + profile == other.profile && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(profile, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{profile=$profile, additionalProperties=$additionalProperties}" + } + + class Profile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Profile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Profile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profile: Profile) = apply { + additionalProperties = profile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Profile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Profile = Profile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Profile{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantAddSingleParams && + userId == other.userId && + tenantId == other.tenantId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, tenantId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantAddSingleParams{userId=$userId, tenantId=$tenantId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt new file mode 100644 index 00000000..0d81492a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt @@ -0,0 +1,508 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TenantAssociation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tenantId: JsonField, + private val profile: JsonField, + private val type: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + ) : this(tenantId, profile, type, userId, mutableMapOf()) + + /** + * Tenant ID for the association between tenant and user + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * Additional metadata to be applied to a user profile when used in a tenant context + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun profile(): Optional = profile.getOptional("profile") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * User ID for the association between tenant and user + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("user_id") + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [profile]. + * + * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantAssociation]. + * + * The following fields are required: + * ```java + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantAssociation]. */ + class Builder internal constructor() { + + private var tenantId: JsonField? = null + private var profile: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantAssociation: TenantAssociation) = apply { + tenantId = tenantAssociation.tenantId + profile = tenantAssociation.profile + type = tenantAssociation.type + userId = tenantAssociation.userId + additionalProperties = tenantAssociation.additionalProperties.toMutableMap() + } + + /** Tenant ID for the association between tenant and user */ + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + /** Additional metadata to be applied to a user profile when used in a tenant context */ + fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) + + /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ + fun profile(profile: Optional) = profile(profile.getOrNull()) + + /** + * Sets [Builder.profile] to an arbitrary JSON value. + * + * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun profile(profile: JsonField) = apply { this.profile = profile } + + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** User ID for the association between tenant and user */ + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TenantAssociation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantAssociation = + TenantAssociation( + checkRequired("tenantId", tenantId), + profile, + type, + userId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TenantAssociation = apply { + if (validated) { + return@apply + } + + tenantId() + profile().ifPresent { it.validate() } + type().ifPresent { it.validate() } + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (tenantId.asKnown().isPresent) 1 else 0) + + (profile.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + /** Additional metadata to be applied to a user profile when used in a tenant context */ + class Profile + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Profile]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Profile]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(profile: Profile) = apply { + additionalProperties = profile.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Profile]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Profile = Profile(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Profile = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Profile && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Profile{additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val USER = of("user") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + USER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + USER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + USER -> Value.USER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + USER -> Known.USER + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantAssociation && + tenantId == other.tenantId && + profile == other.profile && + type == other.type && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(tenantId, profile, type, userId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TenantAssociation{tenantId=$tenantId, profile=$profile, type=$type, userId=$userId, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt new file mode 100644 index 00000000..d91e4a01 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Returns a paginated list of user tenant associations. */ +class TenantListParams +private constructor( + private val userId: String?, + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Continue the pagination with the next cursor */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The number of accounts to return (defaults to 20, maximum value of 100) */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tenantListParams: TenantListParams) = apply { + userId = tenantListParams.userId + cursor = tenantListParams.cursor + limit = tenantListParams.limit + additionalHeaders = tenantListParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantListParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** Continue the pagination with the next cursor */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The number of accounts to return (defaults to 20, maximum value of 100) */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TenantListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantListParams = + TenantListParams( + userId, + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListParams && + userId == other.userId && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TenantListParams{userId=$userId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt new file mode 100644 index 00000000..8510021b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt @@ -0,0 +1,501 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TenantListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasMore: JsonField, + private val type: JsonField, + private val url: JsonField, + private val cursor: JsonField, + private val items: JsonField>, + private val nextUrl: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of(), + @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), + ) : this(hasMore, type, url, cursor, items, nextUrl, mutableMapOf()) + + /** + * Set to true when there are more pages that can be retrieved. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + /** + * Always set to `list`. Represents the type of this object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A url that may be used to generate these results. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * A pointer to the next page of results. Defined only when `has_more` is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("items") + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * `has_more` is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextUrl(): Optional = nextUrl.getOptional("next_url") + + /** + * Returns the raw JSON value of [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [nextUrl]. + * + * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantListResponse]. + * + * The following fields are required: + * ```java + * .hasMore() + * .type() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantListResponse]. */ + class Builder internal constructor() { + + private var hasMore: JsonField? = null + private var type: JsonField? = null + private var url: JsonField? = null + private var cursor: JsonField = JsonMissing.of() + private var items: JsonField>? = null + private var nextUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantListResponse: TenantListResponse) = apply { + hasMore = tenantListResponse.hasMore + type = tenantListResponse.type + url = tenantListResponse.url + cursor = tenantListResponse.cursor + items = tenantListResponse.items.map { it.toMutableList() } + nextUrl = tenantListResponse.nextUrl + additionalProperties = tenantListResponse.additionalProperties.toMutableMap() + } + + /** Set to true when there are more pages that can be retrieved. */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + /** Always set to `list`. Represents the type of this object. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A url that may be used to generate these results. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** A pointer to the next page of results. Defined only when `has_more` is set to true */ + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun items(items: List?) = items(JsonField.ofNullable(items)) + + /** Alias for calling [Builder.items] with `items.orElse(null)`. */ + fun items(items: Optional>) = items(items.getOrNull()) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [TenantAssociation] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: TenantAssociation) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * `has_more` is set to true + */ + fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) + + /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ + fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) + + /** + * Sets [Builder.nextUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TenantListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasMore() + * .type() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantListResponse = + TenantListResponse( + checkRequired("hasMore", hasMore), + checkRequired("type", type), + checkRequired("url", url), + cursor, + (items ?: JsonMissing.of()).map { it.toImmutable() }, + nextUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TenantListResponse = apply { + if (validated) { + return@apply + } + + hasMore() + type().validate() + url() + cursor() + items().ifPresent { it.forEach { it.validate() } } + nextUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (hasMore.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextUrl.asKnown().isPresent) 1 else 0) + + /** Always set to `list`. Represents the type of this object. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST = of("list") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + LIST + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST -> Value.LIST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIST -> Known.LIST + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantListResponse && + hasMore == other.hasMore && + type == other.type && + url == other.url && + cursor == other.cursor && + items == other.items && + nextUrl == other.nextUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasMore, type, url, cursor, items, nextUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TenantListResponse{hasMore=$hasMore, type=$type, url=$url, cursor=$cursor, items=$items, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt new file mode 100644 index 00000000..d450f273 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Removes a user from any tenants they may have been associated with. */ +class TenantRemoveAllParams +private constructor( + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TenantRemoveAllParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TenantRemoveAllParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantRemoveAllParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantRemoveAllParams: TenantRemoveAllParams) = apply { + userId = tenantRemoveAllParams.userId + additionalHeaders = tenantRemoveAllParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantRemoveAllParams.additionalQueryParams.toBuilder() + additionalBodyProperties = tenantRemoveAllParams.additionalBodyProperties.toMutableMap() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TenantRemoveAllParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TenantRemoveAllParams = + TenantRemoveAllParams( + userId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantRemoveAllParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "TenantRemoveAllParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt new file mode 100644 index 00000000..771b17c5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Removes a user from the supplied tenant. */ +class TenantRemoveSingleParams +private constructor( + private val userId: String, + private val tenantId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun userId(): String = userId + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TenantRemoveSingleParams]. + * + * The following fields are required: + * ```java + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TenantRemoveSingleParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var tenantId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tenantRemoveSingleParams: TenantRemoveSingleParams) = apply { + userId = tenantRemoveSingleParams.userId + tenantId = tenantRemoveSingleParams.tenantId + additionalHeaders = tenantRemoveSingleParams.additionalHeaders.toBuilder() + additionalQueryParams = tenantRemoveSingleParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + tenantRemoveSingleParams.additionalBodyProperties.toMutableMap() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TenantRemoveSingleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TenantRemoveSingleParams = + TenantRemoveSingleParams( + checkRequired("userId", userId), + tenantId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TenantRemoveSingleParams && + userId == other.userId && + tenantId == other.tenantId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + userId, + tenantId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "TenantRemoveSingleParams{userId=$userId, tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt new file mode 100644 index 00000000..45875576 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Adds multiple tokens to a user and overwrites matching existing tokens. */ +class TokenAddMultipleParams +private constructor( + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TokenAddMultipleParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TokenAddMultipleParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenAddMultipleParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenAddMultipleParams: TokenAddMultipleParams) = apply { + userId = tokenAddMultipleParams.userId + additionalHeaders = tokenAddMultipleParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenAddMultipleParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + tokenAddMultipleParams.additionalBodyProperties.toMutableMap() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TokenAddMultipleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TokenAddMultipleParams = + TokenAddMultipleParams( + userId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenAddMultipleParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "TokenAddMultipleParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt new file mode 100644 index 00000000..404a50fa --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Adds a single token to a user and overwrites a matching existing token. */ +class TokenAddSingleParams +private constructor( + private val userId: String, + private val pathToken: String?, + private val userToken: UserToken, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): String = userId + + fun pathToken(): Optional = Optional.ofNullable(pathToken) + + fun userToken(): UserToken = userToken + + fun _additionalBodyProperties(): Map = userToken._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenAddSingleParams]. + * + * The following fields are required: + * ```java + * .userId() + * .userToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenAddSingleParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var pathToken: String? = null + private var userToken: UserToken? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenAddSingleParams: TokenAddSingleParams) = apply { + userId = tokenAddSingleParams.userId + pathToken = tokenAddSingleParams.pathToken + userToken = tokenAddSingleParams.userToken + additionalHeaders = tokenAddSingleParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenAddSingleParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun pathToken(pathToken: String?) = apply { this.pathToken = pathToken } + + /** Alias for calling [Builder.pathToken] with `pathToken.orElse(null)`. */ + fun pathToken(pathToken: Optional) = pathToken(pathToken.getOrNull()) + + fun userToken(userToken: UserToken) = apply { this.userToken = userToken } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenAddSingleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * .userToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenAddSingleParams = + TokenAddSingleParams( + checkRequired("userId", userId), + pathToken, + checkRequired("userToken", userToken), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): UserToken = userToken + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> pathToken ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenAddSingleParams && + userId == other.userId && + pathToken == other.pathToken && + userToken == other.userToken && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, pathToken, userToken, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenAddSingleParams{userId=$userId, pathToken=$pathToken, userToken=$userToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt new file mode 100644 index 00000000..c4345cfe --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Delete User Token */ +class TokenDeleteParams +private constructor( + private val userId: String, + private val token: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun userId(): String = userId + + fun token(): Optional = Optional.ofNullable(token) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenDeleteParams]. + * + * The following fields are required: + * ```java + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenDeleteParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var token: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenDeleteParams: TokenDeleteParams) = apply { + userId = tokenDeleteParams.userId + token = tokenDeleteParams.token + additionalHeaders = tokenDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = tokenDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun token(token: String?) = apply { this.token = token } + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [TokenDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenDeleteParams = + TokenDeleteParams( + checkRequired("userId", userId), + token, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> token ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenDeleteParams && + userId == other.userId && + token == other.token && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + userId, + token, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "TokenDeleteParams{userId=$userId, token=$token, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt new file mode 100644 index 00000000..31aab221 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Gets all tokens available for a :user_id */ +class TokenListParams +private constructor( + private val userId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): Optional = Optional.ofNullable(userId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TokenListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TokenListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenListParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenListParams: TokenListParams) = apply { + userId = tokenListParams.userId + additionalHeaders = tokenListParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenListParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String?) = apply { this.userId = userId } + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TokenListParams = + TokenListParams(userId, additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenListParams && + userId == other.userId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(userId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenListParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt new file mode 100644 index 00000000..4cb39559 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get single token available for a `:token` */ +class TokenRetrieveSingleParams +private constructor( + private val userId: String, + private val token: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): String = userId + + fun token(): Optional = Optional.ofNullable(token) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenRetrieveSingleParams]. + * + * The following fields are required: + * ```java + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenRetrieveSingleParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var token: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenRetrieveSingleParams: TokenRetrieveSingleParams) = apply { + userId = tokenRetrieveSingleParams.userId + token = tokenRetrieveSingleParams.token + additionalHeaders = tokenRetrieveSingleParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenRetrieveSingleParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun token(token: String?) = apply { this.token = token } + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenRetrieveSingleParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenRetrieveSingleParams = + TokenRetrieveSingleParams( + checkRequired("userId", userId), + token, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> token ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenRetrieveSingleParams && + userId == other.userId && + token == other.token && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, token, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenRetrieveSingleParams{userId=$userId, token=$token, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt new file mode 100644 index 00000000..93319ec8 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt @@ -0,0 +1,616 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TokenRetrieveSingleResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val providerKey: JsonField, + private val token: JsonField, + private val device: JsonField, + private val expiryDate: JsonField, + private val properties: JsonValue, + private val tracking: JsonField, + private val status: JsonField, + private val statusReason: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("provider_key") + @ExcludeMissing + providerKey: JsonField = JsonMissing.of(), + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("device") + @ExcludeMissing + device: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("properties") @ExcludeMissing properties: JsonValue = JsonMissing.of(), + @JsonProperty("tracking") + @ExcludeMissing + tracking: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("status_reason") + @ExcludeMissing + statusReason: JsonField = JsonMissing.of(), + ) : this( + providerKey, + token, + device, + expiryDate, + properties, + tracking, + status, + statusReason, + mutableMapOf(), + ) + + fun toUserToken(): UserToken = + UserToken.builder() + .providerKey(providerKey) + .token(token) + .device(device) + .expiryDate(expiryDate) + .properties(properties) + .tracking(tracking) + .build() + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun providerKey(): UserToken.ProviderKey = providerKey.getRequired("provider_key") + + /** + * Full body of the token. Must match token in URL. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Information about the device the token is associated with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun device(): Optional = device.getOptional("device") + + /** + * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable + * expiration. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryDate(): Optional = expiryDate.getOptional("expiry_date") + + /** Properties sent to the provider along with the token */ + @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties + + /** + * Information about the device the token is associated with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tracking(): Optional = tracking.getOptional("tracking") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * The reason for the token status. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun statusReason(): Optional = statusReason.getOptional("status_reason") + + /** + * Returns the raw JSON value of [providerKey]. + * + * Unlike [providerKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider_key") + @ExcludeMissing + fun _providerKey(): JsonField = providerKey + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [device]. + * + * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device + + /** + * Returns the raw JSON value of [expiryDate]. + * + * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * Returns the raw JSON value of [tracking]. + * + * Unlike [tracking], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tracking") + @ExcludeMissing + fun _tracking(): JsonField = tracking + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [statusReason]. + * + * Unlike [statusReason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status_reason") + @ExcludeMissing + fun _statusReason(): JsonField = statusReason + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenRetrieveSingleResponse]. + * + * The following fields are required: + * ```java + * .providerKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenRetrieveSingleResponse]. */ + class Builder internal constructor() { + + private var providerKey: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var device: JsonField = JsonMissing.of() + private var expiryDate: JsonField = JsonMissing.of() + private var properties: JsonValue = JsonMissing.of() + private var tracking: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var statusReason: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tokenRetrieveSingleResponse: TokenRetrieveSingleResponse) = apply { + providerKey = tokenRetrieveSingleResponse.providerKey + token = tokenRetrieveSingleResponse.token + device = tokenRetrieveSingleResponse.device + expiryDate = tokenRetrieveSingleResponse.expiryDate + properties = tokenRetrieveSingleResponse.properties + tracking = tokenRetrieveSingleResponse.tracking + status = tokenRetrieveSingleResponse.status + statusReason = tokenRetrieveSingleResponse.statusReason + additionalProperties = tokenRetrieveSingleResponse.additionalProperties.toMutableMap() + } + + fun providerKey(providerKey: UserToken.ProviderKey) = providerKey(JsonField.of(providerKey)) + + /** + * Sets [Builder.providerKey] to an arbitrary JSON value. + * + * You should usually call [Builder.providerKey] with a well-typed [UserToken.ProviderKey] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun providerKey(providerKey: JsonField) = apply { + this.providerKey = providerKey + } + + /** Full body of the token. Must match token in URL. */ + fun token(token: String?) = token(JsonField.ofNullable(token)) + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Information about the device the token is associated with. */ + fun device(device: UserToken.Device?) = device(JsonField.ofNullable(device)) + + /** Alias for calling [Builder.device] with `device.orElse(null)`. */ + fun device(device: Optional) = device(device.getOrNull()) + + /** + * Sets [Builder.device] to an arbitrary JSON value. + * + * You should usually call [Builder.device] with a well-typed [UserToken.Device] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun device(device: JsonField) = apply { this.device = device } + + /** + * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable + * expiration. + */ + fun expiryDate(expiryDate: UserToken.ExpiryDate?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + /** Alias for calling [Builder.expiryDate] with `expiryDate.orElse(null)`. */ + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.getOrNull()) + + /** + * Sets [Builder.expiryDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryDate] with a well-typed [UserToken.ExpiryDate] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + /** Alias for calling [expiryDate] with `UserToken.ExpiryDate.ofString(string)`. */ + fun expiryDate(string: String) = expiryDate(UserToken.ExpiryDate.ofString(string)) + + /** Alias for calling [expiryDate] with `UserToken.ExpiryDate.ofBool(bool)`. */ + fun expiryDate(bool: Boolean) = expiryDate(UserToken.ExpiryDate.ofBool(bool)) + + /** Properties sent to the provider along with the token */ + fun properties(properties: JsonValue) = apply { this.properties = properties } + + /** Information about the device the token is associated with. */ + fun tracking(tracking: UserToken.Tracking?) = tracking(JsonField.ofNullable(tracking)) + + /** Alias for calling [Builder.tracking] with `tracking.orElse(null)`. */ + fun tracking(tracking: Optional) = tracking(tracking.getOrNull()) + + /** + * Sets [Builder.tracking] to an arbitrary JSON value. + * + * You should usually call [Builder.tracking] with a well-typed [UserToken.Tracking] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun tracking(tracking: JsonField) = apply { this.tracking = tracking } + + fun status(status: Status?) = status(JsonField.ofNullable(status)) + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.getOrNull()) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** The reason for the token status. */ + fun statusReason(statusReason: String?) = statusReason(JsonField.ofNullable(statusReason)) + + /** Alias for calling [Builder.statusReason] with `statusReason.orElse(null)`. */ + fun statusReason(statusReason: Optional) = statusReason(statusReason.getOrNull()) + + /** + * Sets [Builder.statusReason] to an arbitrary JSON value. + * + * You should usually call [Builder.statusReason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun statusReason(statusReason: JsonField) = apply { + this.statusReason = statusReason + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TokenRetrieveSingleResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .providerKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenRetrieveSingleResponse = + TokenRetrieveSingleResponse( + checkRequired("providerKey", providerKey), + token, + device, + expiryDate, + properties, + tracking, + status, + statusReason, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TokenRetrieveSingleResponse = apply { + if (validated) { + return@apply + } + + providerKey().validate() + token() + device().ifPresent { it.validate() } + expiryDate().ifPresent { it.validate() } + tracking().ifPresent { it.validate() } + status().ifPresent { it.validate() } + statusReason() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (providerKey.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (device.asKnown().getOrNull()?.validity() ?: 0) + + (expiryDate.asKnown().getOrNull()?.validity() ?: 0) + + (tracking.asKnown().getOrNull()?.validity() ?: 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (statusReason.asKnown().isPresent) 1 else 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val UNKNOWN = of("unknown") + + @JvmField val FAILED = of("failed") + + @JvmField val REVOKED = of("revoked") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + ACTIVE, + UNKNOWN, + FAILED, + REVOKED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + UNKNOWN, + FAILED, + REVOKED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + UNKNOWN -> Value.UNKNOWN + FAILED -> Value.FAILED + REVOKED -> Value.REVOKED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + UNKNOWN -> Known.UNKNOWN + FAILED -> Known.FAILED + REVOKED -> Known.REVOKED + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenRetrieveSingleResponse && + providerKey == other.providerKey && + token == other.token && + device == other.device && + expiryDate == other.expiryDate && + properties == other.properties && + tracking == other.tracking && + status == other.status && + statusReason == other.statusReason && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + providerKey, + token, + device, + expiryDate, + properties, + tracking, + status, + statusReason, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TokenRetrieveSingleResponse{providerKey=$providerKey, token=$token, device=$device, expiryDate=$expiryDate, properties=$properties, tracking=$tracking, status=$status, statusReason=$statusReason, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt new file mode 100644 index 00000000..d877bfc5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt @@ -0,0 +1,706 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Apply a JSON Patch (RFC 6902) to the specified token. */ +class TokenUpdateParams +private constructor( + private val userId: String, + private val token: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun userId(): String = userId + + fun token(): Optional = Optional.ofNullable(token) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun patch(): List = body.patch() + + /** + * Returns the raw JSON value of [patch]. + * + * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _patch(): JsonField> = body._patch() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TokenUpdateParams]. + * + * The following fields are required: + * ```java + * .userId() + * .patch() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TokenUpdateParams]. */ + class Builder internal constructor() { + + private var userId: String? = null + private var token: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(tokenUpdateParams: TokenUpdateParams) = apply { + userId = tokenUpdateParams.userId + token = tokenUpdateParams.token + body = tokenUpdateParams.body.toBuilder() + additionalHeaders = tokenUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenUpdateParams.additionalQueryParams.toBuilder() + } + + fun userId(userId: String) = apply { this.userId = userId } + + fun token(token: String?) = apply { this.token = token } + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [patch] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun patch(patch: List) = apply { body.patch(patch) } + + /** + * Sets [Builder.patch] to an arbitrary JSON value. + * + * You should usually call [Builder.patch] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun patch(patch: JsonField>) = apply { body.patch(patch) } + + /** + * Adds a single [Patch] to [Builder.patch]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPatch(patch: Patch) = apply { body.addPatch(patch) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TokenUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .userId() + * .patch() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TokenUpdateParams = + TokenUpdateParams( + checkRequired("userId", userId), + token, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> userId + 1 -> token ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val patch: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("patch") @ExcludeMissing patch: JsonField> = JsonMissing.of() + ) : this(patch, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun patch(): List = patch.getRequired("patch") + + /** + * Returns the raw JSON value of [patch]. + * + * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("patch") @ExcludeMissing fun _patch(): JsonField> = patch + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .patch() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var patch: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + patch = body.patch.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun patch(patch: List) = patch(JsonField.of(patch)) + + /** + * Sets [Builder.patch] to an arbitrary JSON value. + * + * You should usually call [Builder.patch] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun patch(patch: JsonField>) = apply { + this.patch = patch.map { it.toMutableList() } + } + + /** + * Adds a single [Patch] to [Builder.patch]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPatch(patch: Patch) = apply { + this.patch = + (this.patch ?: JsonField.of(mutableListOf())).also { + checkKnown("patch", it).add(patch) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .patch() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("patch", patch).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + patch().forEach { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (patch.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + patch == other.patch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(patch, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{patch=$patch, additionalProperties=$additionalProperties}" + } + + class Patch + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val op: JsonField, + private val path: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("op") @ExcludeMissing op: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(op, path, value, mutableMapOf()) + + /** + * The operation to perform. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun op(): String = op.getRequired("op") + + /** + * The JSON path specifying the part of the profile to operate on. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun path(): String = path.getRequired("path") + + /** + * The value for the operation. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [op]. + * + * Unlike [op], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("op") @ExcludeMissing fun _op(): JsonField = op + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Patch]. + * + * The following fields are required: + * ```java + * .op() + * .path() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Patch]. */ + class Builder internal constructor() { + + private var op: JsonField? = null + private var path: JsonField? = null + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(patch: Patch) = apply { + op = patch.op + path = patch.path + value = patch.value + additionalProperties = patch.additionalProperties.toMutableMap() + } + + /** The operation to perform. */ + fun op(op: String) = op(JsonField.of(op)) + + /** + * Sets [Builder.op] to an arbitrary JSON value. + * + * You should usually call [Builder.op] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun op(op: JsonField) = apply { this.op = op } + + /** The JSON path specifying the part of the profile to operate on. */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + /** The value for the operation. */ + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional) = value(value.getOrNull()) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Patch]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .op() + * .path() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Patch = + Patch( + checkRequired("op", op), + checkRequired("path", path), + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Patch = apply { + if (validated) { + return@apply + } + + op() + path() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (op.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Patch && + op == other.op && + path == other.path && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(op, path, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Patch{op=$op, path=$path, value=$value, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TokenUpdateParams && + userId == other.userId && + token == other.token && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(userId, token, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TokenUpdateParams{userId=$userId, token=$token, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt new file mode 100644 index 00000000..019a8b44 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt @@ -0,0 +1,1309 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UserToken +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val providerKey: JsonField, + private val token: JsonField, + private val device: JsonField, + private val expiryDate: JsonField, + private val properties: JsonValue, + private val tracking: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("provider_key") + @ExcludeMissing + providerKey: JsonField = JsonMissing.of(), + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("device") @ExcludeMissing device: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("properties") @ExcludeMissing properties: JsonValue = JsonMissing.of(), + @JsonProperty("tracking") @ExcludeMissing tracking: JsonField = JsonMissing.of(), + ) : this(providerKey, token, device, expiryDate, properties, tracking, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun providerKey(): ProviderKey = providerKey.getRequired("provider_key") + + /** + * Full body of the token. Must match token in URL. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Information about the device the token is associated with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun device(): Optional = device.getOptional("device") + + /** + * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable + * expiration. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryDate(): Optional = expiryDate.getOptional("expiry_date") + + /** Properties sent to the provider along with the token */ + @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties + + /** + * Information about the device the token is associated with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tracking(): Optional = tracking.getOptional("tracking") + + /** + * Returns the raw JSON value of [providerKey]. + * + * Unlike [providerKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider_key") + @ExcludeMissing + fun _providerKey(): JsonField = providerKey + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [device]. + * + * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device + + /** + * Returns the raw JSON value of [expiryDate]. + * + * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate + + /** + * Returns the raw JSON value of [tracking]. + * + * Unlike [tracking], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tracking") @ExcludeMissing fun _tracking(): JsonField = tracking + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UserToken]. + * + * The following fields are required: + * ```java + * .providerKey() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserToken]. */ + class Builder internal constructor() { + + private var providerKey: JsonField? = null + private var token: JsonField = JsonMissing.of() + private var device: JsonField = JsonMissing.of() + private var expiryDate: JsonField = JsonMissing.of() + private var properties: JsonValue = JsonMissing.of() + private var tracking: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userToken: UserToken) = apply { + providerKey = userToken.providerKey + token = userToken.token + device = userToken.device + expiryDate = userToken.expiryDate + properties = userToken.properties + tracking = userToken.tracking + additionalProperties = userToken.additionalProperties.toMutableMap() + } + + fun providerKey(providerKey: ProviderKey) = providerKey(JsonField.of(providerKey)) + + /** + * Sets [Builder.providerKey] to an arbitrary JSON value. + * + * You should usually call [Builder.providerKey] with a well-typed [ProviderKey] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun providerKey(providerKey: JsonField) = apply { + this.providerKey = providerKey + } + + /** Full body of the token. Must match token in URL. */ + fun token(token: String?) = token(JsonField.ofNullable(token)) + + /** Alias for calling [Builder.token] with `token.orElse(null)`. */ + fun token(token: Optional) = token(token.getOrNull()) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Information about the device the token is associated with. */ + fun device(device: Device?) = device(JsonField.ofNullable(device)) + + /** Alias for calling [Builder.device] with `device.orElse(null)`. */ + fun device(device: Optional) = device(device.getOrNull()) + + /** + * Sets [Builder.device] to an arbitrary JSON value. + * + * You should usually call [Builder.device] with a well-typed [Device] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun device(device: JsonField) = apply { this.device = device } + + /** + * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable + * expiration. + */ + fun expiryDate(expiryDate: ExpiryDate?) = expiryDate(JsonField.ofNullable(expiryDate)) + + /** Alias for calling [Builder.expiryDate] with `expiryDate.orElse(null)`. */ + fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.getOrNull()) + + /** + * Sets [Builder.expiryDate] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryDate] with a well-typed [ExpiryDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } + + /** Alias for calling [expiryDate] with `ExpiryDate.ofString(string)`. */ + fun expiryDate(string: String) = expiryDate(ExpiryDate.ofString(string)) + + /** Alias for calling [expiryDate] with `ExpiryDate.ofBool(bool)`. */ + fun expiryDate(bool: Boolean) = expiryDate(ExpiryDate.ofBool(bool)) + + /** Properties sent to the provider along with the token */ + fun properties(properties: JsonValue) = apply { this.properties = properties } + + /** Information about the device the token is associated with. */ + fun tracking(tracking: Tracking?) = tracking(JsonField.ofNullable(tracking)) + + /** Alias for calling [Builder.tracking] with `tracking.orElse(null)`. */ + fun tracking(tracking: Optional) = tracking(tracking.getOrNull()) + + /** + * Sets [Builder.tracking] to an arbitrary JSON value. + * + * You should usually call [Builder.tracking] with a well-typed [Tracking] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tracking(tracking: JsonField) = apply { this.tracking = tracking } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UserToken]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .providerKey() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UserToken = + UserToken( + checkRequired("providerKey", providerKey), + token, + device, + expiryDate, + properties, + tracking, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UserToken = apply { + if (validated) { + return@apply + } + + providerKey().validate() + token() + device().ifPresent { it.validate() } + expiryDate().ifPresent { it.validate() } + tracking().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (providerKey.asKnown().getOrNull()?.validity() ?: 0) + + (if (token.asKnown().isPresent) 1 else 0) + + (device.asKnown().getOrNull()?.validity() ?: 0) + + (expiryDate.asKnown().getOrNull()?.validity() ?: 0) + + (tracking.asKnown().getOrNull()?.validity() ?: 0) + + class ProviderKey @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FIREBASE_FCM = of("firebase-fcm") + + @JvmField val APN = of("apn") + + @JvmField val EXPO = of("expo") + + @JvmField val ONESIGNAL = of("onesignal") + + @JvmStatic fun of(value: String) = ProviderKey(JsonField.of(value)) + } + + /** An enum containing [ProviderKey]'s known values. */ + enum class Known { + FIREBASE_FCM, + APN, + EXPO, + ONESIGNAL, + } + + /** + * An enum containing [ProviderKey]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ProviderKey] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FIREBASE_FCM, + APN, + EXPO, + ONESIGNAL, + /** + * An enum member indicating that [ProviderKey] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FIREBASE_FCM -> Value.FIREBASE_FCM + APN -> Value.APN + EXPO -> Value.EXPO + ONESIGNAL -> Value.ONESIGNAL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FIREBASE_FCM -> Known.FIREBASE_FCM + APN -> Known.APN + EXPO -> Known.EXPO + ONESIGNAL -> Known.ONESIGNAL + else -> throw CourierInvalidDataException("Unknown ProviderKey: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): ProviderKey = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ProviderKey && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Information about the device the token is associated with. */ + class Device + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val adId: JsonField, + private val appId: JsonField, + private val deviceId: JsonField, + private val manufacturer: JsonField, + private val model: JsonField, + private val platform: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ad_id") @ExcludeMissing adId: JsonField = JsonMissing.of(), + @JsonProperty("app_id") @ExcludeMissing appId: JsonField = JsonMissing.of(), + @JsonProperty("device_id") + @ExcludeMissing + deviceId: JsonField = JsonMissing.of(), + @JsonProperty("manufacturer") + @ExcludeMissing + manufacturer: JsonField = JsonMissing.of(), + @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), + @JsonProperty("platform") @ExcludeMissing platform: JsonField = JsonMissing.of(), + ) : this(adId, appId, deviceId, manufacturer, model, platform, mutableMapOf()) + + /** + * Id of the advertising identifier + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun adId(): Optional = adId.getOptional("ad_id") + + /** + * Id of the application the token is used for + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun appId(): Optional = appId.getOptional("app_id") + + /** + * Id of the device the token is associated with + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceId(): Optional = deviceId.getOptional("device_id") + + /** + * The device manufacturer + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun manufacturer(): Optional = manufacturer.getOptional("manufacturer") + + /** + * The device model + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun model(): Optional = model.getOptional("model") + + /** + * The device platform i.e. android, ios, web + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun platform(): Optional = platform.getOptional("platform") + + /** + * Returns the raw JSON value of [adId]. + * + * Unlike [adId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ad_id") @ExcludeMissing fun _adId(): JsonField = adId + + /** + * Returns the raw JSON value of [appId]. + * + * Unlike [appId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("app_id") @ExcludeMissing fun _appId(): JsonField = appId + + /** + * Returns the raw JSON value of [deviceId]. + * + * Unlike [deviceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("device_id") @ExcludeMissing fun _deviceId(): JsonField = deviceId + + /** + * Returns the raw JSON value of [manufacturer]. + * + * Unlike [manufacturer], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("manufacturer") + @ExcludeMissing + fun _manufacturer(): JsonField = manufacturer + + /** + * Returns the raw JSON value of [model]. + * + * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model + + /** + * Returns the raw JSON value of [platform]. + * + * Unlike [platform], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("platform") @ExcludeMissing fun _platform(): JsonField = platform + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Device]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Device]. */ + class Builder internal constructor() { + + private var adId: JsonField = JsonMissing.of() + private var appId: JsonField = JsonMissing.of() + private var deviceId: JsonField = JsonMissing.of() + private var manufacturer: JsonField = JsonMissing.of() + private var model: JsonField = JsonMissing.of() + private var platform: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(device: Device) = apply { + adId = device.adId + appId = device.appId + deviceId = device.deviceId + manufacturer = device.manufacturer + model = device.model + platform = device.platform + additionalProperties = device.additionalProperties.toMutableMap() + } + + /** Id of the advertising identifier */ + fun adId(adId: String?) = adId(JsonField.ofNullable(adId)) + + /** Alias for calling [Builder.adId] with `adId.orElse(null)`. */ + fun adId(adId: Optional) = adId(adId.getOrNull()) + + /** + * Sets [Builder.adId] to an arbitrary JSON value. + * + * You should usually call [Builder.adId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun adId(adId: JsonField) = apply { this.adId = adId } + + /** Id of the application the token is used for */ + fun appId(appId: String?) = appId(JsonField.ofNullable(appId)) + + /** Alias for calling [Builder.appId] with `appId.orElse(null)`. */ + fun appId(appId: Optional) = appId(appId.getOrNull()) + + /** + * Sets [Builder.appId] to an arbitrary JSON value. + * + * You should usually call [Builder.appId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun appId(appId: JsonField) = apply { this.appId = appId } + + /** Id of the device the token is associated with */ + fun deviceId(deviceId: String?) = deviceId(JsonField.ofNullable(deviceId)) + + /** Alias for calling [Builder.deviceId] with `deviceId.orElse(null)`. */ + fun deviceId(deviceId: Optional) = deviceId(deviceId.getOrNull()) + + /** + * Sets [Builder.deviceId] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deviceId(deviceId: JsonField) = apply { this.deviceId = deviceId } + + /** The device manufacturer */ + fun manufacturer(manufacturer: String?) = + manufacturer(JsonField.ofNullable(manufacturer)) + + /** Alias for calling [Builder.manufacturer] with `manufacturer.orElse(null)`. */ + fun manufacturer(manufacturer: Optional) = + manufacturer(manufacturer.getOrNull()) + + /** + * Sets [Builder.manufacturer] to an arbitrary JSON value. + * + * You should usually call [Builder.manufacturer] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun manufacturer(manufacturer: JsonField) = apply { + this.manufacturer = manufacturer + } + + /** The device model */ + fun model(model: String?) = model(JsonField.ofNullable(model)) + + /** Alias for calling [Builder.model] with `model.orElse(null)`. */ + fun model(model: Optional) = model(model.getOrNull()) + + /** + * Sets [Builder.model] to an arbitrary JSON value. + * + * You should usually call [Builder.model] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun model(model: JsonField) = apply { this.model = model } + + /** The device platform i.e. android, ios, web */ + fun platform(platform: String?) = platform(JsonField.ofNullable(platform)) + + /** Alias for calling [Builder.platform] with `platform.orElse(null)`. */ + fun platform(platform: Optional) = platform(platform.getOrNull()) + + /** + * Sets [Builder.platform] to an arbitrary JSON value. + * + * You should usually call [Builder.platform] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun platform(platform: JsonField) = apply { this.platform = platform } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Device]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Device = + Device( + adId, + appId, + deviceId, + manufacturer, + model, + platform, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Device = apply { + if (validated) { + return@apply + } + + adId() + appId() + deviceId() + manufacturer() + model() + platform() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (adId.asKnown().isPresent) 1 else 0) + + (if (appId.asKnown().isPresent) 1 else 0) + + (if (deviceId.asKnown().isPresent) 1 else 0) + + (if (manufacturer.asKnown().isPresent) 1 else 0) + + (if (model.asKnown().isPresent) 1 else 0) + + (if (platform.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Device && + adId == other.adId && + appId == other.appId && + deviceId == other.deviceId && + manufacturer == other.manufacturer && + model == other.model && + platform == other.platform && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(adId, appId, deviceId, manufacturer, model, platform, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Device{adId=$adId, appId=$appId, deviceId=$deviceId, manufacturer=$manufacturer, model=$model, platform=$platform, additionalProperties=$additionalProperties}" + } + + /** + * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable + * expiration. + */ + @JsonDeserialize(using = ExpiryDate.Deserializer::class) + @JsonSerialize(using = ExpiryDate.Serializer::class) + class ExpiryDate + private constructor( + private val string: String? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ExpiryDate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitBool(bool: Boolean) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExpiryDate && string == other.string && bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, bool) + + override fun toString(): String = + when { + string != null -> "ExpiryDate{string=$string}" + bool != null -> "ExpiryDate{bool=$bool}" + _json != null -> "ExpiryDate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ExpiryDate") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ExpiryDate(string = string) + + @JvmStatic fun ofBool(bool: Boolean) = ExpiryDate(bool = bool) + } + + /** + * An interface that defines how to map each variant of [ExpiryDate] to a value of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [ExpiryDate] to a value of type [T]. + * + * An instance of [ExpiryDate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ExpiryDate: $json") + } + } + + internal class Deserializer : BaseDeserializer(ExpiryDate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ExpiryDate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ExpiryDate(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ExpiryDate(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> ExpiryDate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ExpiryDate::class) { + + override fun serialize( + value: ExpiryDate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ExpiryDate") + } + } + } + } + + /** Information about the device the token is associated with. */ + class Tracking + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val ip: JsonField, + private val lat: JsonField, + private val long_: JsonField, + private val osVersion: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("ip") @ExcludeMissing ip: JsonField = JsonMissing.of(), + @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), + @JsonProperty("long") @ExcludeMissing long_: JsonField = JsonMissing.of(), + @JsonProperty("os_version") + @ExcludeMissing + osVersion: JsonField = JsonMissing.of(), + ) : this(ip, lat, long_, osVersion, mutableMapOf()) + + /** + * The IP address of the device + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ip(): Optional = ip.getOptional("ip") + + /** + * The latitude of the device + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lat(): Optional = lat.getOptional("lat") + + /** + * The longitude of the device + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun long_(): Optional = long_.getOptional("long") + + /** + * The operating system version + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun osVersion(): Optional = osVersion.getOptional("os_version") + + /** + * Returns the raw JSON value of [ip]. + * + * Unlike [ip], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip + + /** + * Returns the raw JSON value of [lat]. + * + * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat + + /** + * Returns the raw JSON value of [long_]. + * + * Unlike [long_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("long") @ExcludeMissing fun _long_(): JsonField = long_ + + /** + * Returns the raw JSON value of [osVersion]. + * + * Unlike [osVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("os_version") @ExcludeMissing fun _osVersion(): JsonField = osVersion + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Tracking]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tracking]. */ + class Builder internal constructor() { + + private var ip: JsonField = JsonMissing.of() + private var lat: JsonField = JsonMissing.of() + private var long_: JsonField = JsonMissing.of() + private var osVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tracking: Tracking) = apply { + ip = tracking.ip + lat = tracking.lat + long_ = tracking.long_ + osVersion = tracking.osVersion + additionalProperties = tracking.additionalProperties.toMutableMap() + } + + /** The IP address of the device */ + fun ip(ip: String?) = ip(JsonField.ofNullable(ip)) + + /** Alias for calling [Builder.ip] with `ip.orElse(null)`. */ + fun ip(ip: Optional) = ip(ip.getOrNull()) + + /** + * Sets [Builder.ip] to an arbitrary JSON value. + * + * You should usually call [Builder.ip] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ip(ip: JsonField) = apply { this.ip = ip } + + /** The latitude of the device */ + fun lat(lat: String?) = lat(JsonField.ofNullable(lat)) + + /** Alias for calling [Builder.lat] with `lat.orElse(null)`. */ + fun lat(lat: Optional) = lat(lat.getOrNull()) + + /** + * Sets [Builder.lat] to an arbitrary JSON value. + * + * You should usually call [Builder.lat] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lat(lat: JsonField) = apply { this.lat = lat } + + /** The longitude of the device */ + fun long_(long_: String?) = long_(JsonField.ofNullable(long_)) + + /** Alias for calling [Builder.long_] with `long_.orElse(null)`. */ + fun long_(long_: Optional) = long_(long_.getOrNull()) + + /** + * Sets [Builder.long_] to an arbitrary JSON value. + * + * You should usually call [Builder.long_] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun long_(long_: JsonField) = apply { this.long_ = long_ } + + /** The operating system version */ + fun osVersion(osVersion: String?) = osVersion(JsonField.ofNullable(osVersion)) + + /** Alias for calling [Builder.osVersion] with `osVersion.orElse(null)`. */ + fun osVersion(osVersion: Optional) = osVersion(osVersion.getOrNull()) + + /** + * Sets [Builder.osVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.osVersion] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun osVersion(osVersion: JsonField) = apply { this.osVersion = osVersion } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tracking]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Tracking = + Tracking(ip, lat, long_, osVersion, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Tracking = apply { + if (validated) { + return@apply + } + + ip() + lat() + long_() + osVersion() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (ip.asKnown().isPresent) 1 else 0) + + (if (lat.asKnown().isPresent) 1 else 0) + + (if (long_.asKnown().isPresent) 1 else 0) + + (if (osVersion.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Tracking && + ip == other.ip && + lat == other.lat && + long_ == other.long_ && + osVersion == other.osVersion && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(ip, lat, long_, osVersion, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tracking{ip=$ip, lat=$lat, long_=$long_, osVersion=$osVersion, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UserToken && + providerKey == other.providerKey && + token == other.token && + device == other.device && + expiryDate == other.expiryDate && + properties == other.properties && + tracking == other.tracking && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + providerKey, + token, + device, + expiryDate, + properties, + tracking, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UserToken{providerKey=$providerKey, token=$token, device=$device, expiryDate=$expiryDate, properties=$properties, tracking=$tracking, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt new file mode 100644 index 00000000..ab8ad68e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt @@ -0,0 +1,389 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.audiences.Audience +import com.courier.api.models.audiences.AudienceDeleteParams +import com.courier.api.models.audiences.AudienceListMembersParams +import com.courier.api.models.audiences.AudienceListMembersResponse +import com.courier.api.models.audiences.AudienceListParams +import com.courier.api.models.audiences.AudienceListResponse +import com.courier.api.models.audiences.AudienceRetrieveParams +import com.courier.api.models.audiences.AudienceUpdateParams +import com.courier.api.models.audiences.AudienceUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AudienceServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudienceServiceAsync + + /** Returns the specified audience by id. */ + fun retrieve(audienceId: String): CompletableFuture = + retrieve(audienceId, AudienceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + ): CompletableFuture = retrieve(audienceId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: AudienceRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(audienceId: String, requestOptions: RequestOptions): CompletableFuture = + retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) + + /** Creates or updates audience. */ + fun update(audienceId: String): CompletableFuture = + update(audienceId, AudienceUpdateParams.none()) + + /** @see update */ + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see update */ + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + ): CompletableFuture = update(audienceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: AudienceUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + audienceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(audienceId, AudienceUpdateParams.none(), requestOptions) + + /** Get the audiences associated with the authorization token. */ + fun list(): CompletableFuture = list(AudienceListParams.none()) + + /** @see list */ + fun list( + params: AudienceListParams = AudienceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: AudienceListParams = AudienceListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AudienceListParams.none(), requestOptions) + + /** Deletes the specified audience. */ + fun delete(audienceId: String): CompletableFuture = + delete(audienceId, AudienceDeleteParams.none()) + + /** @see delete */ + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see delete */ + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + ): CompletableFuture = delete(audienceId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AudienceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: AudienceDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(audienceId: String, requestOptions: RequestOptions): CompletableFuture = + delete(audienceId, AudienceDeleteParams.none(), requestOptions) + + /** Get list of members of an audience. */ + fun listMembers(audienceId: String): CompletableFuture = + listMembers(audienceId, AudienceListMembersParams.none()) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + ): CompletableFuture = + listMembers(audienceId, params, RequestOptions.none()) + + /** @see listMembers */ + fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listMembers */ + fun listMembers( + params: AudienceListMembersParams + ): CompletableFuture = listMembers(params, RequestOptions.none()) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) + + /** + * A view of [AudienceServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AudienceServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /audiences/{audience_id}`, but is otherwise the same + * as [AudienceServiceAsync.retrieve]. + */ + fun retrieve(audienceId: String): CompletableFuture> = + retrieve(audienceId, AudienceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + ): CompletableFuture> = + retrieve(audienceId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve(params: AudienceRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /audiences/{audience_id}`, but is otherwise the same + * as [AudienceServiceAsync.update]. + */ + fun update(audienceId: String): CompletableFuture> = + update(audienceId, AudienceUpdateParams.none()) + + /** @see update */ + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see update */ + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + ): CompletableFuture> = + update(audienceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: AudienceUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + audienceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(audienceId, AudienceUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /audiences`, but is otherwise the same as + * [AudienceServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(AudienceListParams.none()) + + /** @see list */ + fun list( + params: AudienceListParams = AudienceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: AudienceListParams = AudienceListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AudienceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /audiences/{audience_id}`, but is otherwise the + * same as [AudienceServiceAsync.delete]. + */ + fun delete(audienceId: String): CompletableFuture = + delete(audienceId, AudienceDeleteParams.none()) + + /** @see delete */ + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see delete */ + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + ): CompletableFuture = delete(audienceId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: AudienceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: AudienceDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + audienceId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(audienceId, AudienceDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /audiences/{audience_id}/members`, but is otherwise + * the same as [AudienceServiceAsync.listMembers]. + */ + fun listMembers( + audienceId: String + ): CompletableFuture> = + listMembers(audienceId, AudienceListMembersParams.none()) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + ): CompletableFuture> = + listMembers(audienceId, params, RequestOptions.none()) + + /** @see listMembers */ + fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listMembers */ + fun listMembers( + params: AudienceListMembersParams + ): CompletableFuture> = + listMembers(params, RequestOptions.none()) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt new file mode 100644 index 00000000..985db169 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.audiences.Audience +import com.courier.api.models.audiences.AudienceDeleteParams +import com.courier.api.models.audiences.AudienceListMembersParams +import com.courier.api.models.audiences.AudienceListMembersResponse +import com.courier.api.models.audiences.AudienceListParams +import com.courier.api.models.audiences.AudienceListResponse +import com.courier.api.models.audiences.AudienceRetrieveParams +import com.courier.api.models.audiences.AudienceUpdateParams +import com.courier.api.models.audiences.AudienceUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AudienceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AudienceServiceAsync { + + private val withRawResponse: AudienceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AudienceServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AudienceServiceAsync = + AudienceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /audiences/{audience_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /audiences/{audience_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: AudienceListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /audiences + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: AudienceDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /audiences/{audience_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /audiences/{audience_id}/members + withRawResponse().listMembers(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AudienceServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AudienceServiceAsync.WithRawResponse = + AudienceServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AudienceListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: AudienceDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val listMembersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0), "members") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listMembersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt new file mode 100644 index 00000000..769cd892 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.auditevents.AuditEvent +import com.courier.api.models.auditevents.AuditEventListParams +import com.courier.api.models.auditevents.AuditEventListResponse +import com.courier.api.models.auditevents.AuditEventRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AuditEventServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AuditEventServiceAsync + + /** Fetch a specific audit event by ID. */ + fun retrieve(auditEventId: String): CompletableFuture = + retrieve(auditEventId, AuditEventRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + ): CompletableFuture = retrieve(auditEventId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: AuditEventRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) + + /** Fetch the list of audit events */ + fun list(): CompletableFuture = list(AuditEventListParams.none()) + + /** @see list */ + fun list( + params: AuditEventListParams = AuditEventListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: AuditEventListParams = AuditEventListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(AuditEventListParams.none(), requestOptions) + + /** + * A view of [AuditEventServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AuditEventServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /audit-events/{audit-event-id}`, but is otherwise + * the same as [AuditEventServiceAsync.retrieve]. + */ + fun retrieve(auditEventId: String): CompletableFuture> = + retrieve(auditEventId, AuditEventRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + ): CompletableFuture> = + retrieve(auditEventId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: AuditEventRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /audit-events`, but is otherwise the same as + * [AuditEventServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(AuditEventListParams.none()) + + /** @see list */ + fun list( + params: AuditEventListParams = AuditEventListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: AuditEventListParams = AuditEventListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(AuditEventListParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt new file mode 100644 index 00000000..c4e3c20f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.auditevents.AuditEvent +import com.courier.api.models.auditevents.AuditEventListParams +import com.courier.api.models.auditevents.AuditEventListResponse +import com.courier.api.models.auditevents.AuditEventRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AuditEventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AuditEventServiceAsync { + + private val withRawResponse: AuditEventServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AuditEventServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AuditEventServiceAsync = + AuditEventServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /audit-events/{audit-event-id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: AuditEventListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /audit-events + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AuditEventServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AuditEventServiceAsync.WithRawResponse = + AuditEventServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("auditEventId", params.auditEventId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audit-events", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AuditEventListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audit-events") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt new file mode 100644 index 00000000..1f1cd65f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.auth.AuthIssueTokenParams +import com.courier.api.models.auth.AuthIssueTokenResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AuthServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AuthServiceAsync + + /** Returns a new access token. */ + fun issueToken(params: AuthIssueTokenParams): CompletableFuture = + issueToken(params, RequestOptions.none()) + + /** @see issueToken */ + fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [AuthServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AuthServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /auth/issue-token`, but is otherwise the same as + * [AuthServiceAsync.issueToken]. + */ + fun issueToken( + params: AuthIssueTokenParams + ): CompletableFuture> = + issueToken(params, RequestOptions.none()) + + /** @see issueToken */ + fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt new file mode 100644 index 00000000..25242e48 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.auth.AuthIssueTokenParams +import com.courier.api.models.auth.AuthIssueTokenResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AuthServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AuthServiceAsync { + + private val withRawResponse: AuthServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AuthServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AuthServiceAsync = + AuthServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /auth/issue-token + withRawResponse().issueToken(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AuthServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AuthServiceAsync.WithRawResponse = + AuthServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val issueTokenHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("auth", "issue-token") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { issueTokenHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt new file mode 100644 index 00000000..948d0f1e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.automations.AutomationInvokeAdHocParams +import com.courier.api.models.automations.AutomationInvokeByTemplateParams +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.services.async.automations.InvokeServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AutomationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomationServiceAsync + + fun invoke(): InvokeServiceAsync + + /** + * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of + * automation steps. For information about what steps are available, checkout the ad hoc + * automation guide [here](https://www.courier.com/docs/automations/steps/). + */ + fun invokeAdHoc( + params: AutomationInvokeAdHocParams + ): CompletableFuture = invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Invoke an automation run from an automation template. */ + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + ): CompletableFuture = + invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams + ): CompletableFuture = invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [AutomationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AutomationServiceAsync.WithRawResponse + + fun invoke(): InvokeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as + * [AutomationServiceAsync.invokeAdHoc]. + */ + fun invokeAdHoc( + params: AutomationInvokeAdHocParams + ): CompletableFuture> = + invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise + * the same as [AutomationServiceAsync.invokeByTemplate]. + */ + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + ): CompletableFuture> = + invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams + ): CompletableFuture> = + invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt new file mode 100644 index 00000000..3278e90b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt @@ -0,0 +1,142 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.automations.AutomationInvokeAdHocParams +import com.courier.api.models.automations.AutomationInvokeByTemplateParams +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.services.async.automations.InvokeServiceAsync +import com.courier.api.services.async.automations.InvokeServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AutomationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AutomationServiceAsync { + + private val withRawResponse: AutomationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val invoke: InvokeServiceAsync by lazy { InvokeServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): AutomationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AutomationServiceAsync = + AutomationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun invoke(): InvokeServiceAsync = invoke + + override fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /automations/invoke + withRawResponse().invokeAdHoc(params, requestOptions).thenApply { it.parse() } + + override fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /automations/{templateId}/invoke + withRawResponse().invokeByTemplate(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AutomationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val invoke: InvokeServiceAsync.WithRawResponse by lazy { + InvokeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): AutomationServiceAsync.WithRawResponse = + AutomationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun invoke(): InvokeServiceAsync.WithRawResponse = invoke + + private val invokeAdHocHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { invokeAdHocHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val invokeByTemplateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("templateId", params.templateId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", params._pathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { invokeByTemplateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt new file mode 100644 index 00000000..ad4c399f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt @@ -0,0 +1,302 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.brands.Brand +import com.courier.api.models.brands.BrandCreateParams +import com.courier.api.models.brands.BrandDeleteParams +import com.courier.api.models.brands.BrandListParams +import com.courier.api.models.brands.BrandListResponse +import com.courier.api.models.brands.BrandRetrieveParams +import com.courier.api.models.brands.BrandUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BrandServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandServiceAsync + + /** Create a new brand */ + fun create(params: BrandCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: BrandCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Fetch a specific brand by brand ID. */ + fun retrieve(brandId: String): CompletableFuture = + retrieve(brandId, BrandRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + ): CompletableFuture = retrieve(brandId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: BrandRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(brandId: String, requestOptions: RequestOptions): CompletableFuture = + retrieve(brandId, BrandRetrieveParams.none(), requestOptions) + + /** Replace an existing brand with the supplied values. */ + fun update(brandId: String, params: BrandUpdateParams): CompletableFuture = + update(brandId, params, RequestOptions.none()) + + /** @see update */ + fun update( + brandId: String, + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see update */ + fun update(params: BrandUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Get the list of brands. */ + fun list(): CompletableFuture = list(BrandListParams.none()) + + /** @see list */ + fun list( + params: BrandListParams = BrandListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: BrandListParams = BrandListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(BrandListParams.none(), requestOptions) + + /** Delete a brand by brand ID. */ + fun delete(brandId: String): CompletableFuture = + delete(brandId, BrandDeleteParams.none()) + + /** @see delete */ + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see delete */ + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + ): CompletableFuture = delete(brandId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BrandDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: BrandDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(brandId: String, requestOptions: RequestOptions): CompletableFuture = + delete(brandId, BrandDeleteParams.none(), requestOptions) + + /** A view of [BrandServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BrandServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /brands`, but is otherwise the same as + * [BrandServiceAsync.create]. + */ + fun create(params: BrandCreateParams): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: BrandCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /brands/{brand_id}`, but is otherwise the same as + * [BrandServiceAsync.retrieve]. + */ + fun retrieve(brandId: String): CompletableFuture> = + retrieve(brandId, BrandRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + ): CompletableFuture> = + retrieve(brandId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve(params: BrandRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + brandId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(brandId, BrandRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /brands/{brand_id}`, but is otherwise the same as + * [BrandServiceAsync.update]. + */ + fun update( + brandId: String, + params: BrandUpdateParams, + ): CompletableFuture> = + update(brandId, params, RequestOptions.none()) + + /** @see update */ + fun update( + brandId: String, + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see update */ + fun update(params: BrandUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /brands`, but is otherwise the same as + * [BrandServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(BrandListParams.none()) + + /** @see list */ + fun list( + params: BrandListParams = BrandListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: BrandListParams = BrandListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(BrandListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /brands/{brand_id}`, but is otherwise the same as + * [BrandServiceAsync.delete]. + */ + fun delete(brandId: String): CompletableFuture = + delete(brandId, BrandDeleteParams.none()) + + /** @see delete */ + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see delete */ + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + ): CompletableFuture = delete(brandId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: BrandDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: BrandDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + brandId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(brandId, BrandDeleteParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt new file mode 100644 index 00000000..661c84d4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.brands.Brand +import com.courier.api.models.brands.BrandCreateParams +import com.courier.api.models.brands.BrandDeleteParams +import com.courier.api.models.brands.BrandListParams +import com.courier.api.models.brands.BrandListResponse +import com.courier.api.models.brands.BrandRetrieveParams +import com.courier.api.models.brands.BrandUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BrandServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BrandServiceAsync { + + private val withRawResponse: BrandServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BrandServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BrandServiceAsync = + BrandServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: BrandCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /brands + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /brands/{brand_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /brands/{brand_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: BrandListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /brands + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: BrandDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /brands/{brand_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BrandServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BrandServiceAsync.WithRawResponse = + BrandServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: BrandCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("brandId", params.brandId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("brandId", params.brandId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: BrandListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: BrandDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("brandId", params.brandId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt new file mode 100644 index 00000000..76a45a18 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt @@ -0,0 +1,335 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.bulk.BulkAddUsersParams +import com.courier.api.models.bulk.BulkCreateJobParams +import com.courier.api.models.bulk.BulkCreateJobResponse +import com.courier.api.models.bulk.BulkListUsersParams +import com.courier.api.models.bulk.BulkListUsersResponse +import com.courier.api.models.bulk.BulkRetrieveJobParams +import com.courier.api.models.bulk.BulkRetrieveJobResponse +import com.courier.api.models.bulk.BulkRunJobParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BulkServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BulkServiceAsync + + /** Ingest user data into a Bulk Job */ + fun addUsers(jobId: String, params: BulkAddUsersParams): CompletableFuture = + addUsers(jobId, params, RequestOptions.none()) + + /** @see addUsers */ + fun addUsers( + jobId: String, + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see addUsers */ + fun addUsers(params: BulkAddUsersParams): CompletableFuture = + addUsers(params, RequestOptions.none()) + + /** @see addUsers */ + fun addUsers( + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Create a bulk job */ + fun createJob(params: BulkCreateJobParams): CompletableFuture = + createJob(params, RequestOptions.none()) + + /** @see createJob */ + fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Get Bulk Job Users */ + fun listUsers(jobId: String): CompletableFuture = + listUsers(jobId, BulkListUsersParams.none()) + + /** @see listUsers */ + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see listUsers */ + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + ): CompletableFuture = listUsers(jobId, params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listUsers */ + fun listUsers(params: BulkListUsersParams): CompletableFuture = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listUsers(jobId, BulkListUsersParams.none(), requestOptions) + + /** Get a bulk job */ + fun retrieveJob(jobId: String): CompletableFuture = + retrieveJob(jobId, BulkRetrieveJobParams.none()) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + ): CompletableFuture = + retrieveJob(jobId, params, RequestOptions.none()) + + /** @see retrieveJob */ + fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveJob */ + fun retrieveJob(params: BulkRetrieveJobParams): CompletableFuture = + retrieveJob(params, RequestOptions.none()) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) + + /** Run a bulk job */ + fun runJob(jobId: String): CompletableFuture = runJob(jobId, BulkRunJobParams.none()) + + /** @see runJob */ + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see runJob */ + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + ): CompletableFuture = runJob(jobId, params, RequestOptions.none()) + + /** @see runJob */ + fun runJob( + params: BulkRunJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see runJob */ + fun runJob(params: BulkRunJobParams): CompletableFuture = + runJob(params, RequestOptions.none()) + + /** @see runJob */ + fun runJob(jobId: String, requestOptions: RequestOptions): CompletableFuture = + runJob(jobId, BulkRunJobParams.none(), requestOptions) + + /** A view of [BulkServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BulkServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /bulk/{job_id}`, but is otherwise the same as + * [BulkServiceAsync.addUsers]. + */ + fun addUsers(jobId: String, params: BulkAddUsersParams): CompletableFuture = + addUsers(jobId, params, RequestOptions.none()) + + /** @see addUsers */ + fun addUsers( + jobId: String, + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see addUsers */ + fun addUsers(params: BulkAddUsersParams): CompletableFuture = + addUsers(params, RequestOptions.none()) + + /** @see addUsers */ + fun addUsers( + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `post /bulk`, but is otherwise the same as + * [BulkServiceAsync.createJob]. + */ + fun createJob( + params: BulkCreateJobParams + ): CompletableFuture> = + createJob(params, RequestOptions.none()) + + /** @see createJob */ + fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /bulk/{job_id}/users`, but is otherwise the same as + * [BulkServiceAsync.listUsers]. + */ + fun listUsers(jobId: String): CompletableFuture> = + listUsers(jobId, BulkListUsersParams.none()) + + /** @see listUsers */ + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see listUsers */ + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + ): CompletableFuture> = + listUsers(jobId, params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listUsers */ + fun listUsers( + params: BulkListUsersParams + ): CompletableFuture> = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listUsers(jobId, BulkListUsersParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /bulk/{job_id}`, but is otherwise the same as + * [BulkServiceAsync.retrieveJob]. + */ + fun retrieveJob( + jobId: String + ): CompletableFuture> = + retrieveJob(jobId, BulkRetrieveJobParams.none()) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + ): CompletableFuture> = + retrieveJob(jobId, params, RequestOptions.none()) + + /** @see retrieveJob */ + fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveJob */ + fun retrieveJob( + params: BulkRetrieveJobParams + ): CompletableFuture> = + retrieveJob(params, RequestOptions.none()) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /bulk/{job_id}/run`, but is otherwise the same as + * [BulkServiceAsync.runJob]. + */ + fun runJob(jobId: String): CompletableFuture = + runJob(jobId, BulkRunJobParams.none()) + + /** @see runJob */ + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + runJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see runJob */ + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + ): CompletableFuture = runJob(jobId, params, RequestOptions.none()) + + /** @see runJob */ + fun runJob( + params: BulkRunJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see runJob */ + fun runJob(params: BulkRunJobParams): CompletableFuture = + runJob(params, RequestOptions.none()) + + /** @see runJob */ + fun runJob(jobId: String, requestOptions: RequestOptions): CompletableFuture = + runJob(jobId, BulkRunJobParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt new file mode 100644 index 00000000..2dc2defd --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.bulk.BulkAddUsersParams +import com.courier.api.models.bulk.BulkCreateJobParams +import com.courier.api.models.bulk.BulkCreateJobResponse +import com.courier.api.models.bulk.BulkListUsersParams +import com.courier.api.models.bulk.BulkListUsersResponse +import com.courier.api.models.bulk.BulkRetrieveJobParams +import com.courier.api.models.bulk.BulkRetrieveJobResponse +import com.courier.api.models.bulk.BulkRunJobParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BulkServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BulkServiceAsync { + + private val withRawResponse: BulkServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BulkServiceAsync = + BulkServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun addUsers( + params: BulkAddUsersParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /bulk/{job_id} + withRawResponse().addUsers(params, requestOptions).thenAccept {} + + override fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /bulk + withRawResponse().createJob(params, requestOptions).thenApply { it.parse() } + + override fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /bulk/{job_id}/users + withRawResponse().listUsers(params, requestOptions).thenApply { it.parse() } + + override fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /bulk/{job_id} + withRawResponse().retrieveJob(params, requestOptions).thenApply { it.parse() } + + override fun runJob( + params: BulkRunJobParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /bulk/{job_id}/run + withRawResponse().runJob(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BulkServiceAsync.WithRawResponse = + BulkServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val addUsersHandler: Handler = emptyHandler() + + override fun addUsers( + params: BulkAddUsersParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { addUsersHandler.handle(it) } + } + } + } + + private val createJobHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createJobHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listUsersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0), "users") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listUsersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveJobHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveJobHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val runJobHandler: Handler = emptyHandler() + + override fun runJob( + params: BulkRunJobParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0), "run") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { runJobHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt new file mode 100644 index 00000000..9f0c1299 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.inbound.InboundTrackEventParams +import com.courier.api.models.inbound.InboundTrackEventResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InboundServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboundServiceAsync + + /** Courier Track Event */ + fun trackEvent(params: InboundTrackEventParams): CompletableFuture = + trackEvent(params, RequestOptions.none()) + + /** @see trackEvent */ + fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [InboundServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InboundServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /inbound/courier`, but is otherwise the same as + * [InboundServiceAsync.trackEvent]. + */ + fun trackEvent( + params: InboundTrackEventParams + ): CompletableFuture> = + trackEvent(params, RequestOptions.none()) + + /** @see trackEvent */ + fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt new file mode 100644 index 00000000..7bc0b1c6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.inbound.InboundTrackEventParams +import com.courier.api.models.inbound.InboundTrackEventResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class InboundServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InboundServiceAsync { + + private val withRawResponse: InboundServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InboundServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InboundServiceAsync = + InboundServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /inbound/courier + withRawResponse().trackEvent(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InboundServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InboundServiceAsync.WithRawResponse = + InboundServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val trackEventHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("inbound", "courier") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { trackEventHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt new file mode 100644 index 00000000..469f7ca0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.lists.List +import com.courier.api.models.lists.ListDeleteParams +import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListListResponse +import com.courier.api.models.lists.ListRestoreParams +import com.courier.api.models.lists.ListRetrieveParams +import com.courier.api.models.lists.ListUpdateParams +import com.courier.api.services.async.lists.SubscriptionServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ListServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListServiceAsync + + fun subscriptions(): SubscriptionServiceAsync + + /** Returns a list based on the list ID provided. */ + fun retrieve(listId: String): CompletableFuture = + retrieve(listId, ListRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = retrieve(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): CompletableFuture = retrieve(listId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: ListRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(listId: String, requestOptions: RequestOptions): CompletableFuture = + retrieve(listId, ListRetrieveParams.none(), requestOptions) + + /** Create or replace an existing list with the supplied values. */ + fun update(listId: String, params: ListUpdateParams): CompletableFuture = + update(listId, params, RequestOptions.none()) + + /** @see update */ + fun update( + listId: String, + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see update */ + fun update(params: ListUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Returns all of the lists, with the ability to filter based on a pattern. */ + fun list(): CompletableFuture = list(ListListParams.none()) + + /** @see list */ + fun list( + params: ListListParams = ListListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list(params: ListListParams = ListListParams.none()): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(ListListParams.none(), requestOptions) + + /** Delete a list by list ID. */ + fun delete(listId: String): CompletableFuture = delete(listId, ListDeleteParams.none()) + + /** @see delete */ + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see delete */ + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): CompletableFuture = delete(listId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: ListDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(listId: String, requestOptions: RequestOptions): CompletableFuture = + delete(listId, ListDeleteParams.none(), requestOptions) + + /** Restore a previously deleted list. */ + fun restore(listId: String): CompletableFuture = + restore(listId, ListRestoreParams.none()) + + /** @see restore */ + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = restore(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see restore */ + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + ): CompletableFuture = restore(listId, params, RequestOptions.none()) + + /** @see restore */ + fun restore( + params: ListRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see restore */ + fun restore(params: ListRestoreParams): CompletableFuture = + restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore(listId: String, requestOptions: RequestOptions): CompletableFuture = + restore(listId, ListRestoreParams.none(), requestOptions) + + /** A view of [ListServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListServiceAsync.WithRawResponse + + fun subscriptions(): SubscriptionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /lists/{list_id}`, but is otherwise the same as + * [ListServiceAsync.retrieve]. + */ + fun retrieve(listId: String): CompletableFuture> = + retrieve(listId, ListRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): CompletableFuture> = + retrieve(listId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve(params: ListRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + listId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(listId, ListRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /lists/{list_id}`, but is otherwise the same as + * [ListServiceAsync.update]. + */ + fun update( + listId: String, + params: ListUpdateParams, + ): CompletableFuture> = update(listId, params, RequestOptions.none()) + + /** @see update */ + fun update( + listId: String, + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see update */ + fun update(params: ListUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /lists`, but is otherwise the same as + * [ListServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(ListListParams.none()) + + /** @see list */ + fun list( + params: ListListParams = ListListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: ListListParams = ListListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(ListListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /lists/{list_id}`, but is otherwise the same as + * [ListServiceAsync.delete]. + */ + fun delete(listId: String): CompletableFuture = + delete(listId, ListDeleteParams.none()) + + /** @see delete */ + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see delete */ + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): CompletableFuture = delete(listId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: ListDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + listId: String, + requestOptions: RequestOptions, + ): CompletableFuture = delete(listId, ListDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /lists/{list_id}/restore`, but is otherwise the same + * as [ListServiceAsync.restore]. + */ + fun restore(listId: String): CompletableFuture = + restore(listId, ListRestoreParams.none()) + + /** @see restore */ + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + restore(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see restore */ + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + ): CompletableFuture = restore(listId, params, RequestOptions.none()) + + /** @see restore */ + fun restore( + params: ListRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see restore */ + fun restore(params: ListRestoreParams): CompletableFuture = + restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore( + listId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + restore(listId, ListRestoreParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt new file mode 100644 index 00000000..1afe7a8f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt @@ -0,0 +1,254 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.lists.List +import com.courier.api.models.lists.ListDeleteParams +import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListListResponse +import com.courier.api.models.lists.ListRestoreParams +import com.courier.api.models.lists.ListRetrieveParams +import com.courier.api.models.lists.ListUpdateParams +import com.courier.api.services.async.lists.SubscriptionServiceAsync +import com.courier.api.services.async.lists.SubscriptionServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ListServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ListServiceAsync { + + private val withRawResponse: ListServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val subscriptions: SubscriptionServiceAsync by lazy { + SubscriptionServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): ListServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ListServiceAsync = + ListServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun subscriptions(): SubscriptionServiceAsync = subscriptions + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /lists/{list_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ListUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /lists/{list_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: ListListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /lists + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /lists/{list_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun restore( + params: ListRestoreParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /lists/{list_id}/restore + withRawResponse().restore(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ListServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val subscriptions: SubscriptionServiceAsync.WithRawResponse by lazy { + SubscriptionServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): ListServiceAsync.WithRawResponse = + ListServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions + + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ListUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: ListListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val restoreHandler: Handler = emptyHandler() + + override fun restore( + params: ListRestoreParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "restore") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { restoreHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt new file mode 100644 index 00000000..b8cb8b7f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt @@ -0,0 +1,407 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageDetails +import com.courier.api.models.messages.MessageGetContentParams +import com.courier.api.models.messages.MessageGetContentResponse +import com.courier.api.models.messages.MessageHistoryParams +import com.courier.api.models.messages.MessageHistoryResponse +import com.courier.api.models.messages.MessageListParams +import com.courier.api.models.messages.MessageListResponse +import com.courier.api.models.messages.MessageRetrieveParams +import com.courier.api.models.messages.MessageRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MessageServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageServiceAsync + + /** Fetch the status of a message you've previously sent. */ + fun retrieve(messageId: String): CompletableFuture = + retrieve(messageId, MessageRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + ): CompletableFuture = + retrieve(messageId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: MessageRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + + /** Fetch the statuses of messages you've previously sent. */ + fun list(): CompletableFuture = list(MessageListParams.none()) + + /** @see list */ + fun list( + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: MessageListParams = MessageListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(MessageListParams.none(), requestOptions) + + /** + * Cancel a message that is currently in the process of being delivered. A well-formatted API + * call to the cancel message API will return either `200` status code for a successful + * cancellation or `409` status code for an unsuccessful cancellation. Both cases will include + * the actual message record in the response body (see details below). + */ + fun cancel(messageId: String): CompletableFuture = + cancel(messageId, MessageCancelParams.none()) + + /** @see cancel */ + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + ): CompletableFuture = cancel(messageId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: MessageCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(messageId, MessageCancelParams.none(), requestOptions) + + /** Get message content */ + fun getContent(messageId: String): CompletableFuture = + getContent(messageId, MessageGetContentParams.none()) + + /** @see getContent */ + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see getContent */ + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + ): CompletableFuture = + getContent(messageId, params, RequestOptions.none()) + + /** @see getContent */ + fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see getContent */ + fun getContent(params: MessageGetContentParams): CompletableFuture = + getContent(params, RequestOptions.none()) + + /** @see getContent */ + fun getContent( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + getContent(messageId, MessageGetContentParams.none(), requestOptions) + + /** Fetch the array of events of a message you've previously sent. */ + fun history(messageId: String): CompletableFuture = + history(messageId, MessageHistoryParams.none()) + + /** @see history */ + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + history(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see history */ + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + ): CompletableFuture = history(messageId, params, RequestOptions.none()) + + /** @see history */ + fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see history */ + fun history(params: MessageHistoryParams): CompletableFuture = + history(params, RequestOptions.none()) + + /** @see history */ + fun history( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + history(messageId, MessageHistoryParams.none(), requestOptions) + + /** + * A view of [MessageServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): MessageServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /messages/{message_id}`, but is otherwise the same + * as [MessageServiceAsync.retrieve]. + */ + fun retrieve( + messageId: String + ): CompletableFuture> = + retrieve(messageId, MessageRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + ): CompletableFuture> = + retrieve(messageId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: MessageRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /messages`, but is otherwise the same as + * [MessageServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(MessageListParams.none()) + + /** @see list */ + fun list( + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: MessageListParams = MessageListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(MessageListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /messages/{message_id}/cancel`, but is otherwise + * the same as [MessageServiceAsync.cancel]. + */ + fun cancel(messageId: String): CompletableFuture> = + cancel(messageId, MessageCancelParams.none()) + + /** @see cancel */ + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + ): CompletableFuture> = + cancel(messageId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: MessageCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(messageId, MessageCancelParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /messages/{message_id}/output`, but is otherwise the + * same as [MessageServiceAsync.getContent]. + */ + fun getContent( + messageId: String + ): CompletableFuture> = + getContent(messageId, MessageGetContentParams.none()) + + /** @see getContent */ + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see getContent */ + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + ): CompletableFuture> = + getContent(messageId, params, RequestOptions.none()) + + /** @see getContent */ + fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see getContent */ + fun getContent( + params: MessageGetContentParams + ): CompletableFuture> = + getContent(params, RequestOptions.none()) + + /** @see getContent */ + fun getContent( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + getContent(messageId, MessageGetContentParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /messages/{message_id}/history`, but is otherwise + * the same as [MessageServiceAsync.history]. + */ + fun history(messageId: String): CompletableFuture> = + history(messageId, MessageHistoryParams.none()) + + /** @see history */ + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + history(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see history */ + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + ): CompletableFuture> = + history(messageId, params, RequestOptions.none()) + + /** @see history */ + fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see history */ + fun history( + params: MessageHistoryParams + ): CompletableFuture> = + history(params, RequestOptions.none()) + + /** @see history */ + fun history( + messageId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + history(messageId, MessageHistoryParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt new file mode 100644 index 00000000..ad3d38ed --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageDetails +import com.courier.api.models.messages.MessageGetContentParams +import com.courier.api.models.messages.MessageGetContentResponse +import com.courier.api.models.messages.MessageHistoryParams +import com.courier.api.models.messages.MessageHistoryResponse +import com.courier.api.models.messages.MessageListParams +import com.courier.api.models.messages.MessageListResponse +import com.courier.api.models.messages.MessageRetrieveParams +import com.courier.api.models.messages.MessageRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MessageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MessageServiceAsync { + + private val withRawResponse: MessageServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MessageServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): MessageServiceAsync = + MessageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /messages/{message_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: MessageListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /messages + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /messages/{message_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + + override fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /messages/{message_id}/output + withRawResponse().getContent(params, requestOptions).thenApply { it.parse() } + + override fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /messages/{message_id}/history + withRawResponse().history(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MessageServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): MessageServiceAsync.WithRawResponse = + MessageServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: MessageListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getContentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0), "output") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getContentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val historyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0), "history") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { historyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt new file mode 100644 index 00000000..91a3273e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.NotificationListParams +import com.courier.api.models.notifications.NotificationListResponse +import com.courier.api.models.notifications.NotificationRetrieveContentParams +import com.courier.api.services.async.notifications.CheckServiceAsync +import com.courier.api.services.async.notifications.DraftServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface NotificationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NotificationServiceAsync + + fun draft(): DraftServiceAsync + + fun checks(): CheckServiceAsync + + fun list(): CompletableFuture = list(NotificationListParams.none()) + + /** @see list */ + fun list( + params: NotificationListParams = NotificationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: NotificationListParams = NotificationListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(NotificationListParams.none(), requestOptions) + + fun retrieveContent(id: String): CompletableFuture = + retrieveContent(id, NotificationRetrieveContentParams.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + ): CompletableFuture = + retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveContent */ + fun retrieveContent( + params: NotificationRetrieveContentParams + ): CompletableFuture = retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) + + /** + * A view of [NotificationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): NotificationServiceAsync.WithRawResponse + + fun draft(): DraftServiceAsync.WithRawResponse + + fun checks(): CheckServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /notifications`, but is otherwise the same as + * [NotificationServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(NotificationListParams.none()) + + /** @see list */ + fun list( + params: NotificationListParams = NotificationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: NotificationListParams = NotificationListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(NotificationListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /notifications/{id}/content`, but is otherwise the + * same as [NotificationServiceAsync.retrieveContent]. + */ + fun retrieveContent( + id: String + ): CompletableFuture> = + retrieveContent(id, NotificationRetrieveContentParams.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + ): CompletableFuture> = + retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveContent */ + fun retrieveContent( + params: NotificationRetrieveContentParams + ): CompletableFuture> = + retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt new file mode 100644 index 00000000..d35ef296 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt @@ -0,0 +1,152 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.NotificationListParams +import com.courier.api.models.notifications.NotificationListResponse +import com.courier.api.models.notifications.NotificationRetrieveContentParams +import com.courier.api.services.async.notifications.CheckServiceAsync +import com.courier.api.services.async.notifications.CheckServiceAsyncImpl +import com.courier.api.services.async.notifications.DraftServiceAsync +import com.courier.api.services.async.notifications.DraftServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class NotificationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + NotificationServiceAsync { + + private val withRawResponse: NotificationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val draft: DraftServiceAsync by lazy { DraftServiceAsyncImpl(clientOptions) } + + private val checks: CheckServiceAsync by lazy { CheckServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): NotificationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): NotificationServiceAsync = + NotificationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun draft(): DraftServiceAsync = draft + + override fun checks(): CheckServiceAsync = checks + + override fun list( + params: NotificationListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /notifications + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /notifications/{id}/content + withRawResponse().retrieveContent(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NotificationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val draft: DraftServiceAsync.WithRawResponse by lazy { + DraftServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val checks: CheckServiceAsync.WithRawResponse by lazy { + CheckServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): NotificationServiceAsync.WithRawResponse = + NotificationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun draft(): DraftServiceAsync.WithRawResponse = draft + + override fun checks(): CheckServiceAsync.WithRawResponse = checks + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: NotificationListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("notifications") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveContentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("notifications", params._pathParam(0), "content") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveContentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt new file mode 100644 index 00000000..2eb46791 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt @@ -0,0 +1,361 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.profiles.ProfileCreateParams +import com.courier.api.models.profiles.ProfileCreateResponse +import com.courier.api.models.profiles.ProfileDeleteParams +import com.courier.api.models.profiles.ProfileReplaceParams +import com.courier.api.models.profiles.ProfileReplaceResponse +import com.courier.api.models.profiles.ProfileRetrieveParams +import com.courier.api.models.profiles.ProfileRetrieveResponse +import com.courier.api.models.profiles.ProfileUpdateParams +import com.courier.api.services.async.profiles.ListServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ProfileServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProfileServiceAsync + + fun lists(): ListServiceAsync + + /** + * Merge the supplied values with an existing profile or create a new profile if one doesn't + * already exist. + */ + fun create( + userId: String, + params: ProfileCreateParams, + ): CompletableFuture = create(userId, params, RequestOptions.none()) + + /** @see create */ + fun create( + userId: String, + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see create */ + fun create(params: ProfileCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Returns the specified user profile. */ + fun retrieve(userId: String): CompletableFuture = + retrieve(userId, ProfileRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + ): CompletableFuture = retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: ProfileRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(userId, ProfileRetrieveParams.none(), requestOptions) + + /** Update a profile */ + fun update(userId: String, params: ProfileUpdateParams): CompletableFuture = + update(userId, params, RequestOptions.none()) + + /** @see update */ + fun update( + userId: String, + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see update */ + fun update(params: ProfileUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Deletes the specified user profile. */ + fun delete(userId: String): CompletableFuture = + delete(userId, ProfileDeleteParams.none()) + + /** @see delete */ + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + ): CompletableFuture = delete(userId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ProfileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: ProfileDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(userId: String, requestOptions: RequestOptions): CompletableFuture = + delete(userId, ProfileDeleteParams.none(), requestOptions) + + /** + * When using `PUT`, be sure to include all the key-value pairs required by the recipient's + * profile. Any key-value pairs that exist in the profile but fail to be included in the `PUT` + * request will be removed from the profile. Remember, a `PUT` update is a full replacement of + * the data. For partial updates, use the + * [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. + */ + fun replace( + userId: String, + params: ProfileReplaceParams, + ): CompletableFuture = replace(userId, params, RequestOptions.none()) + + /** @see replace */ + fun replace( + userId: String, + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + replace(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see replace */ + fun replace(params: ProfileReplaceParams): CompletableFuture = + replace(params, RequestOptions.none()) + + /** @see replace */ + fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [ProfileServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ProfileServiceAsync.WithRawResponse + + fun lists(): ListServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /profiles/{user_id}`, but is otherwise the same as + * [ProfileServiceAsync.create]. + */ + fun create( + userId: String, + params: ProfileCreateParams, + ): CompletableFuture> = + create(userId, params, RequestOptions.none()) + + /** @see create */ + fun create( + userId: String, + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see create */ + fun create( + params: ProfileCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /profiles/{user_id}`, but is otherwise the same as + * [ProfileServiceAsync.retrieve]. + */ + fun retrieve(userId: String): CompletableFuture> = + retrieve(userId, ProfileRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + ): CompletableFuture> = + retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: ProfileRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(userId, ProfileRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /profiles/{user_id}`, but is otherwise the same as + * [ProfileServiceAsync.update]. + */ + fun update(userId: String, params: ProfileUpdateParams): CompletableFuture = + update(userId, params, RequestOptions.none()) + + /** @see update */ + fun update( + userId: String, + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see update */ + fun update(params: ProfileUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `delete /profiles/{user_id}`, but is otherwise the same + * as [ProfileServiceAsync.delete]. + */ + fun delete(userId: String): CompletableFuture = + delete(userId, ProfileDeleteParams.none()) + + /** @see delete */ + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + ): CompletableFuture = delete(userId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ProfileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: ProfileDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(userId, ProfileDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /profiles/{user_id}`, but is otherwise the same as + * [ProfileServiceAsync.replace]. + */ + fun replace( + userId: String, + params: ProfileReplaceParams, + ): CompletableFuture> = + replace(userId, params, RequestOptions.none()) + + /** @see replace */ + fun replace( + userId: String, + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + replace(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see replace */ + fun replace( + params: ProfileReplaceParams + ): CompletableFuture> = + replace(params, RequestOptions.none()) + + /** @see replace */ + fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt new file mode 100644 index 00000000..7a55ce13 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt @@ -0,0 +1,259 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.profiles.ProfileCreateParams +import com.courier.api.models.profiles.ProfileCreateResponse +import com.courier.api.models.profiles.ProfileDeleteParams +import com.courier.api.models.profiles.ProfileReplaceParams +import com.courier.api.models.profiles.ProfileReplaceResponse +import com.courier.api.models.profiles.ProfileRetrieveParams +import com.courier.api.models.profiles.ProfileRetrieveResponse +import com.courier.api.models.profiles.ProfileUpdateParams +import com.courier.api.services.async.profiles.ListServiceAsync +import com.courier.api.services.async.profiles.ListServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ProfileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ProfileServiceAsync { + + private val withRawResponse: ProfileServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val lists: ListServiceAsync by lazy { ListServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): ProfileServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ProfileServiceAsync = + ProfileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun lists(): ListServiceAsync = lists + + override fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /profiles/{user_id} + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /profiles/{user_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: ProfileUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /profiles/{user_id} + withRawResponse().update(params, requestOptions).thenAccept {} + + override fun delete( + params: ProfileDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /profiles/{user_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /profiles/{user_id} + withRawResponse().replace(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProfileServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val lists: ListServiceAsync.WithRawResponse by lazy { + ListServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): ProfileServiceAsync.WithRawResponse = + ProfileServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun lists(): ListServiceAsync.WithRawResponse = lists + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: ProfileUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: ProfileDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt new file mode 100644 index 00000000..7034b980 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.models.requests.RequestArchiveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface RequestServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestServiceAsync + + /** Archive message */ + fun archive(requestId: String): CompletableFuture = + archive(requestId, RequestArchiveParams.none()) + + /** @see archive */ + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + archive(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see archive */ + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + ): CompletableFuture = archive(requestId, params, RequestOptions.none()) + + /** @see archive */ + fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see archive */ + fun archive(params: RequestArchiveParams): CompletableFuture = + archive(params, RequestOptions.none()) + + /** @see archive */ + fun archive(requestId: String, requestOptions: RequestOptions): CompletableFuture = + archive(requestId, RequestArchiveParams.none(), requestOptions) + + /** + * A view of [RequestServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RequestServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /requests/{request_id}/archive`, but is otherwise + * the same as [RequestServiceAsync.archive]. + */ + fun archive(requestId: String): CompletableFuture = + archive(requestId, RequestArchiveParams.none()) + + /** @see archive */ + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + archive(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see archive */ + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + ): CompletableFuture = archive(requestId, params, RequestOptions.none()) + + /** @see archive */ + fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see archive */ + fun archive(params: RequestArchiveParams): CompletableFuture = + archive(params, RequestOptions.none()) + + /** @see archive */ + fun archive( + requestId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + archive(requestId, RequestArchiveParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt new file mode 100644 index 00000000..acd685d4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.requests.RequestArchiveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RequestServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + RequestServiceAsync { + + private val withRawResponse: RequestServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RequestServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RequestServiceAsync = + RequestServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /requests/{request_id}/archive + withRawResponse().archive(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RequestServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RequestServiceAsync.WithRawResponse = + RequestServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val archiveHandler: Handler = emptyHandler() + + override fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("requestId", params.requestId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("requests", params._pathParam(0), "archive") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { archiveHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt new file mode 100644 index 00000000..6e194a5c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SendServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SendServiceAsync + + /** Use the send API to send a message to one or more recipients. */ + fun sendMessage(params: SendSendMessageParams): CompletableFuture = + sendMessage(params, RequestOptions.none()) + + /** @see sendMessage */ + fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [SendServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SendServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /send`, but is otherwise the same as + * [SendServiceAsync.sendMessage]. + */ + fun sendMessage( + params: SendSendMessageParams + ): CompletableFuture> = + sendMessage(params, RequestOptions.none()) + + /** @see sendMessage */ + fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt new file mode 100644 index 00000000..67cf12db --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class SendServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SendServiceAsync { + + private val withRawResponse: SendServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SendServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SendServiceAsync = + SendServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /send + withRawResponse().sendMessage(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SendServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SendServiceAsync.WithRawResponse = + SendServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val sendMessageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("send") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { sendMessageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt new file mode 100644 index 00000000..5af8249b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.tenants.Tenant +import com.courier.api.models.tenants.TenantDeleteParams +import com.courier.api.models.tenants.TenantListParams +import com.courier.api.models.tenants.TenantListResponse +import com.courier.api.models.tenants.TenantListUsersParams +import com.courier.api.models.tenants.TenantListUsersResponse +import com.courier.api.models.tenants.TenantRetrieveParams +import com.courier.api.models.tenants.TenantUpdateParams +import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TenantServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TenantServiceAsync + + fun defaultPreferences(): DefaultPreferenceServiceAsync + + /** Get a Tenant */ + fun retrieve(tenantId: String): CompletableFuture = + retrieve(tenantId, TenantRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + ): CompletableFuture = retrieve(tenantId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: TenantRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(tenantId: String, requestOptions: RequestOptions): CompletableFuture = + retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) + + /** Create or Replace a Tenant */ + fun update(tenantId: String, params: TenantUpdateParams): CompletableFuture = + update(tenantId, params, RequestOptions.none()) + + /** @see update */ + fun update( + tenantId: String, + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see update */ + fun update(params: TenantUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Get a List of Tenants */ + fun list(): CompletableFuture = list(TenantListParams.none()) + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(TenantListParams.none(), requestOptions) + + /** Delete a Tenant */ + fun delete(tenantId: String): CompletableFuture = + delete(tenantId, TenantDeleteParams.none()) + + /** @see delete */ + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see delete */ + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + ): CompletableFuture = delete(tenantId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TenantDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: TenantDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(tenantId: String, requestOptions: RequestOptions): CompletableFuture = + delete(tenantId, TenantDeleteParams.none(), requestOptions) + + /** Get Users in Tenant */ + fun listUsers(tenantId: String): CompletableFuture = + listUsers(tenantId, TenantListUsersParams.none()) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + ): CompletableFuture = + listUsers(tenantId, params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listUsers */ + fun listUsers(params: TenantListUsersParams): CompletableFuture = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + listUsers(tenantId, TenantListUsersParams.none(), requestOptions) + + /** + * A view of [TenantServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TenantServiceAsync.WithRawResponse + + fun defaultPreferences(): DefaultPreferenceServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}`, but is otherwise the same as + * [TenantServiceAsync.retrieve]. + */ + fun retrieve(tenantId: String): CompletableFuture> = + retrieve(tenantId, TenantRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + ): CompletableFuture> = + retrieve(tenantId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve(params: TenantRetrieveParams): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /tenants/{tenant_id}`, but is otherwise the same as + * [TenantServiceAsync.update]. + */ + fun update( + tenantId: String, + params: TenantUpdateParams, + ): CompletableFuture> = + update(tenantId, params, RequestOptions.none()) + + /** @see update */ + fun update( + tenantId: String, + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see update */ + fun update(params: TenantUpdateParams): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /tenants`, but is otherwise the same as + * [TenantServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(TenantListParams.none()) + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(TenantListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /tenants/{tenant_id}`, but is otherwise the same + * as [TenantServiceAsync.delete]. + */ + fun delete(tenantId: String): CompletableFuture = + delete(tenantId, TenantDeleteParams.none()) + + /** @see delete */ + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see delete */ + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + ): CompletableFuture = delete(tenantId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TenantDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: TenantDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + tenantId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(tenantId, TenantDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}/users`, but is otherwise the + * same as [TenantServiceAsync.listUsers]. + */ + fun listUsers( + tenantId: String + ): CompletableFuture> = + listUsers(tenantId, TenantListUsersParams.none()) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + ): CompletableFuture> = + listUsers(tenantId, params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listUsers */ + fun listUsers( + params: TenantListUsersParams + ): CompletableFuture> = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + listUsers(tenantId, TenantListUsersParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt new file mode 100644 index 00000000..750709d0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.tenants.Tenant +import com.courier.api.models.tenants.TenantDeleteParams +import com.courier.api.models.tenants.TenantListParams +import com.courier.api.models.tenants.TenantListResponse +import com.courier.api.models.tenants.TenantListUsersParams +import com.courier.api.models.tenants.TenantListUsersResponse +import com.courier.api.models.tenants.TenantRetrieveParams +import com.courier.api.models.tenants.TenantUpdateParams +import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsync +import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TenantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TenantServiceAsync { + + private val withRawResponse: TenantServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val defaultPreferences: DefaultPreferenceServiceAsync by lazy { + DefaultPreferenceServiceAsyncImpl(clientOptions) + } + + override fun withRawResponse(): TenantServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TenantServiceAsync = + TenantServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun defaultPreferences(): DefaultPreferenceServiceAsync = defaultPreferences + + override fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /tenants/{tenant_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /tenants/{tenant_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /tenants + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: TenantDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /tenants/{tenant_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /tenants/{tenant_id}/users + withRawResponse().listUsers(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TenantServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val defaultPreferences: DefaultPreferenceServiceAsync.WithRawResponse by lazy { + DefaultPreferenceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): TenantServiceAsync.WithRawResponse = + TenantServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun defaultPreferences(): DefaultPreferenceServiceAsync.WithRawResponse = + defaultPreferences + + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: TenantDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val listUsersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0), "users") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listUsersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt new file mode 100644 index 00000000..656926cd --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt @@ -0,0 +1,142 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.translations.TranslationRetrieveParams +import com.courier.api.models.translations.TranslationUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TranslationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranslationServiceAsync + + /** Get translations by locale */ + fun retrieve(locale: String, params: TranslationRetrieveParams): CompletableFuture = + retrieve(locale, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + locale: String, + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TranslationRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Update a translation */ + fun update(locale: String, params: TranslationUpdateParams): CompletableFuture = + update(locale, params, RequestOptions.none()) + + /** @see update */ + fun update( + locale: String, + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see update */ + fun update(params: TranslationUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [TranslationServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranslationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /translations/{domain}/{locale}`, but is otherwise + * the same as [TranslationServiceAsync.retrieve]. + */ + fun retrieve( + locale: String, + params: TranslationRetrieveParams, + ): CompletableFuture> = + retrieve(locale, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + locale: String, + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: TranslationRetrieveParams + ): CompletableFuture> = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /translations/{domain}/{locale}`, but is otherwise + * the same as [TranslationServiceAsync.update]. + */ + fun update( + locale: String, + params: TranslationUpdateParams, + ): CompletableFuture = update(locale, params, RequestOptions.none()) + + /** @see update */ + fun update( + locale: String, + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see update */ + fun update(params: TranslationUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt new file mode 100644 index 00000000..dc89350c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.stringHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.translations.TranslationRetrieveParams +import com.courier.api.models.translations.TranslationUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TranslationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TranslationServiceAsync { + + private val withRawResponse: TranslationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TranslationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TranslationServiceAsync = + TranslationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /translations/{domain}/{locale} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /translations/{domain}/{locale} + withRawResponse().update(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TranslationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TranslationServiceAsync.WithRawResponse = + TranslationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = stringHandler() + + override fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("locale", params.locale().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { retrieveHandler.handle(it) } + } + } + } + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("locale", params.locale().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt new file mode 100644 index 00000000..d1cf7a26 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.services.async.users.PreferenceServiceAsync +import com.courier.api.services.async.users.TenantServiceAsync +import com.courier.api.services.async.users.TokenServiceAsync +import java.util.function.Consumer + +interface UserServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserServiceAsync + + fun preferences(): PreferenceServiceAsync + + fun tenants(): TenantServiceAsync + + fun tokens(): TokenServiceAsync + + /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserServiceAsync.WithRawResponse + + fun preferences(): PreferenceServiceAsync.WithRawResponse + + fun tenants(): TenantServiceAsync.WithRawResponse + + fun tokens(): TokenServiceAsync.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt new file mode 100644 index 00000000..16f4a2d3 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.core.ClientOptions +import com.courier.api.services.async.users.PreferenceServiceAsync +import com.courier.api.services.async.users.PreferenceServiceAsyncImpl +import com.courier.api.services.async.users.TenantServiceAsync +import com.courier.api.services.async.users.TenantServiceAsyncImpl +import com.courier.api.services.async.users.TokenServiceAsync +import com.courier.api.services.async.users.TokenServiceAsyncImpl +import java.util.function.Consumer + +class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync { + + private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val preferences: PreferenceServiceAsync by lazy { + PreferenceServiceAsyncImpl(clientOptions) + } + + private val tenants: TenantServiceAsync by lazy { TenantServiceAsyncImpl(clientOptions) } + + private val tokens: TokenServiceAsync by lazy { TokenServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UserServiceAsync = + UserServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun preferences(): PreferenceServiceAsync = preferences + + override fun tenants(): TenantServiceAsync = tenants + + override fun tokens(): TokenServiceAsync = tokens + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserServiceAsync.WithRawResponse { + + private val preferences: PreferenceServiceAsync.WithRawResponse by lazy { + PreferenceServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tenants: TenantServiceAsync.WithRawResponse by lazy { + TenantServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val tokens: TokenServiceAsync.WithRawResponse by lazy { + TokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): UserServiceAsync.WithRawResponse = + UserServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun preferences(): PreferenceServiceAsync.WithRawResponse = preferences + + override fun tenants(): TenantServiceAsync.WithRawResponse = tenants + + override fun tokens(): TokenServiceAsync.WithRawResponse = tokens + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt new file mode 100644 index 00000000..7885bbed --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.automations + +import com.courier.api.core.ClientOptions +import java.util.function.Consumer + +interface InvokeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InvokeServiceAsync + + /** + * A view of [InvokeServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InvokeServiceAsync.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt new file mode 100644 index 00000000..ee9fe041 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.automations + +import com.courier.api.core.ClientOptions +import java.util.function.Consumer + +class InvokeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InvokeServiceAsync { + + private val withRawResponse: InvokeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InvokeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InvokeServiceAsync = + InvokeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvokeServiceAsync.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): InvokeServiceAsync.WithRawResponse = + InvokeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt new file mode 100644 index 00000000..956ebf8a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt @@ -0,0 +1,331 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.lists + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.lists.subscriptions.SubscriptionAddParams +import com.courier.api.models.lists.subscriptions.SubscriptionListParams +import com.courier.api.models.lists.subscriptions.SubscriptionListResponse +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams +import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SubscriptionServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SubscriptionServiceAsync + + /** Get the list's subscriptions. */ + fun list(listId: String): CompletableFuture = + list(listId, SubscriptionListParams.none()) + + /** @see list */ + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see list */ + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + ): CompletableFuture = list(listId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list(params: SubscriptionListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + listId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(listId, SubscriptionListParams.none(), requestOptions) + + /** + * Subscribes additional users to the list, without modifying existing subscriptions. If the + * list does not exist, it will be automatically created. + */ + fun add(listId: String, params: SubscriptionAddParams): CompletableFuture = + add(listId, params, RequestOptions.none()) + + /** @see add */ + fun add( + listId: String, + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = add(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see add */ + fun add(params: SubscriptionAddParams): CompletableFuture = + add(params, RequestOptions.none()) + + /** @see add */ + fun add( + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Subscribes the users to the list, overwriting existing subscriptions. If the list does not + * exist, it will be automatically created. + */ + fun subscribe(listId: String, params: SubscriptionSubscribeParams): CompletableFuture = + subscribe(listId, params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + listId: String, + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + subscribe(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see subscribe */ + fun subscribe(params: SubscriptionSubscribeParams): CompletableFuture = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Subscribe a user to an existing list (note: if the List does not exist, it will be + * automatically created). + */ + fun subscribeUser( + userId: String, + params: SubscriptionSubscribeUserParams, + ): CompletableFuture = subscribeUser(userId, params, RequestOptions.none()) + + /** @see subscribeUser */ + fun subscribeUser( + userId: String, + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribeUser */ + fun subscribeUser(params: SubscriptionSubscribeUserParams): CompletableFuture = + subscribeUser(params, RequestOptions.none()) + + /** @see subscribeUser */ + fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Delete a subscription to a list by list ID and user ID. */ + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + ): CompletableFuture = unsubscribeUser(userId, params, RequestOptions.none()) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see unsubscribeUser */ + fun unsubscribeUser(params: SubscriptionUnsubscribeUserParams): CompletableFuture = + unsubscribeUser(params, RequestOptions.none()) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [SubscriptionServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SubscriptionServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /lists/{list_id}/subscriptions`, but is otherwise + * the same as [SubscriptionServiceAsync.list]. + */ + fun list(listId: String): CompletableFuture> = + list(listId, SubscriptionListParams.none()) + + /** @see list */ + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see list */ + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + ): CompletableFuture> = + list(listId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: SubscriptionListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + listId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(listId, SubscriptionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /lists/{list_id}/subscriptions`, but is otherwise + * the same as [SubscriptionServiceAsync.add]. + */ + fun add(listId: String, params: SubscriptionAddParams): CompletableFuture = + add(listId, params, RequestOptions.none()) + + /** @see add */ + fun add( + listId: String, + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + add(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see add */ + fun add(params: SubscriptionAddParams): CompletableFuture = + add(params, RequestOptions.none()) + + /** @see add */ + fun add( + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions`, but is otherwise + * the same as [SubscriptionServiceAsync.subscribe]. + */ + fun subscribe( + listId: String, + params: SubscriptionSubscribeParams, + ): CompletableFuture = subscribe(listId, params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + listId: String, + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + subscribe(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see subscribe */ + fun subscribe(params: SubscriptionSubscribeParams): CompletableFuture = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions/{user_id}`, but is + * otherwise the same as [SubscriptionServiceAsync.subscribeUser]. + */ + fun subscribeUser( + userId: String, + params: SubscriptionSubscribeUserParams, + ): CompletableFuture = subscribeUser(userId, params, RequestOptions.none()) + + /** @see subscribeUser */ + fun subscribeUser( + userId: String, + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribeUser */ + fun subscribeUser( + params: SubscriptionSubscribeUserParams + ): CompletableFuture = subscribeUser(params, RequestOptions.none()) + + /** @see subscribeUser */ + fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `delete /lists/{list_id}/subscriptions/{user_id}`, but is + * otherwise the same as [SubscriptionServiceAsync.unsubscribeUser]. + */ + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + ): CompletableFuture = unsubscribeUser(userId, params, RequestOptions.none()) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams + ): CompletableFuture = unsubscribeUser(params, RequestOptions.none()) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt new file mode 100644 index 00000000..f6740caa --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.lists + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.lists.subscriptions.SubscriptionAddParams +import com.courier.api.models.lists.subscriptions.SubscriptionListParams +import com.courier.api.models.lists.subscriptions.SubscriptionListResponse +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams +import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionServiceAsync { + + private val withRawResponse: SubscriptionServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SubscriptionServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SubscriptionServiceAsync = + SubscriptionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /lists/{list_id}/subscriptions + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun add( + params: SubscriptionAddParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /lists/{list_id}/subscriptions + withRawResponse().add(params, requestOptions).thenAccept {} + + override fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /lists/{list_id}/subscriptions + withRawResponse().subscribe(params, requestOptions).thenAccept {} + + override fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /lists/{list_id}/subscriptions/{user_id} + withRawResponse().subscribeUser(params, requestOptions).thenAccept {} + + override fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /lists/{list_id}/subscriptions/{user_id} + withRawResponse().unsubscribeUser(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SubscriptionServiceAsync.WithRawResponse = + SubscriptionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "subscriptions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val addHandler: Handler = emptyHandler() + + override fun add( + params: SubscriptionAddParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "subscriptions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { addHandler.handle(it) } + } + } + } + + private val subscribeHandler: Handler = emptyHandler() + + override fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "subscriptions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { subscribeHandler.handle(it) } + } + } + } + + private val subscribeUserHandler: Handler = emptyHandler() + + override fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "lists", + params._pathParam(0), + "subscriptions", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { subscribeUserHandler.handle(it) } + } + } + } + + private val unsubscribeUserHandler: Handler = emptyHandler() + + override fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "lists", + params._pathParam(0), + "subscriptions", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { unsubscribeUserHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt new file mode 100644 index 00000000..4999a60e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.notifications.checks.CheckDeleteParams +import com.courier.api.models.notifications.checks.CheckListParams +import com.courier.api.models.notifications.checks.CheckListResponse +import com.courier.api.models.notifications.checks.CheckUpdateParams +import com.courier.api.models.notifications.checks.CheckUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CheckServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckServiceAsync + + fun update( + submissionId: String, + params: CheckUpdateParams, + ): CompletableFuture = update(submissionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + submissionId: String, + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see update */ + fun update(params: CheckUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + fun list(submissionId: String, params: CheckListParams): CompletableFuture = + list(submissionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + submissionId: String, + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see list */ + fun list(params: CheckListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + fun delete(submissionId: String, params: CheckDeleteParams): CompletableFuture = + delete(submissionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + submissionId: String, + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see delete */ + fun delete(params: CheckDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [CheckServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CheckServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put /notifications/{id}/{submissionId}/checks`, but is + * otherwise the same as [CheckServiceAsync.update]. + */ + fun update( + submissionId: String, + params: CheckUpdateParams, + ): CompletableFuture> = + update(submissionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + submissionId: String, + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see update */ + fun update( + params: CheckUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /notifications/{id}/{submissionId}/checks`, but is + * otherwise the same as [CheckServiceAsync.list]. + */ + fun list( + submissionId: String, + params: CheckListParams, + ): CompletableFuture> = + list(submissionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + submissionId: String, + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see list */ + fun list(params: CheckListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `delete /notifications/{id}/{submissionId}/checks`, but + * is otherwise the same as [CheckServiceAsync.delete]. + */ + fun delete( + submissionId: String, + params: CheckDeleteParams, + ): CompletableFuture = delete(submissionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + submissionId: String, + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see delete */ + fun delete(params: CheckDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt new file mode 100644 index 00000000..dc7c63b4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt @@ -0,0 +1,184 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.notifications.checks.CheckDeleteParams +import com.courier.api.models.notifications.checks.CheckListParams +import com.courier.api.models.notifications.checks.CheckListResponse +import com.courier.api.models.notifications.checks.CheckUpdateParams +import com.courier.api.models.notifications.checks.CheckUpdateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CheckServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CheckServiceAsync { + + private val withRawResponse: CheckServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CheckServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CheckServiceAsync = + CheckServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /notifications/{id}/{submissionId}/checks + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: CheckListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /notifications/{id}/{submissionId}/checks + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: CheckDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /notifications/{id}/{submissionId}/checks + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CheckServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CheckServiceAsync.WithRawResponse = + CheckServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("submissionId", params.submissionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "notifications", + params._pathParam(0), + params._pathParam(1), + "checks", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CheckListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("submissionId", params.submissionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "notifications", + params._pathParam(0), + params._pathParam(1), + "checks", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: CheckDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("submissionId", params.submissionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "notifications", + params._pathParam(0), + params._pathParam(1), + "checks", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt new file mode 100644 index 00000000..b0e47a1d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.draft.DraftRetrieveContentParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface DraftServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DraftServiceAsync + + fun retrieveContent(id: String): CompletableFuture = + retrieveContent(id, DraftRetrieveContentParams.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + ): CompletableFuture = + retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieveContent */ + fun retrieveContent( + params: DraftRetrieveContentParams + ): CompletableFuture = retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) + + /** A view of [DraftServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DraftServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /notifications/{id}/draft/content`, but is otherwise + * the same as [DraftServiceAsync.retrieveContent]. + */ + fun retrieveContent( + id: String + ): CompletableFuture> = + retrieveContent(id, DraftRetrieveContentParams.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + ): CompletableFuture> = + retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieveContent */ + fun retrieveContent( + params: DraftRetrieveContentParams + ): CompletableFuture> = + retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt new file mode 100644 index 00000000..ea4dc0c9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.draft.DraftRetrieveContentParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DraftServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + DraftServiceAsync { + + private val withRawResponse: DraftServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DraftServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DraftServiceAsync = + DraftServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /notifications/{id}/draft/content + withRawResponse().retrieveContent(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DraftServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DraftServiceAsync.WithRawResponse = + DraftServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveContentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("notifications", params._pathParam(0), "draft", "content") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveContentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt new file mode 100644 index 00000000..b0cd0fc1 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.profiles + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.profiles.lists.ListDeleteParams +import com.courier.api.models.profiles.lists.ListDeleteResponse +import com.courier.api.models.profiles.lists.ListRetrieveParams +import com.courier.api.models.profiles.lists.ListRetrieveResponse +import com.courier.api.models.profiles.lists.ListSubscribeParams +import com.courier.api.models.profiles.lists.ListSubscribeResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ListServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListServiceAsync + + /** Returns the subscribed lists for a specified user. */ + fun retrieve(userId: String): CompletableFuture = + retrieve(userId, ListRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): CompletableFuture = retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: ListRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(userId, ListRetrieveParams.none(), requestOptions) + + /** Removes all list subscriptions for given user. */ + fun delete(userId: String): CompletableFuture = + delete(userId, ListDeleteParams.none()) + + /** @see delete */ + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): CompletableFuture = delete(userId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: ListDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(userId, ListDeleteParams.none(), requestOptions) + + /** + * Subscribes the given user to one or more lists. If the list does not exist, it will be + * created. + */ + fun subscribe( + userId: String, + params: ListSubscribeParams, + ): CompletableFuture = subscribe(userId, params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + userId: String, + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + subscribe(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribe */ + fun subscribe(params: ListSubscribeParams): CompletableFuture = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [ListServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /profiles/{user_id}/lists`, but is otherwise the + * same as [ListServiceAsync.retrieve]. + */ + fun retrieve(userId: String): CompletableFuture> = + retrieve(userId, ListRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): CompletableFuture> = + retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(userId, ListRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /profiles/{user_id}/lists`, but is otherwise the + * same as [ListServiceAsync.delete]. + */ + fun delete(userId: String): CompletableFuture> = + delete(userId, ListDeleteParams.none()) + + /** @see delete */ + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): CompletableFuture> = + delete(userId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see delete */ + fun delete( + params: ListDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(userId, ListDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /profiles/{user_id}/lists`, but is otherwise the + * same as [ListServiceAsync.subscribe]. + */ + fun subscribe( + userId: String, + params: ListSubscribeParams, + ): CompletableFuture> = + subscribe(userId, params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + userId: String, + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + subscribe(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribe */ + fun subscribe( + params: ListSubscribeParams + ): CompletableFuture> = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt new file mode 100644 index 00000000..335501eb --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.profiles + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.profiles.lists.ListDeleteParams +import com.courier.api.models.profiles.lists.ListDeleteResponse +import com.courier.api.models.profiles.lists.ListRetrieveParams +import com.courier.api.models.profiles.lists.ListRetrieveResponse +import com.courier.api.models.profiles.lists.ListSubscribeParams +import com.courier.api.models.profiles.lists.ListSubscribeResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ListServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ListServiceAsync { + + private val withRawResponse: ListServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ListServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ListServiceAsync = + ListServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /profiles/{user_id}/lists + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /profiles/{user_id}/lists + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /profiles/{user_id}/lists + withRawResponse().subscribe(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ListServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ListServiceAsync.WithRawResponse = + ListServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0), "lists") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0), "lists") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val subscribeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0), "lists") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { subscribeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt new file mode 100644 index 00000000..84205cef --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.services.async.tenants.defaultpreferences.ItemServiceAsync +import java.util.function.Consumer + +interface DefaultPreferenceServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DefaultPreferenceServiceAsync + + fun items(): ItemServiceAsync + + /** + * A view of [DefaultPreferenceServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DefaultPreferenceServiceAsync.WithRawResponse + + fun items(): ItemServiceAsync.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt new file mode 100644 index 00000000..aaf7b742 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.services.async.tenants.defaultpreferences.ItemServiceAsync +import com.courier.api.services.async.tenants.defaultpreferences.ItemServiceAsyncImpl +import java.util.function.Consumer + +class DefaultPreferenceServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : DefaultPreferenceServiceAsync { + + private val withRawResponse: DefaultPreferenceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val items: ItemServiceAsync by lazy { ItemServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): DefaultPreferenceServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): DefaultPreferenceServiceAsync = + DefaultPreferenceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun items(): ItemServiceAsync = items + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DefaultPreferenceServiceAsync.WithRawResponse { + + private val items: ItemServiceAsync.WithRawResponse by lazy { + ItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): DefaultPreferenceServiceAsync.WithRawResponse = + DefaultPreferenceServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun items(): ItemServiceAsync.WithRawResponse = items + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt new file mode 100644 index 00000000..61f6939b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants.defaultpreferences + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams +import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ItemServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemServiceAsync + + /** Create or Replace Default Preferences For Topic */ + fun update(topicId: String, params: ItemUpdateParams): CompletableFuture = + update(topicId, params, RequestOptions.none()) + + /** @see update */ + fun update( + topicId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see update */ + fun update(params: ItemUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Remove Default Preferences For Topic */ + fun delete(topicId: String, params: ItemDeleteParams): CompletableFuture = + delete(topicId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + topicId: String, + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ItemDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [ItemServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `put + * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as + * [ItemServiceAsync.update]. + */ + fun update(topicId: String, params: ItemUpdateParams): CompletableFuture = + update(topicId, params, RequestOptions.none()) + + /** @see update */ + fun update( + topicId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see update */ + fun update(params: ItemUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `delete + * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as + * [ItemServiceAsync.delete]. + */ + fun delete(topicId: String, params: ItemDeleteParams): CompletableFuture = + delete(topicId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + topicId: String, + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ItemDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt new file mode 100644 index 00000000..5c23862e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants.defaultpreferences + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams +import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ItemServiceAsync { + + private val withRawResponse: ItemServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ItemServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ItemServiceAsync = + ItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /tenants/{tenant_id}/default_preferences/items/{topic_id} + withRawResponse().update(params, requestOptions).thenAccept {} + + override fun delete( + params: ItemDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /tenants/{tenant_id}/default_preferences/items/{topic_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ItemServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ItemServiceAsync.WithRawResponse = + ItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "tenants", + params._pathParam(0), + "default_preferences", + "items", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: ItemDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "tenants", + params._pathParam(0), + "default_preferences", + "items", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt new file mode 100644 index 00000000..2dc74c2c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.users.preferences.PreferenceRetrieveParams +import com.courier.api.models.users.preferences.PreferenceRetrieveResponse +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface PreferenceServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PreferenceServiceAsync + + /** Fetch all user preferences. */ + fun retrieve(userId: String): CompletableFuture = + retrieve(userId, PreferenceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + ): CompletableFuture = + retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: PreferenceRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) + + /** Fetch user preferences for a specific subscription topic. */ + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + ): CompletableFuture = + retrieveTopic(topicId, params, RequestOptions.none()) + + /** @see retrieveTopic */ + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see retrieveTopic */ + fun retrieveTopic( + params: PreferenceRetrieveTopicParams + ): CompletableFuture = + retrieveTopic(params, RequestOptions.none()) + + /** @see retrieveTopic */ + fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Update or Create user preferences for a specific subscription topic. */ + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + ): CompletableFuture = + updateOrCreateTopic(topicId, params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams + ): CompletableFuture = + updateOrCreateTopic(params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [PreferenceServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PreferenceServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /users/{user_id}/preferences`, but is otherwise the + * same as [PreferenceServiceAsync.retrieve]. + */ + fun retrieve( + userId: String + ): CompletableFuture> = + retrieve(userId, PreferenceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + ): CompletableFuture> = + retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: PreferenceRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /users/{user_id}/preferences/{topic_id}`, but is + * otherwise the same as [PreferenceServiceAsync.retrieveTopic]. + */ + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + ): CompletableFuture> = + retrieveTopic(topicId, params, RequestOptions.none()) + + /** @see retrieveTopic */ + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see retrieveTopic */ + fun retrieveTopic( + params: PreferenceRetrieveTopicParams + ): CompletableFuture> = + retrieveTopic(params, RequestOptions.none()) + + /** @see retrieveTopic */ + fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `put /users/{user_id}/preferences/{topic_id}`, but is + * otherwise the same as [PreferenceServiceAsync.updateOrCreateTopic]. + */ + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + ): CompletableFuture> = + updateOrCreateTopic(topicId, params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams + ): CompletableFuture> = + updateOrCreateTopic(params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt new file mode 100644 index 00000000..1684d06d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt @@ -0,0 +1,185 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.users.preferences.PreferenceRetrieveParams +import com.courier.api.models.users.preferences.PreferenceRetrieveResponse +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PreferenceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + PreferenceServiceAsync { + + private val withRawResponse: PreferenceServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PreferenceServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): PreferenceServiceAsync = + PreferenceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /users/{user_id}/preferences + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /users/{user_id}/preferences/{topic_id} + withRawResponse().retrieveTopic(params, requestOptions).thenApply { it.parse() } + + override fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /users/{user_id}/preferences/{topic_id} + withRawResponse().updateOrCreateTopic(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PreferenceServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): PreferenceServiceAsync.WithRawResponse = + PreferenceServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "preferences") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveTopicHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "users", + params._pathParam(0), + "preferences", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveTopicHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateOrCreateTopicHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "users", + params._pathParam(0), + "preferences", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateOrCreateTopicHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt new file mode 100644 index 00000000..ccf0bb85 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt @@ -0,0 +1,345 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.users.tenants.TenantAddMultipleParams +import com.courier.api.models.users.tenants.TenantAddSingleParams +import com.courier.api.models.users.tenants.TenantListParams +import com.courier.api.models.users.tenants.TenantListResponse +import com.courier.api.models.users.tenants.TenantRemoveAllParams +import com.courier.api.models.users.tenants.TenantRemoveSingleParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TenantServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TenantServiceAsync + + /** Returns a paginated list of user tenant associations. */ + fun list(userId: String): CompletableFuture = + list(userId, TenantListParams.none()) + + /** @see list */ + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + ): CompletableFuture = list(userId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TenantListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list(params: TenantListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = list(userId, TenantListParams.none(), requestOptions) + + /** + * This endpoint is used to add a user to multiple tenants in one call. A custom profile can + * also be supplied for each tenant. This profile will be merged with the user's main profile + * when sending to the user with that tenant. + */ + fun addMultiple(userId: String, params: TenantAddMultipleParams): CompletableFuture = + addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + fun addMultiple(params: TenantAddMultipleParams): CompletableFuture = + addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * This endpoint is used to add a single tenant. + * + * A custom profile can also be supplied with the tenant. This profile will be merged with the + * user's main profile when sending to the user with that tenant. + */ + fun addSingle(tenantId: String, params: TenantAddSingleParams): CompletableFuture = + addSingle(tenantId, params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + tenantId: String, + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see addSingle */ + fun addSingle(params: TenantAddSingleParams): CompletableFuture = + addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Removes a user from any tenants they may have been associated with. */ + fun removeAll(userId: String): CompletableFuture = + removeAll(userId, TenantRemoveAllParams.none()) + + /** @see removeAll */ + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + removeAll(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see removeAll */ + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + ): CompletableFuture = removeAll(userId, params, RequestOptions.none()) + + /** @see removeAll */ + fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see removeAll */ + fun removeAll(params: TenantRemoveAllParams): CompletableFuture = + removeAll(params, RequestOptions.none()) + + /** @see removeAll */ + fun removeAll(userId: String, requestOptions: RequestOptions): CompletableFuture = + removeAll(userId, TenantRemoveAllParams.none(), requestOptions) + + /** Removes a user from the supplied tenant. */ + fun removeSingle(tenantId: String, params: TenantRemoveSingleParams): CompletableFuture = + removeSingle(tenantId, params, RequestOptions.none()) + + /** @see removeSingle */ + fun removeSingle( + tenantId: String, + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see removeSingle */ + fun removeSingle(params: TenantRemoveSingleParams): CompletableFuture = + removeSingle(params, RequestOptions.none()) + + /** @see removeSingle */ + fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [TenantServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TenantServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /users/{user_id}/tenants`, but is otherwise the same + * as [TenantServiceAsync.list]. + */ + fun list(userId: String): CompletableFuture> = + list(userId, TenantListParams.none()) + + /** @see list */ + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + ): CompletableFuture> = + list(userId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TenantListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list(params: TenantListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(userId, TenantListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tenants`, but is otherwise the same + * as [TenantServiceAsync.addMultiple]. + */ + fun addMultiple( + userId: String, + params: TenantAddMultipleParams, + ): CompletableFuture = addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + fun addMultiple(params: TenantAddMultipleParams): CompletableFuture = + addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tenants/{tenant_id}`, but is + * otherwise the same as [TenantServiceAsync.addSingle]. + */ + fun addSingle( + tenantId: String, + params: TenantAddSingleParams, + ): CompletableFuture = addSingle(tenantId, params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + tenantId: String, + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see addSingle */ + fun addSingle(params: TenantAddSingleParams): CompletableFuture = + addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `delete /users/{user_id}/tenants`, but is otherwise the + * same as [TenantServiceAsync.removeAll]. + */ + fun removeAll(userId: String): CompletableFuture = + removeAll(userId, TenantRemoveAllParams.none()) + + /** @see removeAll */ + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + removeAll(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see removeAll */ + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + ): CompletableFuture = removeAll(userId, params, RequestOptions.none()) + + /** @see removeAll */ + fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see removeAll */ + fun removeAll(params: TenantRemoveAllParams): CompletableFuture = + removeAll(params, RequestOptions.none()) + + /** @see removeAll */ + fun removeAll( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + removeAll(userId, TenantRemoveAllParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /users/{user_id}/tenants/{tenant_id}`, but is + * otherwise the same as [TenantServiceAsync.removeSingle]. + */ + fun removeSingle( + tenantId: String, + params: TenantRemoveSingleParams, + ): CompletableFuture = removeSingle(tenantId, params, RequestOptions.none()) + + /** @see removeSingle */ + fun removeSingle( + tenantId: String, + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see removeSingle */ + fun removeSingle(params: TenantRemoveSingleParams): CompletableFuture = + removeSingle(params, RequestOptions.none()) + + /** @see removeSingle */ + fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt new file mode 100644 index 00000000..4387c7b2 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt @@ -0,0 +1,231 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.users.tenants.TenantAddMultipleParams +import com.courier.api.models.users.tenants.TenantAddSingleParams +import com.courier.api.models.users.tenants.TenantListParams +import com.courier.api.models.users.tenants.TenantListResponse +import com.courier.api.models.users.tenants.TenantRemoveAllParams +import com.courier.api.models.users.tenants.TenantRemoveSingleParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TenantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TenantServiceAsync { + + private val withRawResponse: TenantServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TenantServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TenantServiceAsync = + TenantServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /users/{user_id}/tenants + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /users/{user_id}/tenants + withRawResponse().addMultiple(params, requestOptions).thenAccept {} + + override fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /users/{user_id}/tenants/{tenant_id} + withRawResponse().addSingle(params, requestOptions).thenAccept {} + + override fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /users/{user_id}/tenants + withRawResponse().removeAll(params, requestOptions).thenAccept {} + + override fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /users/{user_id}/tenants/{tenant_id} + withRawResponse().removeSingle(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TenantServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TenantServiceAsync.WithRawResponse = + TenantServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val addMultipleHandler: Handler = emptyHandler() + + override fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { addMultipleHandler.handle(it) } + } + } + } + + private val addSingleHandler: Handler = emptyHandler() + + override fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { addSingleHandler.handle(it) } + } + } + } + + private val removeAllHandler: Handler = emptyHandler() + + override fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { removeAllHandler.handle(it) } + } + } + } + + private val removeSingleHandler: Handler = emptyHandler() + + override fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { removeSingleHandler.handle(it) } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt new file mode 100644 index 00000000..d0dac405 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.users.tokens.TokenAddMultipleParams +import com.courier.api.models.users.tokens.TokenAddSingleParams +import com.courier.api.models.users.tokens.TokenDeleteParams +import com.courier.api.models.users.tokens.TokenListParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenUpdateParams +import com.courier.api.models.users.tokens.UserToken +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TokenServiceAsync + + /** Apply a JSON Patch (RFC 6902) to the specified token. */ + fun update(token: String, params: TokenUpdateParams): CompletableFuture = + update(token, params, RequestOptions.none()) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + fun update(params: TokenUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Gets all tokens available for a :user_id */ + fun list(userId: String): CompletableFuture> = + list(userId, TokenListParams.none()) + + /** @see list */ + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + ): CompletableFuture> = list(userId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list(params: TokenListParams): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(userId: String, requestOptions: RequestOptions): CompletableFuture> = + list(userId, TokenListParams.none(), requestOptions) + + /** Delete User Token */ + fun delete(token: String, params: TokenDeleteParams): CompletableFuture = + delete(token, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + token: String, + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = delete(params.toBuilder().token(token).build(), requestOptions) + + /** @see delete */ + fun delete(params: TokenDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Adds multiple tokens to a user and overwrites matching existing tokens. */ + fun addMultiple(userId: String): CompletableFuture = + addMultiple(userId, TokenAddMultipleParams.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + ): CompletableFuture = addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see addMultiple */ + fun addMultiple(params: TokenAddMultipleParams): CompletableFuture = + addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple(userId: String, requestOptions: RequestOptions): CompletableFuture = + addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) + + /** Adds a single token to a user and overwrites a matching existing token. */ + fun addSingle(pathToken: String, params: TokenAddSingleParams): CompletableFuture = + addSingle(pathToken, params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + pathToken: String, + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) + + /** @see addSingle */ + fun addSingle(params: TokenAddSingleParams): CompletableFuture = + addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Get single token available for a `:token` */ + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + ): CompletableFuture = + retrieveSingle(token, params, RequestOptions.none()) + + /** @see retrieveSingle */ + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieveSingle(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieveSingle */ + fun retrieveSingle( + params: TokenRetrieveSingleParams + ): CompletableFuture = + retrieveSingle(params, RequestOptions.none()) + + /** @see retrieveSingle */ + fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [TokenServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenServiceAsync.update]. + */ + fun update(token: String, params: TokenUpdateParams): CompletableFuture = + update(token, params, RequestOptions.none()) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + fun update(params: TokenUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `get /users/{user_id}/tokens`, but is otherwise the same + * as [TokenServiceAsync.list]. + */ + fun list(userId: String): CompletableFuture>> = + list(userId, TokenListParams.none()) + + /** @see list */ + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> = + list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + ): CompletableFuture>> = + list(userId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list(params: TokenListParams): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture>> = + list(userId, TokenListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /users/{user_id}/tokens/{token}`, but is + * otherwise the same as [TokenServiceAsync.delete]. + */ + fun delete(token: String, params: TokenDeleteParams): CompletableFuture = + delete(token, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + token: String, + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().token(token).build(), requestOptions) + + /** @see delete */ + fun delete(params: TokenDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tokens`, but is otherwise the same + * as [TokenServiceAsync.addMultiple]. + */ + fun addMultiple(userId: String): CompletableFuture = + addMultiple(userId, TokenAddMultipleParams.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + ): CompletableFuture = addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see addMultiple */ + fun addMultiple(params: TokenAddMultipleParams): CompletableFuture = + addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenServiceAsync.addSingle]. + */ + fun addSingle( + pathToken: String, + params: TokenAddSingleParams, + ): CompletableFuture = addSingle(pathToken, params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + pathToken: String, + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) + + /** @see addSingle */ + fun addSingle(params: TokenAddSingleParams): CompletableFuture = + addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenServiceAsync.retrieveSingle]. + */ + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + ): CompletableFuture> = + retrieveSingle(token, params, RequestOptions.none()) + + /** @see retrieveSingle */ + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieveSingle(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieveSingle */ + fun retrieveSingle( + params: TokenRetrieveSingleParams + ): CompletableFuture> = + retrieveSingle(params, RequestOptions.none()) + + /** @see retrieveSingle */ + fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt new file mode 100644 index 00000000..8cb2ca26 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.users.tokens.TokenAddMultipleParams +import com.courier.api.models.users.tokens.TokenAddSingleParams +import com.courier.api.models.users.tokens.TokenDeleteParams +import com.courier.api.models.users.tokens.TokenListParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenUpdateParams +import com.courier.api.models.users.tokens.UserToken +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TokenServiceAsync { + + private val withRawResponse: TokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TokenServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TokenServiceAsync = + TokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // patch /users/{user_id}/tokens/{token} + withRawResponse().update(params, requestOptions).thenAccept {} + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /users/{user_id}/tokens + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: TokenDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /users/{user_id}/tokens/{token} + withRawResponse().delete(params, requestOptions).thenAccept {} + + override fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /users/{user_id}/tokens + withRawResponse().addMultiple(params, requestOptions).thenAccept {} + + override fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /users/{user_id}/tokens/{token} + withRawResponse().addSingle(params, requestOptions).thenAccept {} + + override fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /users/{user_id}/tokens/{token} + withRawResponse().retrieveSingle(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TokenServiceAsync.WithRawResponse = + TokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + } + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: TokenDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + + private val addMultipleHandler: Handler = emptyHandler() + + override fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { addMultipleHandler.handle(it) } + } + } + } + + private val addSingleHandler: Handler = emptyHandler() + + override fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("pathToken", params.pathToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { addSingleHandler.handle(it) } + } + } + } + + private val retrieveSingleHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveSingleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt new file mode 100644 index 00000000..3f264962 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt @@ -0,0 +1,382 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.audiences.Audience +import com.courier.api.models.audiences.AudienceDeleteParams +import com.courier.api.models.audiences.AudienceListMembersParams +import com.courier.api.models.audiences.AudienceListMembersResponse +import com.courier.api.models.audiences.AudienceListParams +import com.courier.api.models.audiences.AudienceListResponse +import com.courier.api.models.audiences.AudienceRetrieveParams +import com.courier.api.models.audiences.AudienceUpdateParams +import com.courier.api.models.audiences.AudienceUpdateResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface AudienceService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudienceService + + /** Returns the specified audience by id. */ + fun retrieve(audienceId: String): Audience = retrieve(audienceId, AudienceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Audience = retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + ): Audience = retrieve(audienceId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Audience + + /** @see retrieve */ + fun retrieve(params: AudienceRetrieveParams): Audience = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(audienceId: String, requestOptions: RequestOptions): Audience = + retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) + + /** Creates or updates audience. */ + fun update(audienceId: String): AudienceUpdateResponse = + update(audienceId, AudienceUpdateParams.none()) + + /** @see update */ + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AudienceUpdateResponse = + update(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see update */ + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + ): AudienceUpdateResponse = update(audienceId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AudienceUpdateResponse + + /** @see update */ + fun update(params: AudienceUpdateParams): AudienceUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(audienceId: String, requestOptions: RequestOptions): AudienceUpdateResponse = + update(audienceId, AudienceUpdateParams.none(), requestOptions) + + /** Get the audiences associated with the authorization token. */ + fun list(): AudienceListResponse = list(AudienceListParams.none()) + + /** @see list */ + fun list( + params: AudienceListParams = AudienceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AudienceListResponse + + /** @see list */ + fun list(params: AudienceListParams = AudienceListParams.none()): AudienceListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): AudienceListResponse = + list(AudienceListParams.none(), requestOptions) + + /** Deletes the specified audience. */ + fun delete(audienceId: String) = delete(audienceId, AudienceDeleteParams.none()) + + /** @see delete */ + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see delete */ + fun delete(audienceId: String, params: AudienceDeleteParams = AudienceDeleteParams.none()) = + delete(audienceId, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: AudienceDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: AudienceDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(audienceId: String, requestOptions: RequestOptions) = + delete(audienceId, AudienceDeleteParams.none(), requestOptions) + + /** Get list of members of an audience. */ + fun listMembers(audienceId: String): AudienceListMembersResponse = + listMembers(audienceId, AudienceListMembersParams.none()) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AudienceListMembersResponse = + listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + ): AudienceListMembersResponse = listMembers(audienceId, params, RequestOptions.none()) + + /** @see listMembers */ + fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AudienceListMembersResponse + + /** @see listMembers */ + fun listMembers(params: AudienceListMembersParams): AudienceListMembersResponse = + listMembers(params, RequestOptions.none()) + + /** @see listMembers */ + fun listMembers( + audienceId: String, + requestOptions: RequestOptions, + ): AudienceListMembersResponse = + listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) + + /** A view of [AudienceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AudienceService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /audiences/{audience_id}`, but is otherwise the same + * as [AudienceService.retrieve]. + */ + @MustBeClosed + fun retrieve(audienceId: String): HttpResponseFor = + retrieve(audienceId, AudienceRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + audienceId: String, + params: AudienceRetrieveParams = AudienceRetrieveParams.none(), + ): HttpResponseFor = retrieve(audienceId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: AudienceRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + audienceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /audiences/{audience_id}`, but is otherwise the same + * as [AudienceService.update]. + */ + @MustBeClosed + fun update(audienceId: String): HttpResponseFor = + update(audienceId, AudienceUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + audienceId: String, + params: AudienceUpdateParams = AudienceUpdateParams.none(), + ): HttpResponseFor = + update(audienceId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: AudienceUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + audienceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(audienceId, AudienceUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /audiences`, but is otherwise the same as + * [AudienceService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(AudienceListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: AudienceListParams = AudienceListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: AudienceListParams = AudienceListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(AudienceListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /audiences/{audience_id}`, but is otherwise the + * same as [AudienceService.delete]. + */ + @MustBeClosed + fun delete(audienceId: String): HttpResponse = + delete(audienceId, AudienceDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + audienceId: String, + params: AudienceDeleteParams = AudienceDeleteParams.none(), + ): HttpResponse = delete(audienceId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: AudienceDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: AudienceDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(audienceId: String, requestOptions: RequestOptions): HttpResponse = + delete(audienceId, AudienceDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /audiences/{audience_id}/members`, but is otherwise + * the same as [AudienceService.listMembers]. + */ + @MustBeClosed + fun listMembers(audienceId: String): HttpResponseFor = + listMembers(audienceId, AudienceListMembersParams.none()) + + /** @see listMembers */ + @MustBeClosed + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) + + /** @see listMembers */ + @MustBeClosed + fun listMembers( + audienceId: String, + params: AudienceListMembersParams = AudienceListMembersParams.none(), + ): HttpResponseFor = + listMembers(audienceId, params, RequestOptions.none()) + + /** @see listMembers */ + @MustBeClosed + fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listMembers */ + @MustBeClosed + fun listMembers( + params: AudienceListMembersParams + ): HttpResponseFor = listMembers(params, RequestOptions.none()) + + /** @see listMembers */ + @MustBeClosed + fun listMembers( + audienceId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt new file mode 100644 index 00000000..9237a544 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.audiences.Audience +import com.courier.api.models.audiences.AudienceDeleteParams +import com.courier.api.models.audiences.AudienceListMembersParams +import com.courier.api.models.audiences.AudienceListMembersResponse +import com.courier.api.models.audiences.AudienceListParams +import com.courier.api.models.audiences.AudienceListResponse +import com.courier.api.models.audiences.AudienceRetrieveParams +import com.courier.api.models.audiences.AudienceUpdateParams +import com.courier.api.models.audiences.AudienceUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AudienceServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AudienceService { + + private val withRawResponse: AudienceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AudienceService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AudienceService = + AudienceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions, + ): Audience = + // get /audiences/{audience_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions, + ): AudienceUpdateResponse = + // put /audiences/{audience_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: AudienceListParams, + requestOptions: RequestOptions, + ): AudienceListResponse = + // get /audiences + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: AudienceDeleteParams, requestOptions: RequestOptions) { + // delete /audiences/{audience_id} + withRawResponse().delete(params, requestOptions) + } + + override fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions, + ): AudienceListMembersResponse = + // get /audiences/{audience_id}/members + withRawResponse().listMembers(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AudienceService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AudienceService.WithRawResponse = + AudienceServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: AudienceRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: AudienceUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AudienceListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: AudienceDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val listMembersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listMembers( + params: AudienceListMembersParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("audienceId", params.audienceId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audiences", params._pathParam(0), "members") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listMembersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt new file mode 100644 index 00000000..e3cc33a9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.auditevents.AuditEvent +import com.courier.api.models.auditevents.AuditEventListParams +import com.courier.api.models.auditevents.AuditEventListResponse +import com.courier.api.models.auditevents.AuditEventRetrieveParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface AuditEventService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AuditEventService + + /** Fetch a specific audit event by ID. */ + fun retrieve(auditEventId: String): AuditEvent = + retrieve(auditEventId, AuditEventRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AuditEvent = retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + ): AuditEvent = retrieve(auditEventId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AuditEvent + + /** @see retrieve */ + fun retrieve(params: AuditEventRetrieveParams): AuditEvent = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(auditEventId: String, requestOptions: RequestOptions): AuditEvent = + retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) + + /** Fetch the list of audit events */ + fun list(): AuditEventListResponse = list(AuditEventListParams.none()) + + /** @see list */ + fun list( + params: AuditEventListParams = AuditEventListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AuditEventListResponse + + /** @see list */ + fun list(params: AuditEventListParams = AuditEventListParams.none()): AuditEventListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): AuditEventListResponse = + list(AuditEventListParams.none(), requestOptions) + + /** A view of [AuditEventService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AuditEventService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /audit-events/{audit-event-id}`, but is otherwise + * the same as [AuditEventService.retrieve]. + */ + @MustBeClosed + fun retrieve(auditEventId: String): HttpResponseFor = + retrieve(auditEventId, AuditEventRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + auditEventId: String, + params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), + ): HttpResponseFor = retrieve(auditEventId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: AuditEventRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + auditEventId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /audit-events`, but is otherwise the same as + * [AuditEventService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(AuditEventListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: AuditEventListParams = AuditEventListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: AuditEventListParams = AuditEventListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(AuditEventListParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt new file mode 100644 index 00000000..16b2e8f8 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.auditevents.AuditEvent +import com.courier.api.models.auditevents.AuditEventListParams +import com.courier.api.models.auditevents.AuditEventListResponse +import com.courier.api.models.auditevents.AuditEventRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AuditEventServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AuditEventService { + + private val withRawResponse: AuditEventService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AuditEventService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AuditEventService = + AuditEventServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions, + ): AuditEvent = + // get /audit-events/{audit-event-id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: AuditEventListParams, + requestOptions: RequestOptions, + ): AuditEventListResponse = + // get /audit-events + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AuditEventService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AuditEventService.WithRawResponse = + AuditEventServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: AuditEventRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("auditEventId", params.auditEventId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audit-events", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: AuditEventListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("audit-events") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt new file mode 100644 index 00000000..e7e40d3d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.auth.AuthIssueTokenParams +import com.courier.api.models.auth.AuthIssueTokenResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface AuthService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AuthService + + /** Returns a new access token. */ + fun issueToken(params: AuthIssueTokenParams): AuthIssueTokenResponse = + issueToken(params, RequestOptions.none()) + + /** @see issueToken */ + fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AuthIssueTokenResponse + + /** A view of [AuthService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AuthService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /auth/issue-token`, but is otherwise the same as + * [AuthService.issueToken]. + */ + @MustBeClosed + fun issueToken(params: AuthIssueTokenParams): HttpResponseFor = + issueToken(params, RequestOptions.none()) + + /** @see issueToken */ + @MustBeClosed + fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt new file mode 100644 index 00000000..c3ba94ee --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.auth.AuthIssueTokenParams +import com.courier.api.models.auth.AuthIssueTokenResponse +import java.util.function.Consumer + +class AuthServiceImpl internal constructor(private val clientOptions: ClientOptions) : AuthService { + + private val withRawResponse: AuthService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AuthService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AuthService = + AuthServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions, + ): AuthIssueTokenResponse = + // post /auth/issue-token + withRawResponse().issueToken(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AuthService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AuthService.WithRawResponse = + AuthServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val issueTokenHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun issueToken( + params: AuthIssueTokenParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("auth", "issue-token") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { issueTokenHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt new file mode 100644 index 00000000..fa34bac4 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.automations.AutomationInvokeAdHocParams +import com.courier.api.models.automations.AutomationInvokeByTemplateParams +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.services.blocking.automations.InvokeService +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface AutomationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomationService + + fun invoke(): InvokeService + + /** + * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of + * automation steps. For information about what steps are available, checkout the ad hoc + * automation guide [here](https://www.courier.com/docs/automations/steps/). + */ + fun invokeAdHoc(params: AutomationInvokeAdHocParams): AutomationInvokeResponse = + invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AutomationInvokeResponse + + /** Invoke an automation run from an automation template. */ + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + ): AutomationInvokeResponse = invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AutomationInvokeResponse = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + fun invokeByTemplate(params: AutomationInvokeByTemplateParams): AutomationInvokeResponse = + invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AutomationInvokeResponse + + /** A view of [AutomationService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AutomationService.WithRawResponse + + fun invoke(): InvokeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as + * [AutomationService.invokeAdHoc]. + */ + @MustBeClosed + fun invokeAdHoc( + params: AutomationInvokeAdHocParams + ): HttpResponseFor = invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + @MustBeClosed + fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise + * the same as [AutomationService.invokeByTemplate]. + */ + @MustBeClosed + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + ): HttpResponseFor = + invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + @MustBeClosed + fun invokeByTemplate( + templateId: String, + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + @MustBeClosed + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams + ): HttpResponseFor = + invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + @MustBeClosed + fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt new file mode 100644 index 00000000..4b501bde --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.automations.AutomationInvokeAdHocParams +import com.courier.api.models.automations.AutomationInvokeByTemplateParams +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.services.blocking.automations.InvokeService +import com.courier.api.services.blocking.automations.InvokeServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class AutomationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AutomationService { + + private val withRawResponse: AutomationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val invoke: InvokeService by lazy { InvokeServiceImpl(clientOptions) } + + override fun withRawResponse(): AutomationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AutomationService = + AutomationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun invoke(): InvokeService = invoke + + override fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions, + ): AutomationInvokeResponse = + // post /automations/invoke + withRawResponse().invokeAdHoc(params, requestOptions).parse() + + override fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions, + ): AutomationInvokeResponse = + // post /automations/{templateId}/invoke + withRawResponse().invokeByTemplate(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AutomationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val invoke: InvokeService.WithRawResponse by lazy { + InvokeServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): AutomationService.WithRawResponse = + AutomationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun invoke(): InvokeService.WithRawResponse = invoke + + private val invokeAdHocHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeAdHoc( + params: AutomationInvokeAdHocParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { invokeAdHocHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val invokeByTemplateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeByTemplate( + params: AutomationInvokeByTemplateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("templateId", params.templateId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", params._pathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { invokeByTemplateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt new file mode 100644 index 00000000..1dc03837 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt @@ -0,0 +1,287 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.brands.Brand +import com.courier.api.models.brands.BrandCreateParams +import com.courier.api.models.brands.BrandDeleteParams +import com.courier.api.models.brands.BrandListParams +import com.courier.api.models.brands.BrandListResponse +import com.courier.api.models.brands.BrandRetrieveParams +import com.courier.api.models.brands.BrandUpdateParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface BrandService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandService + + /** Create a new brand */ + fun create(params: BrandCreateParams): Brand = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: BrandCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Brand + + /** Fetch a specific brand by brand ID. */ + fun retrieve(brandId: String): Brand = retrieve(brandId, BrandRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Brand = retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(brandId: String, params: BrandRetrieveParams = BrandRetrieveParams.none()): Brand = + retrieve(brandId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Brand + + /** @see retrieve */ + fun retrieve(params: BrandRetrieveParams): Brand = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(brandId: String, requestOptions: RequestOptions): Brand = + retrieve(brandId, BrandRetrieveParams.none(), requestOptions) + + /** Replace an existing brand with the supplied values. */ + fun update(brandId: String, params: BrandUpdateParams): Brand = + update(brandId, params, RequestOptions.none()) + + /** @see update */ + fun update( + brandId: String, + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Brand = update(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see update */ + fun update(params: BrandUpdateParams): Brand = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Brand + + /** Get the list of brands. */ + fun list(): BrandListResponse = list(BrandListParams.none()) + + /** @see list */ + fun list( + params: BrandListParams = BrandListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BrandListResponse + + /** @see list */ + fun list(params: BrandListParams = BrandListParams.none()): BrandListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): BrandListResponse = + list(BrandListParams.none(), requestOptions) + + /** Delete a brand by brand ID. */ + fun delete(brandId: String) = delete(brandId, BrandDeleteParams.none()) + + /** @see delete */ + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see delete */ + fun delete(brandId: String, params: BrandDeleteParams = BrandDeleteParams.none()) = + delete(brandId, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: BrandDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: BrandDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(brandId: String, requestOptions: RequestOptions) = + delete(brandId, BrandDeleteParams.none(), requestOptions) + + /** A view of [BrandService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BrandService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /brands`, but is otherwise the same as + * [BrandService.create]. + */ + @MustBeClosed + fun create(params: BrandCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: BrandCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /brands/{brand_id}`, but is otherwise the same as + * [BrandService.retrieve]. + */ + @MustBeClosed + fun retrieve(brandId: String): HttpResponseFor = + retrieve(brandId, BrandRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + brandId: String, + params: BrandRetrieveParams = BrandRetrieveParams.none(), + ): HttpResponseFor = retrieve(brandId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: BrandRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(brandId: String, requestOptions: RequestOptions): HttpResponseFor = + retrieve(brandId, BrandRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /brands/{brand_id}`, but is otherwise the same as + * [BrandService.update]. + */ + @MustBeClosed + fun update(brandId: String, params: BrandUpdateParams): HttpResponseFor = + update(brandId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + brandId: String, + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: BrandUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /brands`, but is otherwise the same as + * [BrandService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor = list(BrandListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: BrandListParams = BrandListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: BrandListParams = BrandListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(BrandListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /brands/{brand_id}`, but is otherwise the same as + * [BrandService.delete]. + */ + @MustBeClosed + fun delete(brandId: String): HttpResponse = delete(brandId, BrandDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().brandId(brandId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + brandId: String, + params: BrandDeleteParams = BrandDeleteParams.none(), + ): HttpResponse = delete(brandId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: BrandDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: BrandDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(brandId: String, requestOptions: RequestOptions): HttpResponse = + delete(brandId, BrandDeleteParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt new file mode 100644 index 00000000..c9fd104a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.brands.Brand +import com.courier.api.models.brands.BrandCreateParams +import com.courier.api.models.brands.BrandDeleteParams +import com.courier.api.models.brands.BrandListParams +import com.courier.api.models.brands.BrandListResponse +import com.courier.api.models.brands.BrandRetrieveParams +import com.courier.api.models.brands.BrandUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BrandServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BrandService { + + private val withRawResponse: BrandService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BrandService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BrandService = + BrandServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create(params: BrandCreateParams, requestOptions: RequestOptions): Brand = + // post /brands + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve(params: BrandRetrieveParams, requestOptions: RequestOptions): Brand = + // get /brands/{brand_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: BrandUpdateParams, requestOptions: RequestOptions): Brand = + // put /brands/{brand_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: BrandListParams, requestOptions: RequestOptions): BrandListResponse = + // get /brands + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: BrandDeleteParams, requestOptions: RequestOptions) { + // delete /brands/{brand_id} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BrandService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BrandService.WithRawResponse = + BrandServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: BrandCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: BrandRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("brandId", params.brandId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: BrandUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("brandId", params.brandId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: BrandListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: BrandDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("brandId", params.brandId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("brands", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt new file mode 100644 index 00000000..d59522f8 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt @@ -0,0 +1,328 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.bulk.BulkAddUsersParams +import com.courier.api.models.bulk.BulkCreateJobParams +import com.courier.api.models.bulk.BulkCreateJobResponse +import com.courier.api.models.bulk.BulkListUsersParams +import com.courier.api.models.bulk.BulkListUsersResponse +import com.courier.api.models.bulk.BulkRetrieveJobParams +import com.courier.api.models.bulk.BulkRetrieveJobResponse +import com.courier.api.models.bulk.BulkRunJobParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface BulkService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BulkService + + /** Ingest user data into a Bulk Job */ + fun addUsers(jobId: String, params: BulkAddUsersParams) = + addUsers(jobId, params, RequestOptions.none()) + + /** @see addUsers */ + fun addUsers( + jobId: String, + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see addUsers */ + fun addUsers(params: BulkAddUsersParams) = addUsers(params, RequestOptions.none()) + + /** @see addUsers */ + fun addUsers(params: BulkAddUsersParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** Create a bulk job */ + fun createJob(params: BulkCreateJobParams): BulkCreateJobResponse = + createJob(params, RequestOptions.none()) + + /** @see createJob */ + fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkCreateJobResponse + + /** Get Bulk Job Users */ + fun listUsers(jobId: String): BulkListUsersResponse = + listUsers(jobId, BulkListUsersParams.none()) + + /** @see listUsers */ + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkListUsersResponse = listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see listUsers */ + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + ): BulkListUsersResponse = listUsers(jobId, params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkListUsersResponse + + /** @see listUsers */ + fun listUsers(params: BulkListUsersParams): BulkListUsersResponse = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers(jobId: String, requestOptions: RequestOptions): BulkListUsersResponse = + listUsers(jobId, BulkListUsersParams.none(), requestOptions) + + /** Get a bulk job */ + fun retrieveJob(jobId: String): BulkRetrieveJobResponse = + retrieveJob(jobId, BulkRetrieveJobParams.none()) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkRetrieveJobResponse = + retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveJob */ + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + ): BulkRetrieveJobResponse = retrieveJob(jobId, params, RequestOptions.none()) + + /** @see retrieveJob */ + fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BulkRetrieveJobResponse + + /** @see retrieveJob */ + fun retrieveJob(params: BulkRetrieveJobParams): BulkRetrieveJobResponse = + retrieveJob(params, RequestOptions.none()) + + /** @see retrieveJob */ + fun retrieveJob(jobId: String, requestOptions: RequestOptions): BulkRetrieveJobResponse = + retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) + + /** Run a bulk job */ + fun runJob(jobId: String) = runJob(jobId, BulkRunJobParams.none()) + + /** @see runJob */ + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see runJob */ + fun runJob(jobId: String, params: BulkRunJobParams = BulkRunJobParams.none()) = + runJob(jobId, params, RequestOptions.none()) + + /** @see runJob */ + fun runJob(params: BulkRunJobParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see runJob */ + fun runJob(params: BulkRunJobParams) = runJob(params, RequestOptions.none()) + + /** @see runJob */ + fun runJob(jobId: String, requestOptions: RequestOptions) = + runJob(jobId, BulkRunJobParams.none(), requestOptions) + + /** A view of [BulkService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BulkService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /bulk/{job_id}`, but is otherwise the same as + * [BulkService.addUsers]. + */ + @MustBeClosed + fun addUsers(jobId: String, params: BulkAddUsersParams): HttpResponse = + addUsers(jobId, params, RequestOptions.none()) + + /** @see addUsers */ + @MustBeClosed + fun addUsers( + jobId: String, + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see addUsers */ + @MustBeClosed + fun addUsers(params: BulkAddUsersParams): HttpResponse = + addUsers(params, RequestOptions.none()) + + /** @see addUsers */ + @MustBeClosed + fun addUsers( + params: BulkAddUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `post /bulk`, but is otherwise the same as + * [BulkService.createJob]. + */ + @MustBeClosed + fun createJob(params: BulkCreateJobParams): HttpResponseFor = + createJob(params, RequestOptions.none()) + + /** @see createJob */ + @MustBeClosed + fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /bulk/{job_id}/users`, but is otherwise the same as + * [BulkService.listUsers]. + */ + @MustBeClosed + fun listUsers(jobId: String): HttpResponseFor = + listUsers(jobId, BulkListUsersParams.none()) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + jobId: String, + params: BulkListUsersParams = BulkListUsersParams.none(), + ): HttpResponseFor = listUsers(jobId, params, RequestOptions.none()) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listUsers */ + @MustBeClosed + fun listUsers(params: BulkListUsersParams): HttpResponseFor = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + jobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listUsers(jobId, BulkListUsersParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /bulk/{job_id}`, but is otherwise the same as + * [BulkService.retrieveJob]. + */ + @MustBeClosed + fun retrieveJob(jobId: String): HttpResponseFor = + retrieveJob(jobId, BulkRetrieveJobParams.none()) + + /** @see retrieveJob */ + @MustBeClosed + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see retrieveJob */ + @MustBeClosed + fun retrieveJob( + jobId: String, + params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), + ): HttpResponseFor = + retrieveJob(jobId, params, RequestOptions.none()) + + /** @see retrieveJob */ + @MustBeClosed + fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveJob */ + @MustBeClosed + fun retrieveJob(params: BulkRetrieveJobParams): HttpResponseFor = + retrieveJob(params, RequestOptions.none()) + + /** @see retrieveJob */ + @MustBeClosed + fun retrieveJob( + jobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /bulk/{job_id}/run`, but is otherwise the same as + * [BulkService.runJob]. + */ + @MustBeClosed + fun runJob(jobId: String): HttpResponse = runJob(jobId, BulkRunJobParams.none()) + + /** @see runJob */ + @MustBeClosed + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see runJob */ + @MustBeClosed + fun runJob( + jobId: String, + params: BulkRunJobParams = BulkRunJobParams.none(), + ): HttpResponse = runJob(jobId, params, RequestOptions.none()) + + /** @see runJob */ + @MustBeClosed + fun runJob( + params: BulkRunJobParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see runJob */ + @MustBeClosed + fun runJob(params: BulkRunJobParams): HttpResponse = runJob(params, RequestOptions.none()) + + /** @see runJob */ + @MustBeClosed + fun runJob(jobId: String, requestOptions: RequestOptions): HttpResponse = + runJob(jobId, BulkRunJobParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt new file mode 100644 index 00000000..41cc3b56 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.bulk.BulkAddUsersParams +import com.courier.api.models.bulk.BulkCreateJobParams +import com.courier.api.models.bulk.BulkCreateJobResponse +import com.courier.api.models.bulk.BulkListUsersParams +import com.courier.api.models.bulk.BulkListUsersResponse +import com.courier.api.models.bulk.BulkRetrieveJobParams +import com.courier.api.models.bulk.BulkRetrieveJobResponse +import com.courier.api.models.bulk.BulkRunJobParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { + + private val withRawResponse: BulkService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BulkService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BulkService = + BulkServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun addUsers(params: BulkAddUsersParams, requestOptions: RequestOptions) { + // post /bulk/{job_id} + withRawResponse().addUsers(params, requestOptions) + } + + override fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions, + ): BulkCreateJobResponse = + // post /bulk + withRawResponse().createJob(params, requestOptions).parse() + + override fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions, + ): BulkListUsersResponse = + // get /bulk/{job_id}/users + withRawResponse().listUsers(params, requestOptions).parse() + + override fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions, + ): BulkRetrieveJobResponse = + // get /bulk/{job_id} + withRawResponse().retrieveJob(params, requestOptions).parse() + + override fun runJob(params: BulkRunJobParams, requestOptions: RequestOptions) { + // post /bulk/{job_id}/run + withRawResponse().runJob(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BulkService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BulkService.WithRawResponse = + BulkServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val addUsersHandler: Handler = emptyHandler() + + override fun addUsers( + params: BulkAddUsersParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { addUsersHandler.handle(it) } + } + } + + private val createJobHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createJob( + params: BulkCreateJobParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createJobHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listUsersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listUsers( + params: BulkListUsersParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0), "users") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listUsersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveJobHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveJob( + params: BulkRetrieveJobParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveJobHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val runJobHandler: Handler = emptyHandler() + + override fun runJob( + params: BulkRunJobParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("bulk", params._pathParam(0), "run") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { runJobHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt new file mode 100644 index 00000000..5c8dd95a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.inbound.InboundTrackEventParams +import com.courier.api.models.inbound.InboundTrackEventResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface InboundService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboundService + + /** Courier Track Event */ + fun trackEvent(params: InboundTrackEventParams): InboundTrackEventResponse = + trackEvent(params, RequestOptions.none()) + + /** @see trackEvent */ + fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboundTrackEventResponse + + /** A view of [InboundService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboundService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /inbound/courier`, but is otherwise the same as + * [InboundService.trackEvent]. + */ + @MustBeClosed + fun trackEvent( + params: InboundTrackEventParams + ): HttpResponseFor = trackEvent(params, RequestOptions.none()) + + /** @see trackEvent */ + @MustBeClosed + fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt new file mode 100644 index 00000000..dff28335 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.inbound.InboundTrackEventParams +import com.courier.api.models.inbound.InboundTrackEventResponse +import java.util.function.Consumer + +class InboundServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InboundService { + + private val withRawResponse: InboundService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InboundService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InboundService = + InboundServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions, + ): InboundTrackEventResponse = + // post /inbound/courier + withRawResponse().trackEvent(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InboundService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): InboundService.WithRawResponse = + InboundServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val trackEventHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun trackEvent( + params: InboundTrackEventParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("inbound", "courier") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { trackEventHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt new file mode 100644 index 00000000..225cf527 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt @@ -0,0 +1,330 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.lists.List +import com.courier.api.models.lists.ListDeleteParams +import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListListResponse +import com.courier.api.models.lists.ListRestoreParams +import com.courier.api.models.lists.ListRetrieveParams +import com.courier.api.models.lists.ListUpdateParams +import com.courier.api.services.blocking.lists.SubscriptionService +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface ListService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListService + + fun subscriptions(): SubscriptionService + + /** Returns a list based on the list ID provided. */ + fun retrieve(listId: String): List = retrieve(listId, ListRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List = retrieve(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(listId: String, params: ListRetrieveParams = ListRetrieveParams.none()): List = + retrieve(listId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see retrieve */ + fun retrieve(params: ListRetrieveParams): List = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(listId: String, requestOptions: RequestOptions): List = + retrieve(listId, ListRetrieveParams.none(), requestOptions) + + /** Create or replace an existing list with the supplied values. */ + fun update(listId: String, params: ListUpdateParams): List = + update(listId, params, RequestOptions.none()) + + /** @see update */ + fun update( + listId: String, + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List = update(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see update */ + fun update(params: ListUpdateParams): List = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** Returns all of the lists, with the ability to filter based on a pattern. */ + fun list(): ListListResponse = list(ListListParams.none()) + + /** @see list */ + fun list( + params: ListListParams = ListListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ListListResponse + + /** @see list */ + fun list(params: ListListParams = ListListParams.none()): ListListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): ListListResponse = + list(ListListParams.none(), requestOptions) + + /** Delete a list by list ID. */ + fun delete(listId: String) = delete(listId, ListDeleteParams.none()) + + /** @see delete */ + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see delete */ + fun delete(listId: String, params: ListDeleteParams = ListDeleteParams.none()) = + delete(listId, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: ListDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: ListDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(listId: String, requestOptions: RequestOptions) = + delete(listId, ListDeleteParams.none(), requestOptions) + + /** Restore a previously deleted list. */ + fun restore(listId: String) = restore(listId, ListRestoreParams.none()) + + /** @see restore */ + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = restore(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see restore */ + fun restore(listId: String, params: ListRestoreParams = ListRestoreParams.none()) = + restore(listId, params, RequestOptions.none()) + + /** @see restore */ + fun restore(params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see restore */ + fun restore(params: ListRestoreParams) = restore(params, RequestOptions.none()) + + /** @see restore */ + fun restore(listId: String, requestOptions: RequestOptions) = + restore(listId, ListRestoreParams.none(), requestOptions) + + /** A view of [ListService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListService.WithRawResponse + + fun subscriptions(): SubscriptionService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /lists/{list_id}`, but is otherwise the same as + * [ListService.retrieve]. + */ + @MustBeClosed + fun retrieve(listId: String): HttpResponseFor = + retrieve(listId, ListRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + listId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): HttpResponseFor = retrieve(listId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: ListRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(listId: String, requestOptions: RequestOptions): HttpResponseFor = + retrieve(listId, ListRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /lists/{list_id}`, but is otherwise the same as + * [ListService.update]. + */ + @MustBeClosed + fun update(listId: String, params: ListUpdateParams): HttpResponseFor = + update(listId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + listId: String, + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = update(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ListUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ListUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /lists`, but is otherwise the same as + * [ListService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor = list(ListListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: ListListParams = ListListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: ListListParams = ListListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(ListListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /lists/{list_id}`, but is otherwise the same as + * [ListService.delete]. + */ + @MustBeClosed + fun delete(listId: String): HttpResponse = delete(listId, ListDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + listId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): HttpResponse = delete(listId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: ListDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(listId: String, requestOptions: RequestOptions): HttpResponse = + delete(listId, ListDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /lists/{list_id}/restore`, but is otherwise the same + * as [ListService.restore]. + */ + @MustBeClosed + fun restore(listId: String): HttpResponse = restore(listId, ListRestoreParams.none()) + + /** @see restore */ + @MustBeClosed + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = restore(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see restore */ + @MustBeClosed + fun restore( + listId: String, + params: ListRestoreParams = ListRestoreParams.none(), + ): HttpResponse = restore(listId, params, RequestOptions.none()) + + /** @see restore */ + @MustBeClosed + fun restore( + params: ListRestoreParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see restore */ + @MustBeClosed + fun restore(params: ListRestoreParams): HttpResponse = + restore(params, RequestOptions.none()) + + /** @see restore */ + @MustBeClosed + fun restore(listId: String, requestOptions: RequestOptions): HttpResponse = + restore(listId, ListRestoreParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt new file mode 100644 index 00000000..626fa491 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.lists.List +import com.courier.api.models.lists.ListDeleteParams +import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListListResponse +import com.courier.api.models.lists.ListRestoreParams +import com.courier.api.models.lists.ListRetrieveParams +import com.courier.api.models.lists.ListUpdateParams +import com.courier.api.services.blocking.lists.SubscriptionService +import com.courier.api.services.blocking.lists.SubscriptionServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ListServiceImpl internal constructor(private val clientOptions: ClientOptions) : ListService { + + private val withRawResponse: ListService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val subscriptions: SubscriptionService by lazy { + SubscriptionServiceImpl(clientOptions) + } + + override fun withRawResponse(): ListService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ListService = + ListServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun subscriptions(): SubscriptionService = subscriptions + + override fun retrieve(params: ListRetrieveParams, requestOptions: RequestOptions): List = + // get /lists/{list_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: ListUpdateParams, requestOptions: RequestOptions): List = + // put /lists/{list_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: ListListParams, requestOptions: RequestOptions): ListListResponse = + // get /lists + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: ListDeleteParams, requestOptions: RequestOptions) { + // delete /lists/{list_id} + withRawResponse().delete(params, requestOptions) + } + + override fun restore(params: ListRestoreParams, requestOptions: RequestOptions) { + // put /lists/{list_id}/restore + withRawResponse().restore(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ListService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val subscriptions: SubscriptionService.WithRawResponse by lazy { + SubscriptionServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): ListService.WithRawResponse = + ListServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions + + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: ListUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: ListListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val restoreHandler: Handler = emptyHandler() + + override fun restore( + params: ListRestoreParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "restore") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { restoreHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt new file mode 100644 index 00000000..a150e625 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt @@ -0,0 +1,397 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageDetails +import com.courier.api.models.messages.MessageGetContentParams +import com.courier.api.models.messages.MessageGetContentResponse +import com.courier.api.models.messages.MessageHistoryParams +import com.courier.api.models.messages.MessageHistoryResponse +import com.courier.api.models.messages.MessageListParams +import com.courier.api.models.messages.MessageListResponse +import com.courier.api.models.messages.MessageRetrieveParams +import com.courier.api.models.messages.MessageRetrieveResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface MessageService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageService + + /** Fetch the status of a message you've previously sent. */ + fun retrieve(messageId: String): MessageRetrieveResponse = + retrieve(messageId, MessageRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageRetrieveResponse = + retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + ): MessageRetrieveResponse = retrieve(messageId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: MessageRetrieveParams): MessageRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(messageId: String, requestOptions: RequestOptions): MessageRetrieveResponse = + retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + + /** Fetch the statuses of messages you've previously sent. */ + fun list(): MessageListResponse = list(MessageListParams.none()) + + /** @see list */ + fun list( + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageListResponse + + /** @see list */ + fun list(params: MessageListParams = MessageListParams.none()): MessageListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): MessageListResponse = + list(MessageListParams.none(), requestOptions) + + /** + * Cancel a message that is currently in the process of being delivered. A well-formatted API + * call to the cancel message API will return either `200` status code for a successful + * cancellation or `409` status code for an unsuccessful cancellation. Both cases will include + * the actual message record in the response body (see details below). + */ + fun cancel(messageId: String): MessageDetails = cancel(messageId, MessageCancelParams.none()) + + /** @see cancel */ + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageDetails = cancel(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + ): MessageDetails = cancel(messageId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageDetails + + /** @see cancel */ + fun cancel(params: MessageCancelParams): MessageDetails = cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(messageId: String, requestOptions: RequestOptions): MessageDetails = + cancel(messageId, MessageCancelParams.none(), requestOptions) + + /** Get message content */ + fun getContent(messageId: String): MessageGetContentResponse = + getContent(messageId, MessageGetContentParams.none()) + + /** @see getContent */ + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageGetContentResponse = + getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see getContent */ + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + ): MessageGetContentResponse = getContent(messageId, params, RequestOptions.none()) + + /** @see getContent */ + fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageGetContentResponse + + /** @see getContent */ + fun getContent(params: MessageGetContentParams): MessageGetContentResponse = + getContent(params, RequestOptions.none()) + + /** @see getContent */ + fun getContent(messageId: String, requestOptions: RequestOptions): MessageGetContentResponse = + getContent(messageId, MessageGetContentParams.none(), requestOptions) + + /** Fetch the array of events of a message you've previously sent. */ + fun history(messageId: String): MessageHistoryResponse = + history(messageId, MessageHistoryParams.none()) + + /** @see history */ + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageHistoryResponse = + history(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see history */ + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + ): MessageHistoryResponse = history(messageId, params, RequestOptions.none()) + + /** @see history */ + fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): MessageHistoryResponse + + /** @see history */ + fun history(params: MessageHistoryParams): MessageHistoryResponse = + history(params, RequestOptions.none()) + + /** @see history */ + fun history(messageId: String, requestOptions: RequestOptions): MessageHistoryResponse = + history(messageId, MessageHistoryParams.none(), requestOptions) + + /** A view of [MessageService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MessageService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /messages/{message_id}`, but is otherwise the same + * as [MessageService.retrieve]. + */ + @MustBeClosed + fun retrieve(messageId: String): HttpResponseFor = + retrieve(messageId, MessageRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + messageId: String, + params: MessageRetrieveParams = MessageRetrieveParams.none(), + ): HttpResponseFor = + retrieve(messageId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: MessageRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + messageId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(messageId, MessageRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /messages`, but is otherwise the same as + * [MessageService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(MessageListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: MessageListParams = MessageListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: MessageListParams = MessageListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(MessageListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /messages/{message_id}/cancel`, but is otherwise + * the same as [MessageService.cancel]. + */ + @MustBeClosed + fun cancel(messageId: String): HttpResponseFor = + cancel(messageId, MessageCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + messageId: String, + params: MessageCancelParams = MessageCancelParams.none(), + ): HttpResponseFor = cancel(messageId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: MessageCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + messageId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(messageId, MessageCancelParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /messages/{message_id}/output`, but is otherwise the + * same as [MessageService.getContent]. + */ + @MustBeClosed + fun getContent(messageId: String): HttpResponseFor = + getContent(messageId, MessageGetContentParams.none()) + + /** @see getContent */ + @MustBeClosed + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see getContent */ + @MustBeClosed + fun getContent( + messageId: String, + params: MessageGetContentParams = MessageGetContentParams.none(), + ): HttpResponseFor = + getContent(messageId, params, RequestOptions.none()) + + /** @see getContent */ + @MustBeClosed + fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getContent */ + @MustBeClosed + fun getContent( + params: MessageGetContentParams + ): HttpResponseFor = getContent(params, RequestOptions.none()) + + /** @see getContent */ + @MustBeClosed + fun getContent( + messageId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + getContent(messageId, MessageGetContentParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /messages/{message_id}/history`, but is otherwise + * the same as [MessageService.history]. + */ + @MustBeClosed + fun history(messageId: String): HttpResponseFor = + history(messageId, MessageHistoryParams.none()) + + /** @see history */ + @MustBeClosed + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + history(params.toBuilder().messageId(messageId).build(), requestOptions) + + /** @see history */ + @MustBeClosed + fun history( + messageId: String, + params: MessageHistoryParams = MessageHistoryParams.none(), + ): HttpResponseFor = + history(messageId, params, RequestOptions.none()) + + /** @see history */ + @MustBeClosed + fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see history */ + @MustBeClosed + fun history(params: MessageHistoryParams): HttpResponseFor = + history(params, RequestOptions.none()) + + /** @see history */ + @MustBeClosed + fun history( + messageId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + history(messageId, MessageHistoryParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt new file mode 100644 index 00000000..ea6eb65d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageDetails +import com.courier.api.models.messages.MessageGetContentParams +import com.courier.api.models.messages.MessageGetContentResponse +import com.courier.api.models.messages.MessageHistoryParams +import com.courier.api.models.messages.MessageHistoryResponse +import com.courier.api.models.messages.MessageListParams +import com.courier.api.models.messages.MessageListResponse +import com.courier.api.models.messages.MessageRetrieveParams +import com.courier.api.models.messages.MessageRetrieveResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class MessageServiceImpl internal constructor(private val clientOptions: ClientOptions) : + MessageService { + + private val withRawResponse: MessageService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MessageService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): MessageService = + MessageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions, + ): MessageRetrieveResponse = + // get /messages/{message_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: MessageListParams, + requestOptions: RequestOptions, + ): MessageListResponse = + // get /messages + withRawResponse().list(params, requestOptions).parse() + + override fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions, + ): MessageDetails = + // post /messages/{message_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + + override fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions, + ): MessageGetContentResponse = + // get /messages/{message_id}/output + withRawResponse().getContent(params, requestOptions).parse() + + override fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions, + ): MessageHistoryResponse = + // get /messages/{message_id}/history + withRawResponse().history(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MessageService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): MessageService.WithRawResponse = + MessageServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: MessageRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: MessageListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: MessageCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getContentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getContent( + params: MessageGetContentParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0), "output") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getContentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val historyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun history( + params: MessageHistoryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("messageId", params.messageId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("messages", params._pathParam(0), "history") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { historyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt new file mode 100644 index 00000000..6820f7d6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.NotificationListParams +import com.courier.api.models.notifications.NotificationListResponse +import com.courier.api.models.notifications.NotificationRetrieveContentParams +import com.courier.api.services.blocking.notifications.CheckService +import com.courier.api.services.blocking.notifications.DraftService +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface NotificationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NotificationService + + fun draft(): DraftService + + fun checks(): CheckService + + fun list(): NotificationListResponse = list(NotificationListParams.none()) + + /** @see list */ + fun list( + params: NotificationListParams = NotificationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NotificationListResponse + + /** @see list */ + fun list( + params: NotificationListParams = NotificationListParams.none() + ): NotificationListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): NotificationListResponse = + list(NotificationListParams.none(), requestOptions) + + fun retrieveContent(id: String): NotificationGetContent = + retrieveContent(id, NotificationRetrieveContentParams.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NotificationGetContent = retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + ): NotificationGetContent = retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NotificationGetContent + + /** @see retrieveContent */ + fun retrieveContent(params: NotificationRetrieveContentParams): NotificationGetContent = + retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent(id: String, requestOptions: RequestOptions): NotificationGetContent = + retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) + + /** + * A view of [NotificationService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): NotificationService.WithRawResponse + + fun draft(): DraftService.WithRawResponse + + fun checks(): CheckService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /notifications`, but is otherwise the same as + * [NotificationService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(NotificationListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: NotificationListParams = NotificationListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: NotificationListParams = NotificationListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(NotificationListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /notifications/{id}/content`, but is otherwise the + * same as [NotificationService.retrieveContent]. + */ + @MustBeClosed + fun retrieveContent(id: String): HttpResponseFor = + retrieveContent(id, NotificationRetrieveContentParams.none()) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + id: String, + params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), + ): HttpResponseFor = + retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + params: NotificationRetrieveContentParams + ): HttpResponseFor = retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt new file mode 100644 index 00000000..a8a940c3 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.NotificationListParams +import com.courier.api.models.notifications.NotificationListResponse +import com.courier.api.models.notifications.NotificationRetrieveContentParams +import com.courier.api.services.blocking.notifications.CheckService +import com.courier.api.services.blocking.notifications.CheckServiceImpl +import com.courier.api.services.blocking.notifications.DraftService +import com.courier.api.services.blocking.notifications.DraftServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class NotificationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + NotificationService { + + private val withRawResponse: NotificationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val draft: DraftService by lazy { DraftServiceImpl(clientOptions) } + + private val checks: CheckService by lazy { CheckServiceImpl(clientOptions) } + + override fun withRawResponse(): NotificationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): NotificationService = + NotificationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun draft(): DraftService = draft + + override fun checks(): CheckService = checks + + override fun list( + params: NotificationListParams, + requestOptions: RequestOptions, + ): NotificationListResponse = + // get /notifications + withRawResponse().list(params, requestOptions).parse() + + override fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions, + ): NotificationGetContent = + // get /notifications/{id}/content + withRawResponse().retrieveContent(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NotificationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val draft: DraftService.WithRawResponse by lazy { + DraftServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val checks: CheckService.WithRawResponse by lazy { + CheckServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): NotificationService.WithRawResponse = + NotificationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun draft(): DraftService.WithRawResponse = draft + + override fun checks(): CheckService.WithRawResponse = checks + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: NotificationListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("notifications") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveContentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveContent( + params: NotificationRetrieveContentParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("notifications", params._pathParam(0), "content") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveContentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt new file mode 100644 index 00000000..0f639b57 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt @@ -0,0 +1,346 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.profiles.ProfileCreateParams +import com.courier.api.models.profiles.ProfileCreateResponse +import com.courier.api.models.profiles.ProfileDeleteParams +import com.courier.api.models.profiles.ProfileReplaceParams +import com.courier.api.models.profiles.ProfileReplaceResponse +import com.courier.api.models.profiles.ProfileRetrieveParams +import com.courier.api.models.profiles.ProfileRetrieveResponse +import com.courier.api.models.profiles.ProfileUpdateParams +import com.courier.api.services.blocking.profiles.ListService +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface ProfileService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProfileService + + fun lists(): ListService + + /** + * Merge the supplied values with an existing profile or create a new profile if one doesn't + * already exist. + */ + fun create(userId: String, params: ProfileCreateParams): ProfileCreateResponse = + create(userId, params, RequestOptions.none()) + + /** @see create */ + fun create( + userId: String, + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProfileCreateResponse = create(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see create */ + fun create(params: ProfileCreateParams): ProfileCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProfileCreateResponse + + /** Returns the specified user profile. */ + fun retrieve(userId: String): ProfileRetrieveResponse = + retrieve(userId, ProfileRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ProfileRetrieveResponse = retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + ): ProfileRetrieveResponse = retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProfileRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: ProfileRetrieveParams): ProfileRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(userId: String, requestOptions: RequestOptions): ProfileRetrieveResponse = + retrieve(userId, ProfileRetrieveParams.none(), requestOptions) + + /** Update a profile */ + fun update(userId: String, params: ProfileUpdateParams) = + update(userId, params, RequestOptions.none()) + + /** @see update */ + fun update( + userId: String, + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = update(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see update */ + fun update(params: ProfileUpdateParams) = update(params, RequestOptions.none()) + + /** @see update */ + fun update(params: ProfileUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** Deletes the specified user profile. */ + fun delete(userId: String) = delete(userId, ProfileDeleteParams.none()) + + /** @see delete */ + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + fun delete(userId: String, params: ProfileDeleteParams = ProfileDeleteParams.none()) = + delete(userId, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: ProfileDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: ProfileDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(userId: String, requestOptions: RequestOptions) = + delete(userId, ProfileDeleteParams.none(), requestOptions) + + /** + * When using `PUT`, be sure to include all the key-value pairs required by the recipient's + * profile. Any key-value pairs that exist in the profile but fail to be included in the `PUT` + * request will be removed from the profile. Remember, a `PUT` update is a full replacement of + * the data. For partial updates, use the + * [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. + */ + fun replace(userId: String, params: ProfileReplaceParams): ProfileReplaceResponse = + replace(userId, params, RequestOptions.none()) + + /** @see replace */ + fun replace( + userId: String, + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProfileReplaceResponse = replace(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see replace */ + fun replace(params: ProfileReplaceParams): ProfileReplaceResponse = + replace(params, RequestOptions.none()) + + /** @see replace */ + fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ProfileReplaceResponse + + /** A view of [ProfileService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProfileService.WithRawResponse + + fun lists(): ListService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /profiles/{user_id}`, but is otherwise the same as + * [ProfileService.create]. + */ + @MustBeClosed + fun create( + userId: String, + params: ProfileCreateParams, + ): HttpResponseFor = create(userId, params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + userId: String, + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see create */ + @MustBeClosed + fun create(params: ProfileCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /profiles/{user_id}`, but is otherwise the same as + * [ProfileService.retrieve]. + */ + @MustBeClosed + fun retrieve(userId: String): HttpResponseFor = + retrieve(userId, ProfileRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + params: ProfileRetrieveParams = ProfileRetrieveParams.none(), + ): HttpResponseFor = + retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: ProfileRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(userId, ProfileRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `patch /profiles/{user_id}`, but is otherwise the same as + * [ProfileService.update]. + */ + @MustBeClosed + fun update(userId: String, params: ProfileUpdateParams): HttpResponse = + update(userId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + userId: String, + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = update(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ProfileUpdateParams): HttpResponse = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ProfileUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `delete /profiles/{user_id}`, but is otherwise the same + * as [ProfileService.delete]. + */ + @MustBeClosed + fun delete(userId: String): HttpResponse = delete(userId, ProfileDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + userId: String, + params: ProfileDeleteParams = ProfileDeleteParams.none(), + ): HttpResponse = delete(userId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ProfileDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: ProfileDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(userId: String, requestOptions: RequestOptions): HttpResponse = + delete(userId, ProfileDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /profiles/{user_id}`, but is otherwise the same as + * [ProfileService.replace]. + */ + @MustBeClosed + fun replace( + userId: String, + params: ProfileReplaceParams, + ): HttpResponseFor = replace(userId, params, RequestOptions.none()) + + /** @see replace */ + @MustBeClosed + fun replace( + userId: String, + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + replace(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see replace */ + @MustBeClosed + fun replace(params: ProfileReplaceParams): HttpResponseFor = + replace(params, RequestOptions.none()) + + /** @see replace */ + @MustBeClosed + fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt new file mode 100644 index 00000000..042ba30a --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.profiles.ProfileCreateParams +import com.courier.api.models.profiles.ProfileCreateResponse +import com.courier.api.models.profiles.ProfileDeleteParams +import com.courier.api.models.profiles.ProfileReplaceParams +import com.courier.api.models.profiles.ProfileReplaceResponse +import com.courier.api.models.profiles.ProfileRetrieveParams +import com.courier.api.models.profiles.ProfileRetrieveResponse +import com.courier.api.models.profiles.ProfileUpdateParams +import com.courier.api.services.blocking.profiles.ListService +import com.courier.api.services.blocking.profiles.ListServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ProfileServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ProfileService { + + private val withRawResponse: ProfileService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val lists: ListService by lazy { ListServiceImpl(clientOptions) } + + override fun withRawResponse(): ProfileService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ProfileService = + ProfileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun lists(): ListService = lists + + override fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions, + ): ProfileCreateResponse = + // post /profiles/{user_id} + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions, + ): ProfileRetrieveResponse = + // get /profiles/{user_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: ProfileUpdateParams, requestOptions: RequestOptions) { + // patch /profiles/{user_id} + withRawResponse().update(params, requestOptions) + } + + override fun delete(params: ProfileDeleteParams, requestOptions: RequestOptions) { + // delete /profiles/{user_id} + withRawResponse().delete(params, requestOptions) + } + + override fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions, + ): ProfileReplaceResponse = + // put /profiles/{user_id} + withRawResponse().replace(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ProfileService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val lists: ListService.WithRawResponse by lazy { + ListServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): ProfileService.WithRawResponse = + ProfileServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun lists(): ListService.WithRawResponse = lists + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: ProfileCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ProfileRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: ProfileUpdateParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: ProfileDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val replaceHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun replace( + params: ProfileReplaceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { replaceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt new file mode 100644 index 00000000..e9df5849 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.models.requests.RequestArchiveParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface RequestService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestService + + /** Archive message */ + fun archive(requestId: String) = archive(requestId, RequestArchiveParams.none()) + + /** @see archive */ + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = archive(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see archive */ + fun archive(requestId: String, params: RequestArchiveParams = RequestArchiveParams.none()) = + archive(requestId, params, RequestOptions.none()) + + /** @see archive */ + fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see archive */ + fun archive(params: RequestArchiveParams) = archive(params, RequestOptions.none()) + + /** @see archive */ + fun archive(requestId: String, requestOptions: RequestOptions) = + archive(requestId, RequestArchiveParams.none(), requestOptions) + + /** A view of [RequestService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /requests/{request_id}/archive`, but is otherwise + * the same as [RequestService.archive]. + */ + @MustBeClosed + fun archive(requestId: String): HttpResponse = + archive(requestId, RequestArchiveParams.none()) + + /** @see archive */ + @MustBeClosed + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = archive(params.toBuilder().requestId(requestId).build(), requestOptions) + + /** @see archive */ + @MustBeClosed + fun archive( + requestId: String, + params: RequestArchiveParams = RequestArchiveParams.none(), + ): HttpResponse = archive(requestId, params, RequestOptions.none()) + + /** @see archive */ + @MustBeClosed + fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see archive */ + @MustBeClosed + fun archive(params: RequestArchiveParams): HttpResponse = + archive(params, RequestOptions.none()) + + /** @see archive */ + @MustBeClosed + fun archive(requestId: String, requestOptions: RequestOptions): HttpResponse = + archive(requestId, RequestArchiveParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt new file mode 100644 index 00000000..275e31e5 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.requests.RequestArchiveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class RequestServiceImpl internal constructor(private val clientOptions: ClientOptions) : + RequestService { + + private val withRawResponse: RequestService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): RequestService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): RequestService = + RequestServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun archive(params: RequestArchiveParams, requestOptions: RequestOptions) { + // put /requests/{request_id}/archive + withRawResponse().archive(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + RequestService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): RequestService.WithRawResponse = + RequestServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val archiveHandler: Handler = emptyHandler() + + override fun archive( + params: RequestArchiveParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("requestId", params.requestId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("requests", params._pathParam(0), "archive") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { archiveHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt new file mode 100644 index 00000000..ac6f2552 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface SendService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SendService + + /** Use the send API to send a message to one or more recipients. */ + fun sendMessage(params: SendSendMessageParams): SendSendMessageResponse = + sendMessage(params, RequestOptions.none()) + + /** @see sendMessage */ + fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SendSendMessageResponse + + /** A view of [SendService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SendService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /send`, but is otherwise the same as + * [SendService.sendMessage]. + */ + @MustBeClosed + fun sendMessage(params: SendSendMessageParams): HttpResponseFor = + sendMessage(params, RequestOptions.none()) + + /** @see sendMessage */ + @MustBeClosed + fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt new file mode 100644 index 00000000..74328ce2 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse +import java.util.function.Consumer + +class SendServiceImpl internal constructor(private val clientOptions: ClientOptions) : SendService { + + private val withRawResponse: SendService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SendService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SendService = + SendServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions, + ): SendSendMessageResponse = + // post /send + withRawResponse().sendMessage(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SendService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SendService.WithRawResponse = + SendServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val sendMessageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun sendMessage( + params: SendSendMessageParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("send") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { sendMessageHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt new file mode 100644 index 00000000..a4259836 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt @@ -0,0 +1,349 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.tenants.Tenant +import com.courier.api.models.tenants.TenantDeleteParams +import com.courier.api.models.tenants.TenantListParams +import com.courier.api.models.tenants.TenantListResponse +import com.courier.api.models.tenants.TenantListUsersParams +import com.courier.api.models.tenants.TenantListUsersResponse +import com.courier.api.models.tenants.TenantRetrieveParams +import com.courier.api.models.tenants.TenantUpdateParams +import com.courier.api.services.blocking.tenants.DefaultPreferenceService +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface TenantService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TenantService + + fun defaultPreferences(): DefaultPreferenceService + + /** Get a Tenant */ + fun retrieve(tenantId: String): Tenant = retrieve(tenantId, TenantRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): Tenant = retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + ): Tenant = retrieve(tenantId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Tenant + + /** @see retrieve */ + fun retrieve(params: TenantRetrieveParams): Tenant = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(tenantId: String, requestOptions: RequestOptions): Tenant = + retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) + + /** Create or Replace a Tenant */ + fun update(tenantId: String, params: TenantUpdateParams): Tenant = + update(tenantId, params, RequestOptions.none()) + + /** @see update */ + fun update( + tenantId: String, + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Tenant = update(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see update */ + fun update(params: TenantUpdateParams): Tenant = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): Tenant + + /** Get a List of Tenants */ + fun list(): TenantListResponse = list(TenantListParams.none()) + + /** @see list */ + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TenantListResponse + + /** @see list */ + fun list(params: TenantListParams = TenantListParams.none()): TenantListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): TenantListResponse = + list(TenantListParams.none(), requestOptions) + + /** Delete a Tenant */ + fun delete(tenantId: String) = delete(tenantId, TenantDeleteParams.none()) + + /** @see delete */ + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see delete */ + fun delete(tenantId: String, params: TenantDeleteParams = TenantDeleteParams.none()) = + delete(tenantId, params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: TenantDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** @see delete */ + fun delete(params: TenantDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(tenantId: String, requestOptions: RequestOptions) = + delete(tenantId, TenantDeleteParams.none(), requestOptions) + + /** Get Users in Tenant */ + fun listUsers(tenantId: String): TenantListUsersResponse = + listUsers(tenantId, TenantListUsersParams.none()) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TenantListUsersResponse = + listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see listUsers */ + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + ): TenantListUsersResponse = listUsers(tenantId, params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TenantListUsersResponse + + /** @see listUsers */ + fun listUsers(params: TenantListUsersParams): TenantListUsersResponse = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + fun listUsers(tenantId: String, requestOptions: RequestOptions): TenantListUsersResponse = + listUsers(tenantId, TenantListUsersParams.none(), requestOptions) + + /** A view of [TenantService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TenantService.WithRawResponse + + fun defaultPreferences(): DefaultPreferenceService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}`, but is otherwise the same as + * [TenantService.retrieve]. + */ + @MustBeClosed + fun retrieve(tenantId: String): HttpResponseFor = + retrieve(tenantId, TenantRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + tenantId: String, + params: TenantRetrieveParams = TenantRetrieveParams.none(), + ): HttpResponseFor = retrieve(tenantId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TenantRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(tenantId: String, requestOptions: RequestOptions): HttpResponseFor = + retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /tenants/{tenant_id}`, but is otherwise the same as + * [TenantService.update]. + */ + @MustBeClosed + fun update(tenantId: String, params: TenantUpdateParams): HttpResponseFor = + update(tenantId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + tenantId: String, + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: TenantUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /tenants`, but is otherwise the same as + * [TenantService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(TenantListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: TenantListParams = TenantListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(TenantListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /tenants/{tenant_id}`, but is otherwise the same + * as [TenantService.delete]. + */ + @MustBeClosed + fun delete(tenantId: String): HttpResponse = delete(tenantId, TenantDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + tenantId: String, + params: TenantDeleteParams = TenantDeleteParams.none(), + ): HttpResponse = delete(tenantId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: TenantDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: TenantDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(tenantId: String, requestOptions: RequestOptions): HttpResponse = + delete(tenantId, TenantDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}/users`, but is otherwise the + * same as [TenantService.listUsers]. + */ + @MustBeClosed + fun listUsers(tenantId: String): HttpResponseFor = + listUsers(tenantId, TenantListUsersParams.none()) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + tenantId: String, + params: TenantListUsersParams = TenantListUsersParams.none(), + ): HttpResponseFor = + listUsers(tenantId, params, RequestOptions.none()) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listUsers */ + @MustBeClosed + fun listUsers(params: TenantListUsersParams): HttpResponseFor = + listUsers(params, RequestOptions.none()) + + /** @see listUsers */ + @MustBeClosed + fun listUsers( + tenantId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + listUsers(tenantId, TenantListUsersParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt new file mode 100644 index 00000000..5c770be6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt @@ -0,0 +1,238 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.tenants.Tenant +import com.courier.api.models.tenants.TenantDeleteParams +import com.courier.api.models.tenants.TenantListParams +import com.courier.api.models.tenants.TenantListResponse +import com.courier.api.models.tenants.TenantListUsersParams +import com.courier.api.models.tenants.TenantListUsersResponse +import com.courier.api.models.tenants.TenantRetrieveParams +import com.courier.api.models.tenants.TenantUpdateParams +import com.courier.api.services.blocking.tenants.DefaultPreferenceService +import com.courier.api.services.blocking.tenants.DefaultPreferenceServiceImpl +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TenantServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TenantService { + + private val withRawResponse: TenantService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val defaultPreferences: DefaultPreferenceService by lazy { + DefaultPreferenceServiceImpl(clientOptions) + } + + override fun withRawResponse(): TenantService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TenantService = + TenantServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun defaultPreferences(): DefaultPreferenceService = defaultPreferences + + override fun retrieve(params: TenantRetrieveParams, requestOptions: RequestOptions): Tenant = + // get /tenants/{tenant_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: TenantUpdateParams, requestOptions: RequestOptions): Tenant = + // put /tenants/{tenant_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): TenantListResponse = + // get /tenants + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: TenantDeleteParams, requestOptions: RequestOptions) { + // delete /tenants/{tenant_id} + withRawResponse().delete(params, requestOptions) + } + + override fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions, + ): TenantListUsersResponse = + // get /tenants/{tenant_id}/users + withRawResponse().listUsers(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TenantService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val defaultPreferences: DefaultPreferenceService.WithRawResponse by lazy { + DefaultPreferenceServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): TenantService.WithRawResponse = + TenantServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun defaultPreferences(): DefaultPreferenceService.WithRawResponse = + defaultPreferences + + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: TenantRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: TenantUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: TenantDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val listUsersHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listUsers( + params: TenantListUsersParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0), "users") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listUsersHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt new file mode 100644 index 00000000..ab880724 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.translations.TranslationRetrieveParams +import com.courier.api.models.translations.TranslationUpdateParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface TranslationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TranslationService + + /** Get translations by locale */ + fun retrieve(locale: String, params: TranslationRetrieveParams): String = + retrieve(locale, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + locale: String, + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): String = retrieve(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TranslationRetrieveParams): String = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): String + + /** Update a translation */ + fun update(locale: String, params: TranslationUpdateParams) = + update(locale, params, RequestOptions.none()) + + /** @see update */ + fun update( + locale: String, + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = update(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see update */ + fun update(params: TranslationUpdateParams) = update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * A view of [TranslationService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TranslationService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /translations/{domain}/{locale}`, but is otherwise + * the same as [TranslationService.retrieve]. + */ + @MustBeClosed + fun retrieve(locale: String, params: TranslationRetrieveParams): HttpResponseFor = + retrieve(locale, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + locale: String, + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TranslationRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /translations/{domain}/{locale}`, but is otherwise + * the same as [TranslationService.update]. + */ + @MustBeClosed + fun update(locale: String, params: TranslationUpdateParams): HttpResponse = + update(locale, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + locale: String, + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = update(params.toBuilder().locale(locale).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: TranslationUpdateParams): HttpResponse = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt new file mode 100644 index 00000000..c85efd33 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.stringHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.translations.TranslationRetrieveParams +import com.courier.api.models.translations.TranslationUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TranslationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TranslationService { + + private val withRawResponse: TranslationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TranslationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TranslationService = + TranslationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions, + ): String = + // get /translations/{domain}/{locale} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update(params: TranslationUpdateParams, requestOptions: RequestOptions) { + // put /translations/{domain}/{locale} + withRawResponse().update(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TranslationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TranslationService.WithRawResponse = + TranslationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = stringHandler() + + override fun retrieve( + params: TranslationRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("locale", params.locale().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { retrieveHandler.handle(it) } + } + } + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: TranslationUpdateParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("locale", params.locale().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt new file mode 100644 index 00000000..6c224ad7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.services.blocking.users.PreferenceService +import com.courier.api.services.blocking.users.TenantService +import com.courier.api.services.blocking.users.TokenService +import java.util.function.Consumer + +interface UserService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserService + + fun preferences(): PreferenceService + + fun tenants(): TenantService + + fun tokens(): TokenService + + /** A view of [UserService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): UserService.WithRawResponse + + fun preferences(): PreferenceService.WithRawResponse + + fun tenants(): TenantService.WithRawResponse + + fun tokens(): TokenService.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt new file mode 100644 index 00000000..eb048d51 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.core.ClientOptions +import com.courier.api.services.blocking.users.PreferenceService +import com.courier.api.services.blocking.users.PreferenceServiceImpl +import com.courier.api.services.blocking.users.TenantService +import com.courier.api.services.blocking.users.TenantServiceImpl +import com.courier.api.services.blocking.users.TokenService +import com.courier.api.services.blocking.users.TokenServiceImpl +import java.util.function.Consumer + +class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { + + private val withRawResponse: UserService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val preferences: PreferenceService by lazy { PreferenceServiceImpl(clientOptions) } + + private val tenants: TenantService by lazy { TenantServiceImpl(clientOptions) } + + private val tokens: TokenService by lazy { TokenServiceImpl(clientOptions) } + + override fun withRawResponse(): UserService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): UserService = + UserServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun preferences(): PreferenceService = preferences + + override fun tenants(): TenantService = tenants + + override fun tokens(): TokenService = tokens + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + UserService.WithRawResponse { + + private val preferences: PreferenceService.WithRawResponse by lazy { + PreferenceServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tenants: TenantService.WithRawResponse by lazy { + TenantServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val tokens: TokenService.WithRawResponse by lazy { + TokenServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): UserService.WithRawResponse = + UserServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun preferences(): PreferenceService.WithRawResponse = preferences + + override fun tenants(): TenantService.WithRawResponse = tenants + + override fun tokens(): TokenService.WithRawResponse = tokens + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt new file mode 100644 index 00000000..cbd025ff --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.automations + +import com.courier.api.core.ClientOptions +import java.util.function.Consumer + +interface InvokeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InvokeService + + /** A view of [InvokeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InvokeService.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt new file mode 100644 index 00000000..e2ebcaa0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.automations + +import com.courier.api.core.ClientOptions +import java.util.function.Consumer + +class InvokeServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InvokeService { + + private val withRawResponse: InvokeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): InvokeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): InvokeService = + InvokeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + InvokeService.WithRawResponse { + + override fun withOptions( + modifier: Consumer + ): InvokeService.WithRawResponse = + InvokeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt new file mode 100644 index 00000000..0b0d9a43 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.lists + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.lists.subscriptions.SubscriptionAddParams +import com.courier.api.models.lists.subscriptions.SubscriptionListParams +import com.courier.api.models.lists.subscriptions.SubscriptionListResponse +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams +import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface SubscriptionService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SubscriptionService + + /** Get the list's subscriptions. */ + fun list(listId: String): SubscriptionListResponse = list(listId, SubscriptionListParams.none()) + + /** @see list */ + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionListResponse = list(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see list */ + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + ): SubscriptionListResponse = list(listId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SubscriptionListResponse + + /** @see list */ + fun list(params: SubscriptionListParams): SubscriptionListResponse = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(listId: String, requestOptions: RequestOptions): SubscriptionListResponse = + list(listId, SubscriptionListParams.none(), requestOptions) + + /** + * Subscribes additional users to the list, without modifying existing subscriptions. If the + * list does not exist, it will be automatically created. + */ + fun add(listId: String, params: SubscriptionAddParams) = + add(listId, params, RequestOptions.none()) + + /** @see add */ + fun add( + listId: String, + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = add(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see add */ + fun add(params: SubscriptionAddParams) = add(params, RequestOptions.none()) + + /** @see add */ + fun add(params: SubscriptionAddParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** + * Subscribes the users to the list, overwriting existing subscriptions. If the list does not + * exist, it will be automatically created. + */ + fun subscribe(listId: String, params: SubscriptionSubscribeParams) = + subscribe(listId, params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + listId: String, + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = subscribe(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see subscribe */ + fun subscribe(params: SubscriptionSubscribeParams) = subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * Subscribe a user to an existing list (note: if the List does not exist, it will be + * automatically created). + */ + fun subscribeUser(userId: String, params: SubscriptionSubscribeUserParams) = + subscribeUser(userId, params, RequestOptions.none()) + + /** @see subscribeUser */ + fun subscribeUser( + userId: String, + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribeUser */ + fun subscribeUser(params: SubscriptionSubscribeUserParams) = + subscribeUser(params, RequestOptions.none()) + + /** @see subscribeUser */ + fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** Delete a subscription to a list by list ID and user ID. */ + fun unsubscribeUser(userId: String, params: SubscriptionUnsubscribeUserParams) = + unsubscribeUser(userId, params, RequestOptions.none()) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see unsubscribeUser */ + fun unsubscribeUser(params: SubscriptionUnsubscribeUserParams) = + unsubscribeUser(params, RequestOptions.none()) + + /** @see unsubscribeUser */ + fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * A view of [SubscriptionService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SubscriptionService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /lists/{list_id}/subscriptions`, but is otherwise + * the same as [SubscriptionService.list]. + */ + @MustBeClosed + fun list(listId: String): HttpResponseFor = + list(listId, SubscriptionListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + listId: String, + params: SubscriptionListParams = SubscriptionListParams.none(), + ): HttpResponseFor = list(listId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: SubscriptionListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + listId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(listId, SubscriptionListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /lists/{list_id}/subscriptions`, but is otherwise + * the same as [SubscriptionService.add]. + */ + @MustBeClosed + fun add(listId: String, params: SubscriptionAddParams): HttpResponse = + add(listId, params, RequestOptions.none()) + + /** @see add */ + @MustBeClosed + fun add( + listId: String, + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = add(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see add */ + @MustBeClosed + fun add(params: SubscriptionAddParams): HttpResponse = add(params, RequestOptions.none()) + + /** @see add */ + @MustBeClosed + fun add( + params: SubscriptionAddParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions`, but is otherwise + * the same as [SubscriptionService.subscribe]. + */ + @MustBeClosed + fun subscribe(listId: String, params: SubscriptionSubscribeParams): HttpResponse = + subscribe(listId, params, RequestOptions.none()) + + /** @see subscribe */ + @MustBeClosed + fun subscribe( + listId: String, + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = subscribe(params.toBuilder().listId(listId).build(), requestOptions) + + /** @see subscribe */ + @MustBeClosed + fun subscribe(params: SubscriptionSubscribeParams): HttpResponse = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + @MustBeClosed + fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions/{user_id}`, but is + * otherwise the same as [SubscriptionService.subscribeUser]. + */ + @MustBeClosed + fun subscribeUser(userId: String, params: SubscriptionSubscribeUserParams): HttpResponse = + subscribeUser(userId, params, RequestOptions.none()) + + /** @see subscribeUser */ + @MustBeClosed + fun subscribeUser( + userId: String, + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribeUser */ + @MustBeClosed + fun subscribeUser(params: SubscriptionSubscribeUserParams): HttpResponse = + subscribeUser(params, RequestOptions.none()) + + /** @see subscribeUser */ + @MustBeClosed + fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `delete /lists/{list_id}/subscriptions/{user_id}`, but is + * otherwise the same as [SubscriptionService.unsubscribeUser]. + */ + @MustBeClosed + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + ): HttpResponse = unsubscribeUser(userId, params, RequestOptions.none()) + + /** @see unsubscribeUser */ + @MustBeClosed + fun unsubscribeUser( + userId: String, + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see unsubscribeUser */ + @MustBeClosed + fun unsubscribeUser(params: SubscriptionUnsubscribeUserParams): HttpResponse = + unsubscribeUser(params, RequestOptions.none()) + + /** @see unsubscribeUser */ + @MustBeClosed + fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt new file mode 100644 index 00000000..62e4bab9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt @@ -0,0 +1,223 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.lists + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.lists.subscriptions.SubscriptionAddParams +import com.courier.api.models.lists.subscriptions.SubscriptionListParams +import com.courier.api.models.lists.subscriptions.SubscriptionListResponse +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams +import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionService { + + private val withRawResponse: SubscriptionService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SubscriptionService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SubscriptionService = + SubscriptionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions, + ): SubscriptionListResponse = + // get /lists/{list_id}/subscriptions + withRawResponse().list(params, requestOptions).parse() + + override fun add(params: SubscriptionAddParams, requestOptions: RequestOptions) { + // post /lists/{list_id}/subscriptions + withRawResponse().add(params, requestOptions) + } + + override fun subscribe(params: SubscriptionSubscribeParams, requestOptions: RequestOptions) { + // put /lists/{list_id}/subscriptions + withRawResponse().subscribe(params, requestOptions) + } + + override fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions, + ) { + // put /lists/{list_id}/subscriptions/{user_id} + withRawResponse().subscribeUser(params, requestOptions) + } + + override fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions, + ) { + // delete /lists/{list_id}/subscriptions/{user_id} + withRawResponse().unsubscribeUser(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SubscriptionService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SubscriptionService.WithRawResponse = + SubscriptionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SubscriptionListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "subscriptions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val addHandler: Handler = emptyHandler() + + override fun add( + params: SubscriptionAddParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "subscriptions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { addHandler.handle(it) } + } + } + + private val subscribeHandler: Handler = emptyHandler() + + override fun subscribe( + params: SubscriptionSubscribeParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("listId", params.listId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("lists", params._pathParam(0), "subscriptions") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { subscribeHandler.handle(it) } + } + } + + private val subscribeUserHandler: Handler = emptyHandler() + + override fun subscribeUser( + params: SubscriptionSubscribeUserParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "lists", + params._pathParam(0), + "subscriptions", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { subscribeUserHandler.handle(it) } + } + } + + private val unsubscribeUserHandler: Handler = emptyHandler() + + override fun unsubscribeUser( + params: SubscriptionUnsubscribeUserParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "lists", + params._pathParam(0), + "subscriptions", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { unsubscribeUserHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt new file mode 100644 index 00000000..407b8af0 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.notifications.checks.CheckDeleteParams +import com.courier.api.models.notifications.checks.CheckListParams +import com.courier.api.models.notifications.checks.CheckListResponse +import com.courier.api.models.notifications.checks.CheckUpdateParams +import com.courier.api.models.notifications.checks.CheckUpdateResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface CheckService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckService + + fun update(submissionId: String, params: CheckUpdateParams): CheckUpdateResponse = + update(submissionId, params, RequestOptions.none()) + + /** @see update */ + fun update( + submissionId: String, + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CheckUpdateResponse = + update(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see update */ + fun update(params: CheckUpdateParams): CheckUpdateResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CheckUpdateResponse + + fun list(submissionId: String, params: CheckListParams): CheckListResponse = + list(submissionId, params, RequestOptions.none()) + + /** @see list */ + fun list( + submissionId: String, + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CheckListResponse = + list(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see list */ + fun list(params: CheckListParams): CheckListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CheckListResponse + + fun delete(submissionId: String, params: CheckDeleteParams) = + delete(submissionId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + submissionId: String, + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see delete */ + fun delete(params: CheckDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: CheckDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** A view of [CheckService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CheckService.WithRawResponse + + /** + * Returns a raw HTTP response for `put /notifications/{id}/{submissionId}/checks`, but is + * otherwise the same as [CheckService.update]. + */ + @MustBeClosed + fun update( + submissionId: String, + params: CheckUpdateParams, + ): HttpResponseFor = + update(submissionId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + submissionId: String, + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: CheckUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /notifications/{id}/{submissionId}/checks`, but is + * otherwise the same as [CheckService.list]. + */ + @MustBeClosed + fun list( + submissionId: String, + params: CheckListParams, + ): HttpResponseFor = list(submissionId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + submissionId: String, + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list(params: CheckListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: CheckListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `delete /notifications/{id}/{submissionId}/checks`, but + * is otherwise the same as [CheckService.delete]. + */ + @MustBeClosed + fun delete(submissionId: String, params: CheckDeleteParams): HttpResponse = + delete(submissionId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + submissionId: String, + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: CheckDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: CheckDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt new file mode 100644 index 00000000..682835ba --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.notifications.checks.CheckDeleteParams +import com.courier.api.models.notifications.checks.CheckListParams +import com.courier.api.models.notifications.checks.CheckListResponse +import com.courier.api.models.notifications.checks.CheckUpdateParams +import com.courier.api.models.notifications.checks.CheckUpdateResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CheckServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CheckService { + + private val withRawResponse: CheckService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CheckService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CheckService = + CheckServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions, + ): CheckUpdateResponse = + // put /notifications/{id}/{submissionId}/checks + withRawResponse().update(params, requestOptions).parse() + + override fun list(params: CheckListParams, requestOptions: RequestOptions): CheckListResponse = + // get /notifications/{id}/{submissionId}/checks + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: CheckDeleteParams, requestOptions: RequestOptions) { + // delete /notifications/{id}/{submissionId}/checks + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CheckService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CheckService.WithRawResponse = + CheckServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: CheckUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("submissionId", params.submissionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "notifications", + params._pathParam(0), + params._pathParam(1), + "checks", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: CheckListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("submissionId", params.submissionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "notifications", + params._pathParam(0), + params._pathParam(1), + "checks", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: CheckDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("submissionId", params.submissionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "notifications", + params._pathParam(0), + params._pathParam(1), + "checks", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt new file mode 100644 index 00000000..ce4dc76f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.draft.DraftRetrieveContentParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface DraftService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DraftService + + fun retrieveContent(id: String): NotificationGetContent = + retrieveContent(id, DraftRetrieveContentParams.none()) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): NotificationGetContent = retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + ): NotificationGetContent = retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): NotificationGetContent + + /** @see retrieveContent */ + fun retrieveContent(params: DraftRetrieveContentParams): NotificationGetContent = + retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + fun retrieveContent(id: String, requestOptions: RequestOptions): NotificationGetContent = + retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) + + /** A view of [DraftService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DraftService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /notifications/{id}/draft/content`, but is otherwise + * the same as [DraftService.retrieveContent]. + */ + @MustBeClosed + fun retrieveContent(id: String): HttpResponseFor = + retrieveContent(id, DraftRetrieveContentParams.none()) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveContent(params.toBuilder().id(id).build(), requestOptions) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + id: String, + params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), + ): HttpResponseFor = + retrieveContent(id, params, RequestOptions.none()) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + params: DraftRetrieveContentParams + ): HttpResponseFor = retrieveContent(params, RequestOptions.none()) + + /** @see retrieveContent */ + @MustBeClosed + fun retrieveContent( + id: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt new file mode 100644 index 00000000..695d2c99 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.notifications + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.notifications.NotificationGetContent +import com.courier.api.models.notifications.draft.DraftRetrieveContentParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class DraftServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DraftService { + + private val withRawResponse: DraftService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): DraftService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DraftService = + DraftServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions, + ): NotificationGetContent = + // get /notifications/{id}/draft/content + withRawResponse().retrieveContent(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DraftService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): DraftService.WithRawResponse = + DraftServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveContentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveContent( + params: DraftRetrieveContentParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("id", params.id().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("notifications", params._pathParam(0), "draft", "content") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveContentHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt new file mode 100644 index 00000000..1b552764 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.profiles + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.profiles.lists.ListDeleteParams +import com.courier.api.models.profiles.lists.ListDeleteResponse +import com.courier.api.models.profiles.lists.ListRetrieveParams +import com.courier.api.models.profiles.lists.ListRetrieveResponse +import com.courier.api.models.profiles.lists.ListSubscribeParams +import com.courier.api.models.profiles.lists.ListSubscribeResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface ListService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListService + + /** Returns the subscribed lists for a specified user. */ + fun retrieve(userId: String): ListRetrieveResponse = retrieve(userId, ListRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ListRetrieveResponse = retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): ListRetrieveResponse = retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ListRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: ListRetrieveParams): ListRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(userId: String, requestOptions: RequestOptions): ListRetrieveResponse = + retrieve(userId, ListRetrieveParams.none(), requestOptions) + + /** Removes all list subscriptions for given user. */ + fun delete(userId: String): ListDeleteResponse = delete(userId, ListDeleteParams.none()) + + /** @see delete */ + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ListDeleteResponse = delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): ListDeleteResponse = delete(userId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ListDeleteResponse + + /** @see delete */ + fun delete(params: ListDeleteParams): ListDeleteResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(userId: String, requestOptions: RequestOptions): ListDeleteResponse = + delete(userId, ListDeleteParams.none(), requestOptions) + + /** + * Subscribes the given user to one or more lists. If the list does not exist, it will be + * created. + */ + fun subscribe(userId: String, params: ListSubscribeParams): ListSubscribeResponse = + subscribe(userId, params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + userId: String, + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ListSubscribeResponse = subscribe(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribe */ + fun subscribe(params: ListSubscribeParams): ListSubscribeResponse = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ListSubscribeResponse + + /** A view of [ListService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ListService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /profiles/{user_id}/lists`, but is otherwise the + * same as [ListService.retrieve]. + */ + @MustBeClosed + fun retrieve(userId: String): HttpResponseFor = + retrieve(userId, ListRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + params: ListRetrieveParams = ListRetrieveParams.none(), + ): HttpResponseFor = retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: ListRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(userId, ListRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /profiles/{user_id}/lists`, but is otherwise the + * same as [ListService.delete]. + */ + @MustBeClosed + fun delete(userId: String): HttpResponseFor = + delete(userId, ListDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + userId: String, + params: ListDeleteParams = ListDeleteParams.none(), + ): HttpResponseFor = delete(userId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see delete */ + @MustBeClosed + fun delete(params: ListDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + userId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(userId, ListDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /profiles/{user_id}/lists`, but is otherwise the + * same as [ListService.subscribe]. + */ + @MustBeClosed + fun subscribe( + userId: String, + params: ListSubscribeParams, + ): HttpResponseFor = subscribe(userId, params, RequestOptions.none()) + + /** @see subscribe */ + @MustBeClosed + fun subscribe( + userId: String, + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + subscribe(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see subscribe */ + @MustBeClosed + fun subscribe(params: ListSubscribeParams): HttpResponseFor = + subscribe(params, RequestOptions.none()) + + /** @see subscribe */ + @MustBeClosed + fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt new file mode 100644 index 00000000..3ba26fa7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.profiles + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.profiles.lists.ListDeleteParams +import com.courier.api.models.profiles.lists.ListDeleteResponse +import com.courier.api.models.profiles.lists.ListRetrieveParams +import com.courier.api.models.profiles.lists.ListRetrieveResponse +import com.courier.api.models.profiles.lists.ListSubscribeParams +import com.courier.api.models.profiles.lists.ListSubscribeResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ListServiceImpl internal constructor(private val clientOptions: ClientOptions) : ListService { + + private val withRawResponse: ListService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ListService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ListService = + ListServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): ListRetrieveResponse = + // get /profiles/{user_id}/lists + withRawResponse().retrieve(params, requestOptions).parse() + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): ListDeleteResponse = + // delete /profiles/{user_id}/lists + withRawResponse().delete(params, requestOptions).parse() + + override fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions, + ): ListSubscribeResponse = + // post /profiles/{user_id}/lists + withRawResponse().subscribe(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ListService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ListService.WithRawResponse = + ListServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: ListRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0), "lists") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: ListDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0), "lists") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val subscribeHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun subscribe( + params: ListSubscribeParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("profiles", params._pathParam(0), "lists") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { subscribeHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt new file mode 100644 index 00000000..d441fba9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.services.blocking.tenants.defaultpreferences.ItemService +import java.util.function.Consumer + +interface DefaultPreferenceService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DefaultPreferenceService + + fun items(): ItemService + + /** + * A view of [DefaultPreferenceService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DefaultPreferenceService.WithRawResponse + + fun items(): ItemService.WithRawResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt new file mode 100644 index 00000000..9d7b8c15 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.services.blocking.tenants.defaultpreferences.ItemService +import com.courier.api.services.blocking.tenants.defaultpreferences.ItemServiceImpl +import java.util.function.Consumer + +class DefaultPreferenceServiceImpl internal constructor(private val clientOptions: ClientOptions) : + DefaultPreferenceService { + + private val withRawResponse: DefaultPreferenceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val items: ItemService by lazy { ItemServiceImpl(clientOptions) } + + override fun withRawResponse(): DefaultPreferenceService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): DefaultPreferenceService = + DefaultPreferenceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun items(): ItemService = items + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + DefaultPreferenceService.WithRawResponse { + + private val items: ItemService.WithRawResponse by lazy { + ItemServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): DefaultPreferenceService.WithRawResponse = + DefaultPreferenceServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun items(): ItemService.WithRawResponse = items + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt new file mode 100644 index 00000000..7eea5039 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants.defaultpreferences + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams +import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface ItemService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemService + + /** Create or Replace Default Preferences For Topic */ + fun update(topicId: String, params: ItemUpdateParams) = + update(topicId, params, RequestOptions.none()) + + /** @see update */ + fun update( + topicId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = update(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see update */ + fun update(params: ItemUpdateParams) = update(params, RequestOptions.none()) + + /** @see update */ + fun update(params: ItemUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** Remove Default Preferences For Topic */ + fun delete(topicId: String, params: ItemDeleteParams) = + delete(topicId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + topicId: String, + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see delete */ + fun delete(params: ItemDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: ItemDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** A view of [ItemService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ItemService.WithRawResponse + + /** + * Returns a raw HTTP response for `put + * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as + * [ItemService.update]. + */ + @MustBeClosed + fun update(topicId: String, params: ItemUpdateParams): HttpResponse = + update(topicId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + topicId: String, + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = update(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: ItemUpdateParams): HttpResponse = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `delete + * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as + * [ItemService.delete]. + */ + @MustBeClosed + fun delete(topicId: String, params: ItemDeleteParams): HttpResponse = + delete(topicId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + topicId: String, + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: ItemDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: ItemDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt new file mode 100644 index 00000000..678ee62f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants.defaultpreferences + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams +import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { + + private val withRawResponse: ItemService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ItemService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ItemService = + ItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update(params: ItemUpdateParams, requestOptions: RequestOptions) { + // put /tenants/{tenant_id}/default_preferences/items/{topic_id} + withRawResponse().update(params, requestOptions) + } + + override fun delete(params: ItemDeleteParams, requestOptions: RequestOptions) { + // delete /tenants/{tenant_id}/default_preferences/items/{topic_id} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ItemService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ItemService.WithRawResponse = + ItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: ItemUpdateParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "tenants", + params._pathParam(0), + "default_preferences", + "items", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: ItemDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "tenants", + params._pathParam(0), + "default_preferences", + "items", + params._pathParam(1), + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt new file mode 100644 index 00000000..6d69a10b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.users.preferences.PreferenceRetrieveParams +import com.courier.api.models.users.preferences.PreferenceRetrieveResponse +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface PreferenceService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PreferenceService + + /** Fetch all user preferences. */ + fun retrieve(userId: String): PreferenceRetrieveResponse = + retrieve(userId, PreferenceRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceRetrieveResponse = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + ): PreferenceRetrieveResponse = retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: PreferenceRetrieveParams): PreferenceRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(userId: String, requestOptions: RequestOptions): PreferenceRetrieveResponse = + retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) + + /** Fetch user preferences for a specific subscription topic. */ + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + ): PreferenceRetrieveTopicResponse = retrieveTopic(topicId, params, RequestOptions.none()) + + /** @see retrieveTopic */ + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceRetrieveTopicResponse = + retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see retrieveTopic */ + fun retrieveTopic(params: PreferenceRetrieveTopicParams): PreferenceRetrieveTopicResponse = + retrieveTopic(params, RequestOptions.none()) + + /** @see retrieveTopic */ + fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceRetrieveTopicResponse + + /** Update or Create user preferences for a specific subscription topic. */ + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + ): PreferenceUpdateOrCreateTopicResponse = + updateOrCreateTopic(topicId, params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceUpdateOrCreateTopicResponse = + updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams + ): PreferenceUpdateOrCreateTopicResponse = updateOrCreateTopic(params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): PreferenceUpdateOrCreateTopicResponse + + /** A view of [PreferenceService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PreferenceService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /users/{user_id}/preferences`, but is otherwise the + * same as [PreferenceService.retrieve]. + */ + @MustBeClosed + fun retrieve(userId: String): HttpResponseFor = + retrieve(userId, PreferenceRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), + ): HttpResponseFor = + retrieve(userId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: PreferenceRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + userId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /users/{user_id}/preferences/{topic_id}`, but is + * otherwise the same as [PreferenceService.retrieveTopic]. + */ + @MustBeClosed + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + ): HttpResponseFor = + retrieveTopic(topicId, params, RequestOptions.none()) + + /** @see retrieveTopic */ + @MustBeClosed + fun retrieveTopic( + topicId: String, + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see retrieveTopic */ + @MustBeClosed + fun retrieveTopic( + params: PreferenceRetrieveTopicParams + ): HttpResponseFor = + retrieveTopic(params, RequestOptions.none()) + + /** @see retrieveTopic */ + @MustBeClosed + fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `put /users/{user_id}/preferences/{topic_id}`, but is + * otherwise the same as [PreferenceService.updateOrCreateTopic]. + */ + @MustBeClosed + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + ): HttpResponseFor = + updateOrCreateTopic(topicId, params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + @MustBeClosed + fun updateOrCreateTopic( + topicId: String, + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) + + /** @see updateOrCreateTopic */ + @MustBeClosed + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams + ): HttpResponseFor = + updateOrCreateTopic(params, RequestOptions.none()) + + /** @see updateOrCreateTopic */ + @MustBeClosed + fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt new file mode 100644 index 00000000..6b5a4f0d --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.users.preferences.PreferenceRetrieveParams +import com.courier.api.models.users.preferences.PreferenceRetrieveResponse +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class PreferenceServiceImpl internal constructor(private val clientOptions: ClientOptions) : + PreferenceService { + + private val withRawResponse: PreferenceService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): PreferenceService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): PreferenceService = + PreferenceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions, + ): PreferenceRetrieveResponse = + // get /users/{user_id}/preferences + withRawResponse().retrieve(params, requestOptions).parse() + + override fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions, + ): PreferenceRetrieveTopicResponse = + // get /users/{user_id}/preferences/{topic_id} + withRawResponse().retrieveTopic(params, requestOptions).parse() + + override fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions, + ): PreferenceUpdateOrCreateTopicResponse = + // put /users/{user_id}/preferences/{topic_id} + withRawResponse().updateOrCreateTopic(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + PreferenceService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): PreferenceService.WithRawResponse = + PreferenceServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: PreferenceRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "preferences") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveTopicHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveTopic( + params: PreferenceRetrieveTopicParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "users", + params._pathParam(0), + "preferences", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveTopicHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateOrCreateTopicHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun updateOrCreateTopic( + params: PreferenceUpdateOrCreateTopicParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("topicId", params.topicId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "users", + params._pathParam(0), + "preferences", + params._pathParam(1), + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateOrCreateTopicHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt new file mode 100644 index 00000000..67401748 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt @@ -0,0 +1,336 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.users.tenants.TenantAddMultipleParams +import com.courier.api.models.users.tenants.TenantAddSingleParams +import com.courier.api.models.users.tenants.TenantListParams +import com.courier.api.models.users.tenants.TenantListResponse +import com.courier.api.models.users.tenants.TenantRemoveAllParams +import com.courier.api.models.users.tenants.TenantRemoveSingleParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface TenantService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TenantService + + /** Returns a paginated list of user tenant associations. */ + fun list(userId: String): TenantListResponse = list(userId, TenantListParams.none()) + + /** @see list */ + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TenantListResponse = list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + ): TenantListResponse = list(userId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TenantListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TenantListResponse + + /** @see list */ + fun list(params: TenantListParams): TenantListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(userId: String, requestOptions: RequestOptions): TenantListResponse = + list(userId, TenantListParams.none(), requestOptions) + + /** + * This endpoint is used to add a user to multiple tenants in one call. A custom profile can + * also be supplied for each tenant. This profile will be merged with the user's main profile + * when sending to the user with that tenant. + */ + fun addMultiple(userId: String, params: TenantAddMultipleParams) = + addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + fun addMultiple(params: TenantAddMultipleParams) = addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** + * This endpoint is used to add a single tenant. + * + * A custom profile can also be supplied with the tenant. This profile will be merged with the + * user's main profile when sending to the user with that tenant. + */ + fun addSingle(tenantId: String, params: TenantAddSingleParams) = + addSingle(tenantId, params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + tenantId: String, + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see addSingle */ + fun addSingle(params: TenantAddSingleParams) = addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** Removes a user from any tenants they may have been associated with. */ + fun removeAll(userId: String) = removeAll(userId, TenantRemoveAllParams.none()) + + /** @see removeAll */ + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = removeAll(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see removeAll */ + fun removeAll(userId: String, params: TenantRemoveAllParams = TenantRemoveAllParams.none()) = + removeAll(userId, params, RequestOptions.none()) + + /** @see removeAll */ + fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see removeAll */ + fun removeAll(params: TenantRemoveAllParams) = removeAll(params, RequestOptions.none()) + + /** @see removeAll */ + fun removeAll(userId: String, requestOptions: RequestOptions) = + removeAll(userId, TenantRemoveAllParams.none(), requestOptions) + + /** Removes a user from the supplied tenant. */ + fun removeSingle(tenantId: String, params: TenantRemoveSingleParams) = + removeSingle(tenantId, params, RequestOptions.none()) + + /** @see removeSingle */ + fun removeSingle( + tenantId: String, + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see removeSingle */ + fun removeSingle(params: TenantRemoveSingleParams) = removeSingle(params, RequestOptions.none()) + + /** @see removeSingle */ + fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** A view of [TenantService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TenantService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /users/{user_id}/tenants`, but is otherwise the same + * as [TenantService.list]. + */ + @MustBeClosed + fun list(userId: String): HttpResponseFor = + list(userId, TenantListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + userId: String, + params: TenantListParams = TenantListParams.none(), + ): HttpResponseFor = list(userId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TenantListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: TenantListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + userId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(userId, TenantListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tenants`, but is otherwise the same + * as [TenantService.addMultiple]. + */ + @MustBeClosed + fun addMultiple(userId: String, params: TenantAddMultipleParams): HttpResponse = + addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple( + userId: String, + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple(params: TenantAddMultipleParams): HttpResponse = + addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tenants/{tenant_id}`, but is + * otherwise the same as [TenantService.addSingle]. + */ + @MustBeClosed + fun addSingle(tenantId: String, params: TenantAddSingleParams): HttpResponse = + addSingle(tenantId, params, RequestOptions.none()) + + /** @see addSingle */ + @MustBeClosed + fun addSingle( + tenantId: String, + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see addSingle */ + @MustBeClosed + fun addSingle(params: TenantAddSingleParams): HttpResponse = + addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + @MustBeClosed + fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `delete /users/{user_id}/tenants`, but is otherwise the + * same as [TenantService.removeAll]. + */ + @MustBeClosed + fun removeAll(userId: String): HttpResponse = + removeAll(userId, TenantRemoveAllParams.none()) + + /** @see removeAll */ + @MustBeClosed + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = removeAll(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see removeAll */ + @MustBeClosed + fun removeAll( + userId: String, + params: TenantRemoveAllParams = TenantRemoveAllParams.none(), + ): HttpResponse = removeAll(userId, params, RequestOptions.none()) + + /** @see removeAll */ + @MustBeClosed + fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see removeAll */ + @MustBeClosed + fun removeAll(params: TenantRemoveAllParams): HttpResponse = + removeAll(params, RequestOptions.none()) + + /** @see removeAll */ + @MustBeClosed + fun removeAll(userId: String, requestOptions: RequestOptions): HttpResponse = + removeAll(userId, TenantRemoveAllParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /users/{user_id}/tenants/{tenant_id}`, but is + * otherwise the same as [TenantService.removeSingle]. + */ + @MustBeClosed + fun removeSingle(tenantId: String, params: TenantRemoveSingleParams): HttpResponse = + removeSingle(tenantId, params, RequestOptions.none()) + + /** @see removeSingle */ + @MustBeClosed + fun removeSingle( + tenantId: String, + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = + removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see removeSingle */ + @MustBeClosed + fun removeSingle(params: TenantRemoveSingleParams): HttpResponse = + removeSingle(params, RequestOptions.none()) + + /** @see removeSingle */ + @MustBeClosed + fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt new file mode 100644 index 00000000..ac374fcb --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.users.tenants.TenantAddMultipleParams +import com.courier.api.models.users.tenants.TenantAddSingleParams +import com.courier.api.models.users.tenants.TenantListParams +import com.courier.api.models.users.tenants.TenantListResponse +import com.courier.api.models.users.tenants.TenantRemoveAllParams +import com.courier.api.models.users.tenants.TenantRemoveSingleParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TenantServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TenantService { + + private val withRawResponse: TenantService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TenantService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TenantService = + TenantServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): TenantListResponse = + // get /users/{user_id}/tenants + withRawResponse().list(params, requestOptions).parse() + + override fun addMultiple(params: TenantAddMultipleParams, requestOptions: RequestOptions) { + // put /users/{user_id}/tenants + withRawResponse().addMultiple(params, requestOptions) + } + + override fun addSingle(params: TenantAddSingleParams, requestOptions: RequestOptions) { + // put /users/{user_id}/tenants/{tenant_id} + withRawResponse().addSingle(params, requestOptions) + } + + override fun removeAll(params: TenantRemoveAllParams, requestOptions: RequestOptions) { + // delete /users/{user_id}/tenants + withRawResponse().removeAll(params, requestOptions) + } + + override fun removeSingle(params: TenantRemoveSingleParams, requestOptions: RequestOptions) { + // delete /users/{user_id}/tenants/{tenant_id} + withRawResponse().removeSingle(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TenantService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TenantService.WithRawResponse = + TenantServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TenantListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val addMultipleHandler: Handler = emptyHandler() + + override fun addMultiple( + params: TenantAddMultipleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { addMultipleHandler.handle(it) } + } + } + + private val addSingleHandler: Handler = emptyHandler() + + override fun addSingle( + params: TenantAddSingleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { addSingleHandler.handle(it) } + } + } + + private val removeAllHandler: Handler = emptyHandler() + + override fun removeAll( + params: TenantRemoveAllParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { removeAllHandler.handle(it) } + } + } + + private val removeSingleHandler: Handler = emptyHandler() + + override fun removeSingle( + params: TenantRemoveSingleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { removeSingleHandler.handle(it) } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt new file mode 100644 index 00000000..6c834e0e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt @@ -0,0 +1,375 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.users.tokens.TokenAddMultipleParams +import com.courier.api.models.users.tokens.TokenAddSingleParams +import com.courier.api.models.users.tokens.TokenDeleteParams +import com.courier.api.models.users.tokens.TokenListParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenUpdateParams +import com.courier.api.models.users.tokens.UserToken +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface TokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TokenService + + /** Apply a JSON Patch (RFC 6902) to the specified token. */ + fun update(token: String, params: TokenUpdateParams) = + update(token, params, RequestOptions.none()) + + /** @see update */ + fun update( + token: String, + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + fun update(params: TokenUpdateParams) = update(params, RequestOptions.none()) + + /** @see update */ + fun update(params: TokenUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** Gets all tokens available for a :user_id */ + fun list(userId: String): List = list(userId, TokenListParams.none()) + + /** @see list */ + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List = list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + fun list(userId: String, params: TokenListParams = TokenListParams.none()): List = + list(userId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list(params: TokenListParams): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(userId: String, requestOptions: RequestOptions): List = + list(userId, TokenListParams.none(), requestOptions) + + /** Delete User Token */ + fun delete(token: String, params: TokenDeleteParams) = + delete(token, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + token: String, + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().token(token).build(), requestOptions) + + /** @see delete */ + fun delete(params: TokenDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(params: TokenDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) + + /** Adds multiple tokens to a user and overwrites matching existing tokens. */ + fun addMultiple(userId: String) = addMultiple(userId, TokenAddMultipleParams.none()) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + ) = addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see addMultiple */ + fun addMultiple(params: TokenAddMultipleParams) = addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + fun addMultiple(userId: String, requestOptions: RequestOptions) = + addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) + + /** Adds a single token to a user and overwrites a matching existing token. */ + fun addSingle(pathToken: String, params: TokenAddSingleParams) = + addSingle(pathToken, params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + pathToken: String, + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) = addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) + + /** @see addSingle */ + fun addSingle(params: TokenAddSingleParams) = addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** Get single token available for a `:token` */ + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + ): TokenRetrieveSingleResponse = retrieveSingle(token, params, RequestOptions.none()) + + /** @see retrieveSingle */ + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenRetrieveSingleResponse = + retrieveSingle(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieveSingle */ + fun retrieveSingle(params: TokenRetrieveSingleParams): TokenRetrieveSingleResponse = + retrieveSingle(params, RequestOptions.none()) + + /** @see retrieveSingle */ + fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenRetrieveSingleResponse + + /** A view of [TokenService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `patch /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenService.update]. + */ + @MustBeClosed + fun update(token: String, params: TokenUpdateParams): HttpResponse = + update(token, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + token: String, + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = update(params.toBuilder().token(token).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update(params: TokenUpdateParams): HttpResponse = update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `get /users/{user_id}/tokens`, but is otherwise the same + * as [TokenService.list]. + */ + @MustBeClosed + fun list(userId: String): HttpResponseFor> = + list(userId, TokenListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> = + list(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + userId: String, + params: TokenListParams = TokenListParams.none(), + ): HttpResponseFor> = list(userId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TokenListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list(params: TokenListParams): HttpResponseFor> = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(userId: String, requestOptions: RequestOptions): HttpResponseFor> = + list(userId, TokenListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /users/{user_id}/tokens/{token}`, but is + * otherwise the same as [TokenService.delete]. + */ + @MustBeClosed + fun delete(token: String, params: TokenDeleteParams): HttpResponse = + delete(token, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + token: String, + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().token(token).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete(params: TokenDeleteParams): HttpResponse = delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: TokenDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tokens`, but is otherwise the same + * as [TokenService.addMultiple]. + */ + @MustBeClosed + fun addMultiple(userId: String): HttpResponse = + addMultiple(userId, TokenAddMultipleParams.none()) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple( + userId: String, + params: TokenAddMultipleParams = TokenAddMultipleParams.none(), + ): HttpResponse = addMultiple(userId, params, RequestOptions.none()) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple(params: TokenAddMultipleParams): HttpResponse = + addMultiple(params, RequestOptions.none()) + + /** @see addMultiple */ + @MustBeClosed + fun addMultiple(userId: String, requestOptions: RequestOptions): HttpResponse = + addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenService.addSingle]. + */ + @MustBeClosed + fun addSingle(pathToken: String, params: TokenAddSingleParams): HttpResponse = + addSingle(pathToken, params, RequestOptions.none()) + + /** @see addSingle */ + @MustBeClosed + fun addSingle( + pathToken: String, + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) + + /** @see addSingle */ + @MustBeClosed + fun addSingle(params: TokenAddSingleParams): HttpResponse = + addSingle(params, RequestOptions.none()) + + /** @see addSingle */ + @MustBeClosed + fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** + * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenService.retrieveSingle]. + */ + @MustBeClosed + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + ): HttpResponseFor = + retrieveSingle(token, params, RequestOptions.none()) + + /** @see retrieveSingle */ + @MustBeClosed + fun retrieveSingle( + token: String, + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieveSingle(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieveSingle */ + @MustBeClosed + fun retrieveSingle( + params: TokenRetrieveSingleParams + ): HttpResponseFor = + retrieveSingle(params, RequestOptions.none()) + + /** @see retrieveSingle */ + @MustBeClosed + fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt new file mode 100644 index 00000000..7c168b9f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.emptyHandler +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.users.tokens.TokenAddMultipleParams +import com.courier.api.models.users.tokens.TokenAddSingleParams +import com.courier.api.models.users.tokens.TokenDeleteParams +import com.courier.api.models.users.tokens.TokenListParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenUpdateParams +import com.courier.api.models.users.tokens.UserToken +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TokenService { + + private val withRawResponse: TokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TokenService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TokenService = + TokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun update(params: TokenUpdateParams, requestOptions: RequestOptions) { + // patch /users/{user_id}/tokens/{token} + withRawResponse().update(params, requestOptions) + } + + override fun list(params: TokenListParams, requestOptions: RequestOptions): List = + // get /users/{user_id}/tokens + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: TokenDeleteParams, requestOptions: RequestOptions) { + // delete /users/{user_id}/tokens/{token} + withRawResponse().delete(params, requestOptions) + } + + override fun addMultiple(params: TokenAddMultipleParams, requestOptions: RequestOptions) { + // put /users/{user_id}/tokens + withRawResponse().addMultiple(params, requestOptions) + } + + override fun addSingle(params: TokenAddSingleParams, requestOptions: RequestOptions) { + // put /users/{user_id}/tokens/{token} + withRawResponse().addSingle(params, requestOptions) + } + + override fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions, + ): TokenRetrieveSingleResponse = + // get /users/{user_id}/tokens/{token} + withRawResponse().retrieveSingle(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TokenService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TokenService.WithRawResponse = + TokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val updateHandler: Handler = emptyHandler() + + override fun update( + params: TokenUpdateParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PATCH) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { updateHandler.handle(it) } + } + } + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: TokenListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: TokenDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + + private val addMultipleHandler: Handler = emptyHandler() + + override fun addMultiple( + params: TokenAddMultipleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("userId", params.userId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { addMultipleHandler.handle(it) } + } + } + + private val addSingleHandler: Handler = emptyHandler() + + override fun addSingle( + params: TokenAddSingleParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("pathToken", params.pathToken().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { addSingleHandler.handle(it) } + } + } + + private val retrieveSingleHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieveSingle( + params: TokenRetrieveSingleParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveSingleHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro b/courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro new file mode 100644 index 00000000..6f41f07f --- /dev/null +++ b/courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro @@ -0,0 +1,32 @@ +# Jackson uses reflection and depends heavily on runtime attributes. +-keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* + +# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. +-keep class kotlin.reflect.** { *; } +-keep class kotlin.Metadata { *; } + +# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). +-keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { + ; + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +# Jackson uses reflection to access annotation members. +-keepclassmembers @interface com.fasterxml.jackson.annotation.** { + *; +} + +# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). +-keep class com.fasterxml.jackson.core.type.TypeReference { *; } +-keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } + +# Jackson uses reflection to access our class serializers and deserializers. +-keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.courier.api.** { *; } +-keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.courier.api.** { *; } + +# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. +-keepclassmembers class com.courier.api.** { + (...); + @com.fasterxml.jackson.annotation.* *; +} \ No newline at end of file diff --git a/courier-java-core/src/test/kotlin/com/courier/api/TestServerExtension.kt b/courier-java-core/src/test/kotlin/com/courier/api/TestServerExtension.kt new file mode 100644 index 00000000..546dca62 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/TestServerExtension.kt @@ -0,0 +1,62 @@ +package com.courier.api + +import java.lang.RuntimeException +import java.net.URL +import org.junit.jupiter.api.extension.BeforeAllCallback +import org.junit.jupiter.api.extension.ConditionEvaluationResult +import org.junit.jupiter.api.extension.ExecutionCondition +import org.junit.jupiter.api.extension.ExtensionContext + +class TestServerExtension : BeforeAllCallback, ExecutionCondition { + + override fun beforeAll(context: ExtensionContext?) { + try { + URL(BASE_URL).openConnection().connect() + } catch (e: Exception) { + throw RuntimeException( + """ + The test suite will not run without a mock Prism server running against your OpenAPI spec. + + You can set the environment variable `SKIP_MOCK_TESTS` to `true` to skip running any tests + that require the mock server. + + To fix: + + 1. Install Prism (requires Node 16+): + + With npm: + $ npm install -g @stoplight/prism-cli + + With yarn: + $ yarn global add @stoplight/prism-cli + + 2. Run the mock server + + To run the server, pass in the path of your OpenAPI spec to the prism command: + $ prism mock path/to/your.openapi.yml + """ + .trimIndent(), + e, + ) + } + } + + override fun evaluateExecutionCondition(context: ExtensionContext): ConditionEvaluationResult { + return if (System.getenv(SKIP_TESTS_ENV).toBoolean()) { + ConditionEvaluationResult.disabled( + "Environment variable $SKIP_TESTS_ENV is set to true" + ) + } else { + ConditionEvaluationResult.enabled( + "Environment variable $SKIP_TESTS_ENV is not set to true" + ) + } + } + + companion object { + + val BASE_URL = System.getenv("TEST_API_BASE_URL") ?: "http://localhost:4010" + + const val SKIP_TESTS_ENV: String = "SKIP_MOCK_TESTS" + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/ClientOptionsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/ClientOptionsTest.kt new file mode 100644 index 00000000..176b544a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/ClientOptionsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.core + +import com.courier.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/ObjectMappersTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/ObjectMappersTest.kt new file mode 100644 index 00000000..ac9af342 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/ObjectMappersTest.kt @@ -0,0 +1,102 @@ +package com.courier.api.core + +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.exc.MismatchedInputException +import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDateTime +import kotlin.reflect.KClass +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource +import org.junitpioneer.jupiter.cartesian.CartesianTest + +internal class ObjectMappersTest { + + internal class ClassWithBooleanFieldPrefixedWithIs(private val isActive: JsonField) { + + @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + } + + @Test + fun write_whenFieldPrefixedWithIs_keepsPrefix() { + val value = ClassWithBooleanFieldPrefixedWithIs(JsonField.of(true)) + + val json = jsonMapper().writeValueAsString(value) + + assertThat(json).isEqualTo("{\"is_active\":true}") + } + + internal class Class(@get:JsonProperty("field") @JsonProperty("field") val field: String) + + enum class ShapeTestCase(val value: Any, val kClass: KClass<*>) { + STRING("Hello World!", String::class), + BOOLEAN(true, Boolean::class), + FLOAT(3.14F, Float::class), + DOUBLE(3.14, Double::class), + INTEGER(42, Int::class), + LONG(42L, Long::class), + MAP(mapOf("property" to "value"), Map::class), + CLASS(Class("Hello World!"), Class::class), + LIST(listOf(1, 2, 3), List::class); + + companion object { + val VALID_CONVERSIONS = + listOf( + FLOAT to DOUBLE, + FLOAT to INTEGER, + FLOAT to LONG, + DOUBLE to FLOAT, + DOUBLE to INTEGER, + DOUBLE to LONG, + INTEGER to FLOAT, + INTEGER to DOUBLE, + INTEGER to LONG, + LONG to FLOAT, + LONG to DOUBLE, + LONG to INTEGER, + CLASS to MAP, + // These aren't actually valid, but coercion configs don't work for String until + // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 + // We currently test on v2.13.4. + BOOLEAN to STRING, + FLOAT to STRING, + DOUBLE to STRING, + INTEGER to STRING, + LONG to STRING, + ) + } + } + + @CartesianTest + fun read(@CartesianTest.Enum shape1: ShapeTestCase, @CartesianTest.Enum shape2: ShapeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(shape1.value) + + val e = catchThrowable { jsonMapper.readValue(json, shape2.kClass.java) } + + if (shape1 == shape2 || shape1 to shape2 in ShapeTestCase.VALID_CONVERSIONS) { + assertThat(e).isNull() + } else { + assertThat(e).isInstanceOf(MismatchedInputException::class.java) + } + } + + enum class LenientLocalDateTimeTestCase(val string: String) { + DATE("1998-04-21"), + DATE_TIME("1998-04-21T04:00:00"), + ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), + ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + } + + @ParameterizedTest + @EnumSource + fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + val jsonMapper = jsonMapper() + val json = jsonMapper.writeValueAsString(testCase.string) + + assertDoesNotThrow { jsonMapper().readValue(json) } + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/PhantomReachableTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/PhantomReachableTest.kt new file mode 100644 index 00000000..42bbd541 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/PhantomReachableTest.kt @@ -0,0 +1,27 @@ +package com.courier.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PhantomReachableTest { + + @Test + fun closeWhenPhantomReachable_whenObservedIsGarbageCollected_closesCloseable() { + var closed = false + val closeable = AutoCloseable { closed = true } + + closeWhenPhantomReachable( + // Pass an inline object for the object to observe so that it becomes immediately + // unreachable. + Any(), + closeable, + ) + + assertThat(closed).isFalse() + + System.gc() + Thread.sleep(100) + + assertThat(closed).isTrue() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/UtilsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/UtilsTest.kt new file mode 100644 index 00000000..25142f15 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/UtilsTest.kt @@ -0,0 +1,33 @@ +package com.courier.api.core + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtilsTest { + @Test + fun contentDeepEquals() { + assertThat(42 contentEquals 42).isTrue() + assertThat(42 contentEquals "Hello World!").isFalse() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 3)).isTrue() + assertThat(byteArrayOf(1, 2, 3) contentEquals byteArrayOf(1, 2, 4)).isFalse() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) + ) + .isTrue() + assertThat( + arrayOf(byteArrayOf(1, 2), byteArrayOf(3)) contentEquals + arrayOf(byteArrayOf(1), byteArrayOf(2, 3)) + ) + .isFalse() + } + + @Test + fun contentToString() { + assertThat((42).contentToString()).isEqualTo("42") + assertThat("Hello World!".contentToString()).isEqualTo("Hello World!") + assertThat(byteArrayOf(1, 2, 3).contentToString()).isEqualTo("[1, 2, 3]") + assertThat(arrayOf(byteArrayOf(1, 2), byteArrayOf(3)).contentToString()) + .isEqualTo("[[1, 2], [3]]") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/ValuesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/ValuesTest.kt new file mode 100644 index 00000000..76650e07 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/ValuesTest.kt @@ -0,0 +1,144 @@ +package com.courier.api.core + +import java.util.Optional +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ValuesTest { + companion object { + private val NON_JSON = Any() + } + + enum class TestCase( + val value: JsonField<*>, + val expectedIsMissing: Boolean = false, + val expectedIsNull: Boolean = false, + val expectedAsKnown: Optional<*> = Optional.empty(), + val expectedAsBoolean: Optional = Optional.empty(), + val expectedAsNumber: Optional = Optional.empty(), + val expectedAsString: Optional = Optional.empty(), + val expectedAsArray: Optional> = Optional.empty(), + val expectedAsObject: Optional> = Optional.empty(), + ) { + MISSING(JsonMissing.of(), expectedIsMissing = true), + NULL(JsonNull.of(), expectedIsNull = true), + KNOWN(KnownValue.of(NON_JSON), expectedAsKnown = Optional.of(NON_JSON)), + KNOWN_BOOLEAN( + KnownValue.of(true), + expectedAsKnown = Optional.of(true), + expectedAsBoolean = Optional.of(true), + ), + BOOLEAN(JsonBoolean.of(true), expectedAsBoolean = Optional.of(true)), + KNOWN_NUMBER( + KnownValue.of(42), + expectedAsKnown = Optional.of(42), + expectedAsNumber = Optional.of(42), + ), + NUMBER(JsonNumber.of(42), expectedAsNumber = Optional.of(42)), + KNOWN_STRING( + KnownValue.of("hello"), + expectedAsKnown = Optional.of("hello"), + expectedAsString = Optional.of("hello"), + ), + STRING(JsonString.of("hello"), expectedAsString = Optional.of("hello")), + KNOWN_ARRAY_NOT_ALL_JSON( + KnownValue.of(listOf("a", "b", NON_JSON)), + expectedAsKnown = Optional.of(listOf("a", "b", NON_JSON)), + ), + KNOWN_ARRAY( + KnownValue.of(listOf("a", "b", "c")), + expectedAsKnown = Optional.of(listOf("a", "b", "c")), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + ARRAY( + JsonArray.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + expectedAsArray = + Optional.of(listOf(JsonString.of("a"), JsonString.of("b"), JsonString.of("c"))), + ), + KNOWN_OBJECT_NOT_ALL_STRING_KEYS( + KnownValue.of(mapOf("a" to "b", 42 to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", 42 to "c")), + ), + KNOWN_OBJECT_NOT_ALL_JSON( + KnownValue.of(mapOf("a" to "b", "b" to NON_JSON)), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to NON_JSON)), + ), + KNOWN_OBJECT( + KnownValue.of(mapOf("a" to "b", "b" to "c")), + expectedAsKnown = Optional.of(mapOf("a" to "b", "b" to "c")), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + OBJECT( + JsonObject.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + expectedAsObject = + Optional.of(mapOf("a" to JsonString.of("b"), "b" to JsonString.of("c"))), + ), + } + + @ParameterizedTest + @EnumSource + fun isMissing(testCase: TestCase) { + val isMissing = testCase.value.isMissing() + + assertThat(isMissing).isEqualTo(testCase.expectedIsMissing) + } + + @ParameterizedTest + @EnumSource + fun isNull(testCase: TestCase) { + val isNull = testCase.value.isNull() + + assertThat(isNull).isEqualTo(testCase.expectedIsNull) + } + + @ParameterizedTest + @EnumSource + fun asKnown(testCase: TestCase) { + val known = testCase.value.asKnown() + + assertThat(known).isEqualTo(testCase.expectedAsKnown) + } + + @ParameterizedTest + @EnumSource + fun asBoolean(testCase: TestCase) { + val boolean = testCase.value.asBoolean() + + assertThat(boolean).isEqualTo(testCase.expectedAsBoolean) + } + + @ParameterizedTest + @EnumSource + fun asNumber(testCase: TestCase) { + val number = testCase.value.asNumber() + + assertThat(number).isEqualTo(testCase.expectedAsNumber) + } + + @ParameterizedTest + @EnumSource + fun asString(testCase: TestCase) { + val string = testCase.value.asString() + + assertThat(string).isEqualTo(testCase.expectedAsString) + } + + @ParameterizedTest + @EnumSource + fun asArray(testCase: TestCase) { + val array = testCase.value.asArray() + + assertThat(array).isEqualTo(testCase.expectedAsArray) + } + + @ParameterizedTest + @EnumSource + fun asObject(testCase: TestCase) { + val obj = testCase.value.asObject() + + assertThat(obj).isEqualTo(testCase.expectedAsObject) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/http/AsyncStreamResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/http/AsyncStreamResponseTest.kt new file mode 100644 index 00000000..322747c4 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/http/AsyncStreamResponseTest.kt @@ -0,0 +1,268 @@ +package com.courier.api.core.http + +import java.util.* +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import java.util.stream.Stream +import kotlin.streams.asStream +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.catchThrowable +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.* + +@ExtendWith(MockitoExtension::class) +internal class AsyncStreamResponseTest { + + companion object { + private val ERROR = RuntimeException("ERROR!") + } + + private val streamResponse = + spy> { + doReturn(Stream.of("chunk1", "chunk2", "chunk3")).whenever(it).stream() + } + private val erroringStreamResponse = + spy> { + doReturn( + sequence { + yield("chunk1") + yield("chunk2") + throw ERROR + } + .asStream() + ) + .whenever(it) + .stream() + } + private val executor = + spy { + doAnswer { invocation -> invocation.getArgument(0).run() } + .whenever(it) + .execute(any()) + } + private val handler = mock>() + + @Test + fun subscribe_whenAlreadySubscribed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.subscribe {} + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe more than once") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenClosed_throws() { + val asyncStreamResponse = CompletableFuture>().toAsync(executor) + asyncStreamResponse.close() + + val throwable = catchThrowable { asyncStreamResponse.subscribe {} } + + assertThat(throwable).isInstanceOf(IllegalStateException::class.java) + assertThat(throwable).hasMessage("Cannot subscribe after the response is closed") + verify(executor, never()).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletesAfterClose_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + asyncStreamResponse.close() + + future.complete(streamResponse) + + verify(handler, never()).onNext(any()) + verify(handler, never()).onComplete(any()) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureErrors_callsOnComplete() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.completeExceptionally(ERROR) + + verify(handler, never()).onNext(any()) + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenFutureCompletes_runsHandler() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(streamResponse) + + inOrder(handler, streamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onNext("chunk3") + verify(handler, times(1)).onComplete(Optional.empty()) + verify(streamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun subscribe_whenStreamErrors_callsOnCompleteEarly() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + + future.complete(erroringStreamResponse) + + inOrder(handler, erroringStreamResponse) { + verify(handler, times(1)).onNext("chunk1") + verify(handler, times(1)).onNext("chunk2") + verify(handler, times(1)).onComplete(Optional.of(ERROR)) + verify(erroringStreamResponse, times(1)).close() + } + verify(executor, times(1)).execute(any()) + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureNotCompleted_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.completeExceptionally(ERROR) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedButStillStreaming_onCompleteFutureNotCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isNotCompleted + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamErrors_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenStreamResponseFutureCompletedAndStreamCompleted_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe(handler) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithoutThrowableThrows_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(streamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun onCompleteFuture_whenHandlerOnCompleteWithThrowableThrows_onCompleteFutureCompletedExceptionally() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.subscribe( + object : AsyncStreamResponse.Handler { + override fun onNext(value: String) {} + + override fun onComplete(error: Optional) = throw ERROR + } + ) + future.complete(erroringStreamResponse) + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompletedExceptionally + } + + @Test + fun onCompleteFuture_whenClosed_onCompleteFutureCompleted() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + val onCompletableFuture = asyncStreamResponse.onCompleteFuture() + + assertThat(onCompletableFuture).isCompleted + } + + @Test + fun close_whenNotClosed_closesStreamResponse() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + + asyncStreamResponse.close() + future.complete(streamResponse) + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenAlreadyClosed_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + future.complete(streamResponse) + + asyncStreamResponse.close() + + verify(streamResponse, times(1)).close() + } + + @Test + fun close_whenFutureErrors_doesNothing() { + val future = CompletableFuture>() + val asyncStreamResponse = future.toAsync(executor) + asyncStreamResponse.close() + + assertDoesNotThrow { future.completeExceptionally(ERROR) } + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/http/HeadersTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/http/HeadersTest.kt new file mode 100644 index 00000000..135d4a9a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/http/HeadersTest.kt @@ -0,0 +1,242 @@ +package com.courier.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HeadersTest { + + enum class TestCase( + val headers: Headers, + val expectedMap: Map>, + val expectedSize: Int, + ) { + EMPTY(Headers.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + Headers.builder().put("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT( + Headers.builder().put("name1", "value").put("name2", "value").build(), + expectedMap = mapOf("name1" to listOf("value"), "name2" to listOf("value")), + expectedSize = 2, + ), + MULTIPLE_PUT_SAME_NAME( + Headers.builder().put("name", "value1").put("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .put("name", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .put("NAME", "value2") + .put("nAmE", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + PUT_ALL_MAP( + Headers.builder() + .putAll( + mapOf( + "name1" to listOf("value1", "value2"), + "name2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("name1" to listOf("value1", "value2"), "name2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + Headers.builder().putAll(Headers.builder().put("name", "value").build()).build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + PUT_ALL_CASE_INSENSITIVE( + Headers.builder() + .putAll( + mapOf( + "name" to listOf("value1"), + "NAME" to listOf("value2"), + "nAmE" to listOf("value3"), + ) + ) + .build(), + expectedMap = mapOf("name" to listOf("value1", "value2", "value3")), + expectedSize = 3, + ), + REMOVE_ABSENT( + Headers.builder().remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + Headers.builder().put("name", "value").remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + Headers.builder().put("name", listOf("value1", "value2")).remove("name").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_CASE_INSENSITIVE( + Headers.builder().put("name", listOf("value1", "value2")).remove("NAME").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("name1", "name2", "name3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value") + .put("name3", "value") + .removeAll(setOf("NAME1", "nAmE3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + Headers.builder().put("name1", "value").put("name2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + Headers.builder().replace("name", "value").build(), + expectedMap = mapOf("name" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + Headers.builder().put("name", "value1").replace("name", "value2").build(), + expectedMap = mapOf("name" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", "value3") + .build(), + expectedMap = mapOf("name" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + Headers.builder().replace("name", listOf("value1", "value2")).build(), + expectedMap = mapOf("name" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + Headers.builder() + .put("name", "value1") + .replace("name", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("name" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + Headers.builder() + .put("name", listOf("value1", "value2")) + .replace("name", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("name" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_CASE_INSENSITIVE( + Headers.builder() + .put("name", "value1") + .replace("NAME", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("NAME" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(mapOf("name1" to listOf("value2"), "name3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .put("name3", "value1") + .replaceAll(Headers.builder().put("name1", "value2").put("name3", "value2").build()) + .build(), + expectedMap = + mapOf( + "name1" to listOf("value2"), + "name2" to listOf("value1"), + "name3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_CASE_INSENSITIVE( + Headers.builder() + .put("name1", "value1") + .put("name2", "value1") + .replaceAll(mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2"))) + .build(), + expectedMap = mapOf("NAME1" to listOf("value2"), "nAmE2" to listOf("value2")), + expectedSize = 2, + ), + } + + @ParameterizedTest + @EnumSource + fun namesAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val headers = testCase.headers + headers.names().forEach { name -> map[name] = headers.values(name) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun caseInsensitiveNames(testCase: TestCase) { + val headers = testCase.headers + + for (name in headers.names()) { + assertThat(headers.values(name)).isEqualTo(headers.values(name.lowercase())) + assertThat(headers.values(name)).isEqualTo(headers.values(name.uppercase())) + } + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.headers.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/http/QueryParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/http/QueryParamsTest.kt new file mode 100644 index 00000000..1195d807 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/http/QueryParamsTest.kt @@ -0,0 +1,180 @@ +package com.courier.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class QueryParamsTest { + + enum class TestCase( + val queryParams: QueryParams, + val expectedMap: Map>, + val expectedSize: Int, + ) { + EMPTY(QueryParams.builder().build(), expectedMap = mapOf(), expectedSize = 0), + PUT_ONE( + QueryParams.builder().put("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + PUT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT( + QueryParams.builder().put("key1", "value").put("key2", "value").build(), + expectedMap = mapOf("key1" to listOf("value"), "key2" to listOf("value")), + expectedSize = 2, + ), + MULTIPLE_PUT_SAME_NAME( + QueryParams.builder().put("key", "value1").put("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + MULTIPLE_PUT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .put("key", listOf("value1", "value2")) + .build(), + expectedMap = mapOf("key" to listOf("value1", "value2", "value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_MAP( + QueryParams.builder() + .putAll( + mapOf( + "key1" to listOf("value1", "value2"), + "key2" to listOf("value1", "value2"), + ) + ) + .build(), + expectedMap = + mapOf("key1" to listOf("value1", "value2"), "key2" to listOf("value1", "value2")), + expectedSize = 4, + ), + PUT_ALL_HEADERS( + QueryParams.builder().putAll(QueryParams.builder().put("key", "value").build()).build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REMOVE_ABSENT( + QueryParams.builder().remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_ONE( + QueryParams.builder().put("key", "value").remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_PRESENT_MULTIPLE( + QueryParams.builder().put("key", listOf("value1", "value2")).remove("key").build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REMOVE_ALL( + QueryParams.builder() + .put("key1", "value") + .put("key3", "value") + .removeAll(setOf("key1", "key2", "key3")) + .build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + CLEAR( + QueryParams.builder().put("key1", "value").put("key2", "value").clear().build(), + expectedMap = mapOf(), + expectedSize = 0, + ), + REPLACE_ONE_ABSENT( + QueryParams.builder().replace("key", "value").build(), + expectedMap = mapOf("key" to listOf("value")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_ONE( + QueryParams.builder().put("key", "value1").replace("key", "value2").build(), + expectedMap = mapOf("key" to listOf("value2")), + expectedSize = 1, + ), + REPLACE_ONE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", "value3") + .build(), + expectedMap = mapOf("key" to listOf("value3")), + expectedSize = 1, + ), + REPLACE_MULTIPLE_ABSENT( + QueryParams.builder().replace("key", listOf("value1", "value2")).build(), + expectedMap = mapOf("key" to listOf("value1", "value2")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_ONE( + QueryParams.builder() + .put("key", "value1") + .replace("key", listOf("value2", "value3")) + .build(), + expectedMap = mapOf("key" to listOf("value2", "value3")), + expectedSize = 2, + ), + REPLACE_MULTIPLE_PRESENT_MULTIPLE( + QueryParams.builder() + .put("key", listOf("value1", "value2")) + .replace("key", listOf("value3", "value4")) + .build(), + expectedMap = mapOf("key" to listOf("value3", "value4")), + expectedSize = 2, + ), + REPLACE_ALL_MAP( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll(mapOf("key1" to listOf("value2"), "key3" to listOf("value2"))) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + REPLACE_ALL_HEADERS( + QueryParams.builder() + .put("key1", "value1") + .put("key2", "value1") + .put("key3", "value1") + .replaceAll( + QueryParams.builder().put("key1", "value2").put("key3", "value2").build() + ) + .build(), + expectedMap = + mapOf( + "key1" to listOf("value2"), + "key2" to listOf("value1"), + "key3" to listOf("value2"), + ), + expectedSize = 3, + ), + } + + @ParameterizedTest + @EnumSource + fun keysAndValues(testCase: TestCase) { + val map = mutableMapOf>() + val queryParams = testCase.queryParams + queryParams.keys().forEach { key -> map[key] = queryParams.values(key) } + + assertThat(map).isEqualTo(testCase.expectedMap) + } + + @ParameterizedTest + @EnumSource + fun size(testCase: TestCase) { + val size = testCase.queryParams.size + + assertThat(size).isEqualTo(testCase.expectedSize) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/core/http/RetryingHttpClientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/core/http/RetryingHttpClientTest.kt new file mode 100644 index 00000000..9c861ede --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/core/http/RetryingHttpClientTest.kt @@ -0,0 +1,356 @@ +package com.courier.api.core.http + +import com.courier.api.client.okhttp.OkHttpClient +import com.courier.api.core.RequestOptions +import com.courier.api.core.Sleeper +import com.courier.api.errors.CourierRetryableException +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import com.github.tomakehurst.wiremock.stubbing.Scenario +import java.io.InputStream +import java.time.Duration +import java.util.concurrent.CompletableFuture +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.parallel.ResourceLock +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.ValueSource + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class RetryingHttpClientTest { + + private var openResponseCount = 0 + private lateinit var baseUrl: String + private lateinit var httpClient: HttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() + httpClient = + object : HttpClient { + + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse = trackClose(okHttpClient.execute(request, requestOptions)) + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture = + okHttpClient.executeAsync(request, requestOptions).thenApply { trackClose(it) } + + override fun close() = okHttpClient.close() + + private fun trackClose(response: HttpResponse): HttpResponse { + openResponseCount++ + return object : HttpResponse { + + private var isClosed = false + + override fun statusCode(): Int = response.statusCode() + + override fun headers(): Headers = response.headers() + + override fun body(): InputStream = response.body() + + override fun close() { + response.close() + if (isClosed) { + return + } + openResponseCount-- + isClosed = true + } + } + } + } + resetAllScenarios() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val retryingClient = retryingHttpClientBuilder().build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withIdempotencyHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .withHeader("X-Some-Header", matching("stainless-java-retry-.+")) + .willReturn(ok()) + ) + val retryingClient = + retryingHttpClientBuilder().maxRetries(2).idempotencyHeader("X-Some-Header").build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(1, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + // First we fail with a retry after header given as a date + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + // Then we fail with a retry after header given as a delay + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(serviceUnavailable().withHeader("Retry-After", "1.234")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + // Then we return a success + .inScenario("foo") + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("2")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withOverwrittenRetryCountHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // first we fail with a retry after header given as a date + .whenScenarioStateIs(Scenario.STARTED) + .willReturn( + serviceUnavailable().withHeader("Retry-After", "Wed, 21 Oct 2015 07:28:00 GMT") + ) + .willSetStateTo("RETRY_AFTER_DATE") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DATE") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(2).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .putHeader("x-stainless-retry-count", "42") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 2, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("42")), + ) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryAfterMsHeader(async: Boolean) { + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") + .whenScenarioStateIs(Scenario.STARTED) + .willReturn(serviceUnavailable().withHeader("Retry-After-Ms", "10")) + .willSetStateTo("RETRY_AFTER_DELAY") + ) + stubFor( + post(urlPathEqualTo("/something")) + .inScenario("foo") // then we return a success + .whenScenarioStateIs("RETRY_AFTER_DELAY") + .willReturn(ok()) + .willSetStateTo("COMPLETED") + ) + val retryingClient = retryingHttpClientBuilder().maxRetries(1).build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify(2, postRequestedFor(urlPathEqualTo("/something"))) + assertNoResponseLeaks() + } + + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun execute_withRetryableException(async: Boolean) { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + + var callCount = 0 + val failingHttpClient = + object : HttpClient { + override fun execute( + request: HttpRequest, + requestOptions: RequestOptions, + ): HttpResponse { + callCount++ + if (callCount == 1) { + throw CourierRetryableException("Simulated retryable failure") + } + return httpClient.execute(request, requestOptions) + } + + override fun executeAsync( + request: HttpRequest, + requestOptions: RequestOptions, + ): CompletableFuture { + callCount++ + if (callCount == 1) { + val future = CompletableFuture() + future.completeExceptionally( + CourierRetryableException("Simulated retryable failure") + ) + return future + } + return httpClient.executeAsync(request, requestOptions) + } + + override fun close() = httpClient.close() + } + + val retryingClient = + RetryingHttpClient.builder() + .httpClient(failingHttpClient) + .maxRetries(2) + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + .build() + + val response = + retryingClient.execute( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), + async, + ) + + assertThat(response.statusCode()).isEqualTo(200) + verify( + 1, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("1")), + ) + verify( + 0, + postRequestedFor(urlPathEqualTo("/something")) + .withHeader("x-stainless-retry-count", equalTo("0")), + ) + assertNoResponseLeaks() + } + + private fun retryingHttpClientBuilder() = + RetryingHttpClient.builder() + .httpClient(httpClient) + // Use a no-op `Sleeper` to make the test fast. + .sleeper( + object : Sleeper { + + override fun sleep(duration: Duration) {} + + override fun sleepAsync(duration: Duration): CompletableFuture = + CompletableFuture.completedFuture(null) + + override fun close() {} + } + ) + + private fun HttpClient.execute(request: HttpRequest, async: Boolean): HttpResponse = + if (async) executeAsync(request).get() else execute(request) + + // When retrying, all failed responses should be closed. Only the final returned response should + // be open. + private fun assertNoResponseLeaks() = assertThat(openResponseCount).isEqualTo(1) +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt new file mode 100644 index 00000000..3525755a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceDeleteParamsTest { + + @Test + fun create() { + AudienceDeleteParams.builder().audienceId("audience_id").build() + } + + @Test + fun pathParams() { + val params = AudienceDeleteParams.builder().audienceId("audience_id").build() + + assertThat(params._pathParam(0)).isEqualTo("audience_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt new file mode 100644 index 00000000..aa874b76 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceListMembersParamsTest { + + @Test + fun create() { + AudienceListMembersParams.builder().audienceId("audience_id").cursor("cursor").build() + } + + @Test + fun pathParams() { + val params = AudienceListMembersParams.builder().audienceId("audience_id").build() + + assertThat(params._pathParam(0)).isEqualTo("audience_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + AudienceListMembersParams.builder().audienceId("audience_id").cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = AudienceListMembersParams.builder().audienceId("audience_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt new file mode 100644 index 00000000..3ef062a7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceListMembersResponseTest { + + @Test + fun create() { + val audienceListMembersResponse = + AudienceListMembersResponse.builder() + .addItem( + AudienceListMembersResponse.Item.builder() + .addedAt("added_at") + .audienceId("audience_id") + .audienceVersion(0L) + .memberId("member_id") + .reason("reason") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(audienceListMembersResponse.items()) + .containsExactly( + AudienceListMembersResponse.Item.builder() + .addedAt("added_at") + .audienceId("audience_id") + .audienceVersion(0L) + .memberId("member_id") + .reason("reason") + .build() + ) + assertThat(audienceListMembersResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val audienceListMembersResponse = + AudienceListMembersResponse.builder() + .addItem( + AudienceListMembersResponse.Item.builder() + .addedAt("added_at") + .audienceId("audience_id") + .audienceVersion(0L) + .memberId("member_id") + .reason("reason") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedAudienceListMembersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(audienceListMembersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAudienceListMembersResponse).isEqualTo(audienceListMembersResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt new file mode 100644 index 00000000..c794dfbc --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceListParamsTest { + + @Test + fun create() { + AudienceListParams.builder().cursor("cursor").build() + } + + @Test + fun queryParams() { + val params = AudienceListParams.builder().cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = AudienceListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt new file mode 100644 index 00000000..5ba56e5c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceListResponseTest { + + @Test + fun create() { + val audienceListResponse = + AudienceListResponse.builder() + .addItem( + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(audienceListResponse.items()) + .containsExactly( + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + ) + assertThat(audienceListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val audienceListResponse = + AudienceListResponse.builder() + .addItem( + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedAudienceListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(audienceListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAudienceListResponse).isEqualTo(audienceListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt new file mode 100644 index 00000000..acf188f5 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceRetrieveParamsTest { + + @Test + fun create() { + AudienceRetrieveParams.builder().audienceId("audience_id").build() + } + + @Test + fun pathParams() { + val params = AudienceRetrieveParams.builder().audienceId("audience_id").build() + + assertThat(params._pathParam(0)).isEqualTo("audience_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt new file mode 100644 index 00000000..9573ecc6 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceTest { + + @Test + fun create() { + val audience = + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + + assertThat(audience.id()).isEqualTo("id") + assertThat(audience.createdAt()).isEqualTo("created_at") + assertThat(audience.description()).isEqualTo("description") + assertThat(audience.filter()) + .isEqualTo( + Filter.ofUnionMember0( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + ) + assertThat(audience.name()).isEqualTo("name") + assertThat(audience.updatedAt()).isEqualTo("updated_at") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val audience = + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + + val roundtrippedAudience = + jsonMapper.readValue( + jsonMapper.writeValueAsString(audience), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAudience).isEqualTo(audience) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt new file mode 100644 index 00000000..e8ab4192 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceUpdateParamsTest { + + @Test + fun create() { + AudienceUpdateParams.builder() + .audienceId("audience_id") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .build() + } + + @Test + fun pathParams() { + val params = AudienceUpdateParams.builder().audienceId("audience_id").build() + + assertThat(params._pathParam(0)).isEqualTo("audience_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + AudienceUpdateParams.builder() + .audienceId("audience_id") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .build() + + val body = params._body() + + assertThat(body.description()).contains("description") + assertThat(body.filter()) + .contains( + Filter.ofUnionMember0( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + ) + assertThat(body.name()).contains("name") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = AudienceUpdateParams.builder().audienceId("audience_id").build() + + val body = params._body() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt new file mode 100644 index 00000000..ef8a8c15 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AudienceUpdateResponseTest { + + @Test + fun create() { + val audienceUpdateResponse = + AudienceUpdateResponse.builder() + .audience( + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + ) + .build() + + assertThat(audienceUpdateResponse.audience()) + .isEqualTo( + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val audienceUpdateResponse = + AudienceUpdateResponse.builder() + .audience( + Audience.builder() + .id("id") + .createdAt("created_at") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .updatedAt("updated_at") + .build() + ) + .build() + + val roundtrippedAudienceUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(audienceUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAudienceUpdateResponse).isEqualTo(audienceUpdateResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt new file mode 100644 index 00000000..8ad539d9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class FilterConfigTest { + + @Test + fun ofUnionMember0() { + val unionMember0 = + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + + val filterConfig = FilterConfig.ofUnionMember0(unionMember0) + + assertThat(filterConfig.unionMember0()).contains(unionMember0) + assertThat(filterConfig.nested()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val filterConfig = + FilterConfig.ofUnionMember0( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + + val roundtrippedFilterConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(filterConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFilterConfig).isEqualTo(filterConfig) + } + + @Test + fun ofNested() { + val nested = + NestedFilterConfig.builder() + .operator(NestedFilterConfig.Operator.ENDS_WITH) + .addRule( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .build() + + val filterConfig = FilterConfig.ofNested(nested) + + assertThat(filterConfig.unionMember0()).isEmpty + assertThat(filterConfig.nested()).contains(nested) + } + + @Test + fun ofNestedRoundtrip() { + val jsonMapper = jsonMapper() + val filterConfig = + FilterConfig.ofNested( + NestedFilterConfig.builder() + .operator(NestedFilterConfig.Operator.ENDS_WITH) + .addRule( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .build() + ) + + val roundtrippedFilterConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(filterConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFilterConfig).isEqualTo(filterConfig) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val filterConfig = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { filterConfig.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt new file mode 100644 index 00000000..3e565ad1 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class FilterTest { + + @Test + fun ofUnionMember0() { + val unionMember0 = + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + + val filter = Filter.ofUnionMember0(unionMember0) + + assertThat(filter.unionMember0()).contains(unionMember0) + assertThat(filter.nestedFilterConfig()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val filter = + Filter.ofUnionMember0( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + + val roundtrippedFilter = + jsonMapper.readValue(jsonMapper.writeValueAsString(filter), jacksonTypeRef()) + + assertThat(roundtrippedFilter).isEqualTo(filter) + } + + @Test + fun ofNestedFilterConfig() { + val nestedFilterConfig = + NestedFilterConfig.builder() + .operator(NestedFilterConfig.Operator.ENDS_WITH) + .addRule( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .build() + + val filter = Filter.ofNestedFilterConfig(nestedFilterConfig) + + assertThat(filter.unionMember0()).isEmpty + assertThat(filter.nestedFilterConfig()).contains(nestedFilterConfig) + } + + @Test + fun ofNestedFilterConfigRoundtrip() { + val jsonMapper = jsonMapper() + val filter = + Filter.ofNestedFilterConfig( + NestedFilterConfig.builder() + .operator(NestedFilterConfig.Operator.ENDS_WITH) + .addRule( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .build() + ) + + val roundtrippedFilter = + jsonMapper.readValue(jsonMapper.writeValueAsString(filter), jacksonTypeRef()) + + assertThat(roundtrippedFilter).isEqualTo(filter) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val filter = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { filter.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt new file mode 100644 index 00000000..e86f387d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NestedFilterConfigTest { + + @Test + fun create() { + val nestedFilterConfig = + NestedFilterConfig.builder() + .operator(NestedFilterConfig.Operator.ENDS_WITH) + .addRule( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .build() + + assertThat(nestedFilterConfig.operator()).isEqualTo(NestedFilterConfig.Operator.ENDS_WITH) + assertThat(nestedFilterConfig.rules()) + .containsExactly( + FilterConfig.ofUnionMember0( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val nestedFilterConfig = + NestedFilterConfig.builder() + .operator(NestedFilterConfig.Operator.ENDS_WITH) + .addRule( + FilterConfig.UnionMember0.builder() + .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .build() + + val roundtrippedNestedFilterConfig = + jsonMapper.readValue( + jsonMapper.writeValueAsString(nestedFilterConfig), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNestedFilterConfig).isEqualTo(nestedFilterConfig) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt new file mode 100644 index 00000000..c456b0c0 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.audiences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PagingTest { + + @Test + fun create() { + val paging = Paging.builder().more(true).cursor("cursor").build() + + assertThat(paging.more()).isEqualTo(true) + assertThat(paging.cursor()).contains("cursor") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val paging = Paging.builder().more(true).cursor("cursor").build() + + val roundtrippedPaging = + jsonMapper.readValue(jsonMapper.writeValueAsString(paging), jacksonTypeRef()) + + assertThat(roundtrippedPaging).isEqualTo(paging) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt new file mode 100644 index 00000000..c571ee3e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AuditEventListParamsTest { + + @Test + fun create() { + AuditEventListParams.builder().cursor("cursor").build() + } + + @Test + fun queryParams() { + val params = AuditEventListParams.builder().cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = AuditEventListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt new file mode 100644 index 00000000..1c113ff7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AuditEventListResponseTest { + + @Test + fun create() { + val auditEventListResponse = + AuditEventListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + AuditEvent.builder() + .auditEventId("auditEventId") + .source("source") + .timestamp("timestamp") + .type("type") + .actor(AuditEvent.Actor.builder().id("id").email("email").build()) + .target(AuditEvent.Target.builder().id("id").email("email").build()) + .build() + ) + .build() + + assertThat(auditEventListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + assertThat(auditEventListResponse.results()) + .containsExactly( + AuditEvent.builder() + .auditEventId("auditEventId") + .source("source") + .timestamp("timestamp") + .type("type") + .actor(AuditEvent.Actor.builder().id("id").email("email").build()) + .target(AuditEvent.Target.builder().id("id").email("email").build()) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val auditEventListResponse = + AuditEventListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + AuditEvent.builder() + .auditEventId("auditEventId") + .source("source") + .timestamp("timestamp") + .type("type") + .actor(AuditEvent.Actor.builder().id("id").email("email").build()) + .target(AuditEvent.Target.builder().id("id").email("email").build()) + .build() + ) + .build() + + val roundtrippedAuditEventListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(auditEventListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAuditEventListResponse).isEqualTo(auditEventListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt new file mode 100644 index 00000000..7b671c8b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AuditEventRetrieveParamsTest { + + @Test + fun create() { + AuditEventRetrieveParams.builder().auditEventId("audit-event-id").build() + } + + @Test + fun pathParams() { + val params = AuditEventRetrieveParams.builder().auditEventId("audit-event-id").build() + + assertThat(params._pathParam(0)).isEqualTo("audit-event-id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt new file mode 100644 index 00000000..49f9f690 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auditevents + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AuditEventTest { + + @Test + fun create() { + val auditEvent = + AuditEvent.builder() + .auditEventId("auditEventId") + .source("source") + .timestamp("timestamp") + .type("type") + .actor(AuditEvent.Actor.builder().id("id").email("email").build()) + .target(AuditEvent.Target.builder().id("id").email("email").build()) + .build() + + assertThat(auditEvent.auditEventId()).isEqualTo("auditEventId") + assertThat(auditEvent.source()).isEqualTo("source") + assertThat(auditEvent.timestamp()).isEqualTo("timestamp") + assertThat(auditEvent.type()).isEqualTo("type") + assertThat(auditEvent.actor()) + .contains(AuditEvent.Actor.builder().id("id").email("email").build()) + assertThat(auditEvent.target()) + .contains(AuditEvent.Target.builder().id("id").email("email").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val auditEvent = + AuditEvent.builder() + .auditEventId("auditEventId") + .source("source") + .timestamp("timestamp") + .type("type") + .actor(AuditEvent.Actor.builder().id("id").email("email").build()) + .target(AuditEvent.Target.builder().id("id").email("email").build()) + .build() + + val roundtrippedAuditEvent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(auditEvent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAuditEvent).isEqualTo(auditEvent) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt new file mode 100644 index 00000000..cd7b9143 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auth + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AuthIssueTokenParamsTest { + + @Test + fun create() { + AuthIssueTokenParams.builder() + .expiresIn("expires_in") + .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) + .build() + } + + @Test + fun body() { + val params = + AuthIssueTokenParams.builder() + .expiresIn("expires_in") + .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) + .build() + + val body = params._body() + + assertThat(body.expiresIn()).isEqualTo("expires_in") + assertThat(body.scope()).isEqualTo(AuthIssueTokenParams.Scope.READ_PREFERENCES) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt new file mode 100644 index 00000000..80690828 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.auth + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AuthIssueTokenResponseTest { + + @Test + fun create() { + val authIssueTokenResponse = AuthIssueTokenResponse.builder().token("token").build() + + assertThat(authIssueTokenResponse.token()).contains("token") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val authIssueTokenResponse = AuthIssueTokenResponse.builder().token("token").build() + + val roundtrippedAuthIssueTokenResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(authIssueTokenResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAuthIssueTokenResponse).isEqualTo(authIssueTokenResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt new file mode 100644 index 00000000..2c15d8cb --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations + +import com.courier.api.core.JsonValue +import com.courier.api.models.automations.invoke.AutomationInvokeParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutomationInvokeAdHocParamsTest { + + @Test + fun create() { + AutomationInvokeAdHocParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .automation( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + .builder() + .if_("if") + .ref("ref") + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .cancelationToken("cancelation_token") + .build() + ) + .build() + } + + @Test + fun body() { + val params = + AutomationInvokeAdHocParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .automation( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + .builder() + .if_("if") + .ref("ref") + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .cancelationToken("cancelation_token") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.brand()).contains("brand") + assertThat(body.data()) + .contains( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body._profile()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.recipient()).contains("recipient") + assertThat(body.template()).contains("template") + assertThat(body.automation()) + .isEqualTo( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + .builder() + .if_("if") + .ref("ref") + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .cancelationToken("cancelation_token") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + AutomationInvokeAdHocParams.builder() + .automation( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + .builder() + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.automation()) + .isEqualTo( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + .builder() + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt new file mode 100644 index 00000000..46e54514 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations + +import com.courier.api.core.JsonValue +import com.courier.api.models.automations.invoke.AutomationInvokeParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutomationInvokeByTemplateParamsTest { + + @Test + fun create() { + AutomationInvokeByTemplateParams.builder() + .templateId("templateId") + .automationInvokeParams( + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + AutomationInvokeByTemplateParams.builder() + .templateId("templateId") + .automationInvokeParams(AutomationInvokeParams.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("templateId") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + AutomationInvokeByTemplateParams.builder() + .templateId("templateId") + .automationInvokeParams( + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + AutomationInvokeByTemplateParams.builder() + .templateId("templateId") + .automationInvokeParams(AutomationInvokeParams.builder().build()) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(AutomationInvokeParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt new file mode 100644 index 00000000..376c761d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutomationInvokeParamsTest { + + @Test + fun create() { + val automationInvokeParams = + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + + assertThat(automationInvokeParams.brand()).contains("brand") + assertThat(automationInvokeParams.data()) + .contains( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(automationInvokeParams._profile()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(automationInvokeParams.recipient()).contains("recipient") + assertThat(automationInvokeParams.template()).contains("template") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val automationInvokeParams = + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + + val roundtrippedAutomationInvokeParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(automationInvokeParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAutomationInvokeParams).isEqualTo(automationInvokeParams) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt new file mode 100644 index 00000000..1b164e6f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutomationInvokeResponseTest { + + @Test + fun create() { + val automationInvokeResponse = + AutomationInvokeResponse.builder().runId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() + + assertThat(automationInvokeResponse.runId()) + .isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val automationInvokeResponse = + AutomationInvokeResponse.builder().runId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() + + val roundtrippedAutomationInvokeResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(automationInvokeResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAutomationInvokeResponse).isEqualTo(automationInvokeResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt new file mode 100644 index 00000000..37c8b8b8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.automations.invoke + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AutomationStepTest { + + @Test + fun create() { + val automationStep = AutomationStep.builder().if_("if").ref("ref").build() + + assertThat(automationStep.if_()).contains("if") + assertThat(automationStep.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val automationStep = AutomationStep.builder().if_("if").ref("ref").build() + + val roundtrippedAutomationStep = + jsonMapper.readValue( + jsonMapper.writeValueAsString(automationStep), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAutomationStep).isEqualTo(automationStep) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt new file mode 100644 index 00000000..96f6815e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandCreateParamsTest { + + @Test + fun create() { + BrandCreateParams.builder() + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + BrandCreateParams.builder() + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.settings()) + .isEqualTo( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + assertThat(body.id()).contains("id") + assertThat(body.snippets()) + .contains( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BrandCreateParams.builder() + .name("name") + .settings(BrandSettings.builder().build()) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.settings()).isEqualTo(BrandSettings.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt new file mode 100644 index 00000000..631fcf67 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandDeleteParamsTest { + + @Test + fun create() { + BrandDeleteParams.builder().brandId("brand_id").build() + } + + @Test + fun pathParams() { + val params = BrandDeleteParams.builder().brandId("brand_id").build() + + assertThat(params._pathParam(0)).isEqualTo("brand_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt new file mode 100644 index 00000000..bd89858a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandListParamsTest { + + @Test + fun create() { + BrandListParams.builder().cursor("cursor").build() + } + + @Test + fun queryParams() { + val params = BrandListParams.builder().cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = BrandListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt new file mode 100644 index 00000000..9783ee59 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandListResponseTest { + + @Test + fun create() { + val brandListResponse = + BrandListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + Brand.builder() + .created(0L) + .name("name") + .published(0L) + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .updated(0L) + .version("version") + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(brandListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + assertThat(brandListResponse.results()) + .containsExactly( + Brand.builder() + .created(0L) + .name("name") + .published(0L) + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .updated(0L) + .version("version") + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val brandListResponse = + BrandListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + Brand.builder() + .created(0L) + .name("name") + .published(0L) + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .updated(0L) + .version("version") + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedBrandListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(brandListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrandListResponse).isEqualTo(brandListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt new file mode 100644 index 00000000..52f1ce9b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandRetrieveParamsTest { + + @Test + fun create() { + BrandRetrieveParams.builder().brandId("brand_id").build() + } + + @Test + fun pathParams() { + val params = BrandRetrieveParams.builder().brandId("brand_id").build() + + assertThat(params._pathParam(0)).isEqualTo("brand_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt new file mode 100644 index 00000000..6ac00664 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandSettingsTest { + + @Test + fun create() { + val brandSettings = + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + + assertThat(brandSettings.colors()) + .contains( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + assertThat(brandSettings.email()) + .contains( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + assertThat(brandSettings._inapp()).isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val brandSettings = + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + + val roundtrippedBrandSettings = + jsonMapper.readValue( + jsonMapper.writeValueAsString(brandSettings), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrandSettings).isEqualTo(brandSettings) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt new file mode 100644 index 00000000..c003b5cb --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandSnippetsTest { + + @Test + fun create() { + val brandSnippets = + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + + assertThat(brandSnippets.items()) + .containsExactly( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val brandSnippets = + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + + val roundtrippedBrandSnippets = + jsonMapper.readValue( + jsonMapper.writeValueAsString(brandSnippets), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrandSnippets).isEqualTo(brandSnippets) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt new file mode 100644 index 00000000..9552cfd3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt @@ -0,0 +1,140 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandTest { + + @Test + fun create() { + val brand = + Brand.builder() + .created(0L) + .name("name") + .published(0L) + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .updated(0L) + .version("version") + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + + assertThat(brand.created()).isEqualTo(0L) + assertThat(brand.name()).isEqualTo("name") + assertThat(brand.published()).isEqualTo(0L) + assertThat(brand.settings()) + .isEqualTo( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + assertThat(brand.updated()).isEqualTo(0L) + assertThat(brand.version()).isEqualTo("version") + assertThat(brand.id()).contains("id") + assertThat(brand.snippets()) + .contains( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val brand = + Brand.builder() + .created(0L) + .name("name") + .published(0L) + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .updated(0L) + .version("version") + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + + val roundtrippedBrand = + jsonMapper.readValue(jsonMapper.writeValueAsString(brand), jacksonTypeRef()) + + assertThat(roundtrippedBrand).isEqualTo(brand) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt new file mode 100644 index 00000000..93c77d55 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandUpdateParamsTest { + + @Test + fun create() { + BrandUpdateParams.builder() + .brandId("brand_id") + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = BrandUpdateParams.builder().brandId("brand_id").name("name").build() + + assertThat(params._pathParam(0)).isEqualTo("brand_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + BrandUpdateParams.builder() + .brandId("brand_id") + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.settings()) + .contains( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + assertThat(body.snippets()) + .contains( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = BrandUpdateParams.builder().brandId("brand_id").name("name").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt new file mode 100644 index 00000000..5a012951 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt @@ -0,0 +1,433 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.send.MessageContext +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkAddUsersParamsTest { + + @Test + fun create() { + BulkAddUsersParams.builder() + .jobId("job_id") + .addUser( + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + BulkAddUsersParams.builder() + .jobId("job_id") + .addUser(InboundBulkMessageUser.builder().build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + BulkAddUsersParams.builder() + .jobId("job_id") + .addUser( + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.users()) + .containsExactly( + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BulkAddUsersParams.builder() + .jobId("job_id") + .addUser(InboundBulkMessageUser.builder().build()) + .build() + + val body = params._body() + + assertThat(body.users()).containsExactly(InboundBulkMessageUser.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt new file mode 100644 index 00000000..d6e441d2 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt @@ -0,0 +1,588 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.Utm +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkCreateJobParamsTest { + + @Test + fun create() { + BulkCreateJobParams.builder() + .message( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + BulkCreateJobParams.builder() + .message( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.message()) + .isEqualTo( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BulkCreateJobParams.builder().message(InboundBulkMessage.builder().build()).build() + + val body = params._body() + + assertThat(body.message()).isEqualTo(InboundBulkMessage.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt new file mode 100644 index 00000000..07dc583e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkCreateJobResponseTest { + + @Test + fun create() { + val bulkCreateJobResponse = BulkCreateJobResponse.builder().jobId("jobId").build() + + assertThat(bulkCreateJobResponse.jobId()).isEqualTo("jobId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkCreateJobResponse = BulkCreateJobResponse.builder().jobId("jobId").build() + + val roundtrippedBulkCreateJobResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkCreateJobResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkCreateJobResponse).isEqualTo(bulkCreateJobResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt new file mode 100644 index 00000000..fd0af7b0 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkListUsersParamsTest { + + @Test + fun create() { + BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() + } + + @Test + fun pathParams() { + val params = BulkListUsersParams.builder().jobId("job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = BulkListUsersParams.builder().jobId("job_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt new file mode 100644 index 00000000..e3eeea91 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt @@ -0,0 +1,436 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.send.MessageContext +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkListUsersResponseTest { + + @Test + fun create() { + val bulkListUsersResponse = + BulkListUsersResponse.builder() + .addItem( + BulkListUsersResponse.Item.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .status(BulkListUsersResponse.Item.Status.PENDING) + .messageId("messageId") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(bulkListUsersResponse.items()) + .containsExactly( + BulkListUsersResponse.Item.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .status(BulkListUsersResponse.Item.Status.PENDING) + .messageId("messageId") + .build() + ) + assertThat(bulkListUsersResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkListUsersResponse = + BulkListUsersResponse.builder() + .addItem( + BulkListUsersResponse.Item.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .status(BulkListUsersResponse.Item.Status.PENDING) + .messageId("messageId") + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedBulkListUsersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkListUsersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkListUsersResponse).isEqualTo(bulkListUsersResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt new file mode 100644 index 00000000..ace2bcbe --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRetrieveJobParamsTest { + + @Test + fun create() { + BulkRetrieveJobParams.builder().jobId("job_id").build() + } + + @Test + fun pathParams() { + val params = BulkRetrieveJobParams.builder().jobId("job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt new file mode 100644 index 00000000..3016664d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt @@ -0,0 +1,674 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.Utm +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRetrieveJobResponseTest { + + @Test + fun create() { + val bulkRetrieveJobResponse = + BulkRetrieveJobResponse.builder() + .job( + BulkRetrieveJobResponse.Job.builder() + .definition( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf( + "channel" to 0, + "provider" to 0, + ), + ) + ), + ) + .build() + ) + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to + "term", + ) + ), + "override" to + mapOf( + "foo" to "bar" + ), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(0), + ) + .build() + ) + .criteria( + BaseMessage.Timeout.Criteria.NO_ESCALATION + ) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(0), + ) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .enqueued(0L) + .failures(0L) + .received(0L) + .status(BulkRetrieveJobResponse.Job.Status.CREATED) + .build() + ) + .build() + + assertThat(bulkRetrieveJobResponse.job()) + .isEqualTo( + BulkRetrieveJobResponse.Job.builder() + .definition( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to + "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .enqueued(0L) + .failures(0L) + .received(0L) + .status(BulkRetrieveJobResponse.Job.Status.CREATED) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val bulkRetrieveJobResponse = + BulkRetrieveJobResponse.builder() + .job( + BulkRetrieveJobResponse.Job.builder() + .definition( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf( + "channel" to 0, + "provider" to 0, + ), + ) + ), + ) + .build() + ) + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to + "term", + ) + ), + "override" to + mapOf( + "foo" to "bar" + ), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(0), + ) + .build() + ) + .criteria( + BaseMessage.Timeout.Criteria.NO_ESCALATION + ) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(0), + ) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .enqueued(0L) + .failures(0L) + .received(0L) + .status(BulkRetrieveJobResponse.Job.Status.CREATED) + .build() + ) + .build() + + val roundtrippedBulkRetrieveJobResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bulkRetrieveJobResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBulkRetrieveJobResponse).isEqualTo(bulkRetrieveJobResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt new file mode 100644 index 00000000..9feb5964 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BulkRunJobParamsTest { + + @Test + fun create() { + BulkRunJobParams.builder().jobId("job_id").build() + } + + @Test + fun pathParams() { + val params = BulkRunJobParams.builder().jobId("job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt new file mode 100644 index 00000000..7934c3d9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt @@ -0,0 +1,555 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.Utm +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundBulkMessageTest { + + @Test + fun create() { + val inboundBulkMessage = + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + + assertThat(inboundBulkMessage.brand()).contains("brand") + assertThat(inboundBulkMessage.data()) + .contains( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(inboundBulkMessage.event()).contains("event") + assertThat(inboundBulkMessage.locale()) + .contains( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(inboundBulkMessage.message()) + .contains( + InboundBulkMessage.Message.ofInboundBulkTemplate( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + ) + assertThat(inboundBulkMessage._override()).isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundBulkMessage = + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + + val roundtrippedInboundBulkMessage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundBulkMessage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundBulkMessage).isEqualTo(inboundBulkMessage) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt new file mode 100644 index 00000000..fa0c9c8a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt @@ -0,0 +1,369 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.send.MessageContext +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundBulkMessageUserTest { + + @Test + fun create() { + val inboundBulkMessageUser = + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + + assertThat(inboundBulkMessageUser._data()).isEqualTo(JsonValue.from(mapOf())) + assertThat(inboundBulkMessageUser.preferences()) + .contains( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + assertThat(inboundBulkMessageUser._profile()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(inboundBulkMessageUser.recipient()).contains("recipient") + assertThat(inboundBulkMessageUser.to()) + .contains( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundBulkMessageUser = + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + + val roundtrippedInboundBulkMessageUser = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundBulkMessageUser), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundBulkMessageUser).isEqualTo(inboundBulkMessageUser) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt new file mode 100644 index 00000000..85d5306b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.bulk + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.send.MessageContext +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserRecipientTest { + + @Test + fun create() { + val userRecipient = + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + + assertThat(userRecipient.accountId()).contains("account_id") + assertThat(userRecipient.context()) + .contains(MessageContext.builder().tenantId("tenant_id").build()) + assertThat(userRecipient.data()) + .contains( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(userRecipient.email()).contains("email") + assertThat(userRecipient.locale()).contains("locale") + assertThat(userRecipient.phoneNumber()).contains("phone_number") + assertThat(userRecipient.preferences()) + .contains( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + assertThat(userRecipient.tenantId()).contains("tenant_id") + assertThat(userRecipient.userId()).contains("user_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userRecipient = + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + + val roundtrippedUserRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userRecipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserRecipient).isEqualTo(userRecipient) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt new file mode 100644 index 00000000..5015b259 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.inbound + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundTrackEventParamsTest { + + @Test + fun create() { + InboundTrackEventParams.builder() + .event("New Order Placed") + .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") + .properties( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + .type(InboundTrackEventParams.Type.TRACK) + .userId("1234") + .build() + } + + @Test + fun body() { + val params = + InboundTrackEventParams.builder() + .event("New Order Placed") + .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") + .properties( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + .type(InboundTrackEventParams.Type.TRACK) + .userId("1234") + .build() + + val body = params._body() + + assertThat(body.event()).isEqualTo("New Order Placed") + assertThat(body.messageId()).isEqualTo("4c62c457-b329-4bea-9bfc-17bba86c393f") + assertThat(body.properties()) + .isEqualTo( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + assertThat(body.type()).isEqualTo(InboundTrackEventParams.Type.TRACK) + assertThat(body.userId()).contains("1234") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InboundTrackEventParams.builder() + .event("New Order Placed") + .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") + .properties( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + .type(InboundTrackEventParams.Type.TRACK) + .build() + + val body = params._body() + + assertThat(body.event()).isEqualTo("New Order Placed") + assertThat(body.messageId()).isEqualTo("4c62c457-b329-4bea-9bfc-17bba86c393f") + assertThat(body.properties()) + .isEqualTo( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + assertThat(body.type()).isEqualTo(InboundTrackEventParams.Type.TRACK) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt new file mode 100644 index 00000000..dfe1fd97 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.inbound + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboundTrackEventResponseTest { + + @Test + fun create() { + val inboundTrackEventResponse = + InboundTrackEventResponse.builder() + .messageId("1-65f240a0-47a6a120c8374de9bcf9f22c") + .build() + + assertThat(inboundTrackEventResponse.messageId()) + .isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboundTrackEventResponse = + InboundTrackEventResponse.builder() + .messageId("1-65f240a0-47a6a120c8374de9bcf9f22c") + .build() + + val roundtrippedInboundTrackEventResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboundTrackEventResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboundTrackEventResponse).isEqualTo(inboundTrackEventResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt new file mode 100644 index 00000000..09d23fe3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListDeleteParamsTest { + + @Test + fun create() { + ListDeleteParams.builder().listId("list_id").build() + } + + @Test + fun pathParams() { + val params = ListDeleteParams.builder().listId("list_id").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt new file mode 100644 index 00000000..01e1f7ab --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListListParamsTest { + + @Test + fun create() { + ListListParams.builder().cursor("cursor").pattern("pattern").build() + } + + @Test + fun queryParams() { + val params = ListListParams.builder().cursor("cursor").pattern("pattern").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder().put("cursor", "cursor").put("pattern", "pattern").build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ListListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt new file mode 100644 index 00000000..5319596d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListListResponseTest { + + @Test + fun create() { + val listListResponse = + ListListResponse.builder() + .addItem(List.builder().id("id").name("name").created(0L).updated(0L).build()) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(listListResponse.items()) + .containsExactly(List.builder().id("id").name("name").created(0L).updated(0L).build()) + assertThat(listListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listListResponse = + ListListResponse.builder() + .addItem(List.builder().id("id").name("name").created(0L).updated(0L).build()) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedListListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListListResponse).isEqualTo(listListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt new file mode 100644 index 00000000..86f8655c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRestoreParamsTest { + + @Test + fun create() { + ListRestoreParams.builder().listId("list_id").build() + } + + @Test + fun pathParams() { + val params = ListRestoreParams.builder().listId("list_id").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt new file mode 100644 index 00000000..907f8b4e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRetrieveParamsTest { + + @Test + fun create() { + ListRetrieveParams.builder().listId("list_id").build() + } + + @Test + fun pathParams() { + val params = ListRetrieveParams.builder().listId("list_id").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt new file mode 100644 index 00000000..324770f7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListTest { + + @Test + fun create() { + val list = List.builder().id("id").name("name").created(0L).updated(0L).build() + + assertThat(list.id()).isEqualTo("id") + assertThat(list.name()).isEqualTo("name") + assertThat(list.created()).contains(0L) + assertThat(list.updated()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val list = List.builder().id("id").name("name").created(0L).updated(0L).build() + + val roundtrippedList = + jsonMapper.readValue(jsonMapper.writeValueAsString(list), jacksonTypeRef()) + + assertThat(roundtrippedList).isEqualTo(list) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt new file mode 100644 index 00000000..64553174 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists + +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListUpdateParamsTest { + + @Test + fun create() { + ListUpdateParams.builder() + .listId("list_id") + .name("name") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = ListUpdateParams.builder().listId("list_id").name("name").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ListUpdateParams.builder() + .listId("list_id") + .name("name") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.preferences()) + .contains( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ListUpdateParams.builder().listId("list_id").name("name").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt new file mode 100644 index 00000000..1287a144 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PutSubscriptionsRecipientTest { + + @Test + fun create() { + val putSubscriptionsRecipient = + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + + assertThat(putSubscriptionsRecipient.recipientId()).isEqualTo("recipientId") + assertThat(putSubscriptionsRecipient.preferences()) + .contains( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val putSubscriptionsRecipient = + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedPutSubscriptionsRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(putSubscriptionsRecipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPutSubscriptionsRecipient).isEqualTo(putSubscriptionsRecipient) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt new file mode 100644 index 00000000..5bf58f9d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RecipientPreferencesTest { + + @Test + fun create() { + val recipientPreferences = + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + + assertThat(recipientPreferences.categories()) + .contains( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + assertThat(recipientPreferences.notifications()) + .contains( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val recipientPreferences = + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + + val roundtrippedRecipientPreferences = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipientPreferences), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipientPreferences).isEqualTo(recipientPreferences) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt new file mode 100644 index 00000000..32193c77 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionAddParamsTest { + + @Test + fun create() { + SubscriptionAddParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + SubscriptionAddParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder().recipientId("recipientId").build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SubscriptionAddParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.recipients()) + .containsExactly( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SubscriptionAddParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder().recipientId("recipientId").build() + ) + .build() + + val body = params._body() + + assertThat(body.recipients()) + .containsExactly(PutSubscriptionsRecipient.builder().recipientId("recipientId").build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt new file mode 100644 index 00000000..ade25b2f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionListParamsTest { + + @Test + fun create() { + SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() + } + + @Test + fun pathParams() { + val params = SubscriptionListParams.builder().listId("list_id").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SubscriptionListParams.builder().listId("list_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt new file mode 100644 index 00000000..5943c470 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionListResponseTest { + + @Test + fun create() { + val subscriptionListResponse = + SubscriptionListResponse.builder() + .addItem( + SubscriptionListResponse.Item.builder() + .recipientId("recipientId") + .created("created") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(subscriptionListResponse.items()) + .containsExactly( + SubscriptionListResponse.Item.builder() + .recipientId("recipientId") + .created("created") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(subscriptionListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionListResponse = + SubscriptionListResponse.builder() + .addItem( + SubscriptionListResponse.Item.builder() + .recipientId("recipientId") + .created("created") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedSubscriptionListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionListResponse).isEqualTo(subscriptionListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt new file mode 100644 index 00000000..ff37366e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionSubscribeParamsTest { + + @Test + fun create() { + SubscriptionSubscribeParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + SubscriptionSubscribeParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder().recipientId("recipientId").build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + SubscriptionSubscribeParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.recipients()) + .containsExactly( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SubscriptionSubscribeParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder().recipientId("recipientId").build() + ) + .build() + + val body = params._body() + + assertThat(body.recipients()) + .containsExactly(PutSubscriptionsRecipient.builder().recipientId("recipientId").build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt new file mode 100644 index 00000000..a60befae --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionSubscribeUserParamsTest { + + @Test + fun create() { + SubscriptionSubscribeUserParams.builder() + .listId("list_id") + .userId("user_id") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + SubscriptionSubscribeUserParams.builder().listId("list_id").userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + assertThat(params._pathParam(1)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + SubscriptionSubscribeUserParams.builder() + .listId("list_id") + .userId("user_id") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.preferences()) + .contains( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SubscriptionSubscribeUserParams.builder().listId("list_id").userId("user_id").build() + + val body = params._body() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt new file mode 100644 index 00000000..054cbb3c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionUnsubscribeUserParamsTest { + + @Test + fun create() { + SubscriptionUnsubscribeUserParams.builder().listId("list_id").userId("user_id").build() + } + + @Test + fun pathParams() { + val params = + SubscriptionUnsubscribeUserParams.builder().listId("list_id").userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("list_id") + assertThat(params._pathParam(1)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt new file mode 100644 index 00000000..2d76ba16 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageCancelParamsTest { + + @Test + fun create() { + MessageCancelParams.builder().messageId("message_id").build() + } + + @Test + fun pathParams() { + val params = MessageCancelParams.builder().messageId("message_id").build() + + assertThat(params._pathParam(0)).isEqualTo("message_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt new file mode 100644 index 00000000..44a98a49 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageDetailsTest { + + @Test + fun create() { + val messageDetails = + MessageDetails.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .build() + + assertThat(messageDetails.id()).isEqualTo("id") + assertThat(messageDetails.clicked()).isEqualTo(0L) + assertThat(messageDetails.delivered()).isEqualTo(0L) + assertThat(messageDetails.enqueued()).isEqualTo(0L) + assertThat(messageDetails.event()).isEqualTo("event") + assertThat(messageDetails.notification()).isEqualTo("notification") + assertThat(messageDetails.opened()).isEqualTo(0L) + assertThat(messageDetails.recipient()).isEqualTo("recipient") + assertThat(messageDetails.sent()).isEqualTo(0L) + assertThat(messageDetails.status()).isEqualTo(MessageDetails.Status.CANCELED) + assertThat(messageDetails.error()).contains("error") + assertThat(messageDetails.reason()).contains(MessageDetails.Reason.FILTERED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageDetails = + MessageDetails.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .build() + + val roundtrippedMessageDetails = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageDetails), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageDetails).isEqualTo(messageDetails) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt new file mode 100644 index 00000000..fb739bfd --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageGetContentParamsTest { + + @Test + fun create() { + MessageGetContentParams.builder().messageId("message_id").build() + } + + @Test + fun pathParams() { + val params = MessageGetContentParams.builder().messageId("message_id").build() + + assertThat(params._pathParam(0)).isEqualTo("message_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt new file mode 100644 index 00000000..40b073cf --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageGetContentResponseTest { + + @Test + fun create() { + val messageGetContentResponse = + MessageGetContentResponse.builder() + .addResult( + MessageGetContentResponse.Result.builder() + .channel("channel") + .channelId("channel_id") + .content( + MessageGetContentResponse.Result.Content.builder() + .addBlock( + MessageGetContentResponse.Result.Content.Block.builder() + .text("text") + .type("type") + .build() + ) + .body("body") + .html("html") + .subject("subject") + .text("text") + .title("title") + .build() + ) + .build() + ) + .build() + + assertThat(messageGetContentResponse.results()) + .containsExactly( + MessageGetContentResponse.Result.builder() + .channel("channel") + .channelId("channel_id") + .content( + MessageGetContentResponse.Result.Content.builder() + .addBlock( + MessageGetContentResponse.Result.Content.Block.builder() + .text("text") + .type("type") + .build() + ) + .body("body") + .html("html") + .subject("subject") + .text("text") + .title("title") + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageGetContentResponse = + MessageGetContentResponse.builder() + .addResult( + MessageGetContentResponse.Result.builder() + .channel("channel") + .channelId("channel_id") + .content( + MessageGetContentResponse.Result.Content.builder() + .addBlock( + MessageGetContentResponse.Result.Content.Block.builder() + .text("text") + .type("type") + .build() + ) + .body("body") + .html("html") + .subject("subject") + .text("text") + .title("title") + .build() + ) + .build() + ) + .build() + + val roundtrippedMessageGetContentResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageGetContentResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageGetContentResponse).isEqualTo(messageGetContentResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt new file mode 100644 index 00000000..c1c71c4c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageHistoryParamsTest { + + @Test + fun create() { + MessageHistoryParams.builder().messageId("message_id").type("type").build() + } + + @Test + fun pathParams() { + val params = MessageHistoryParams.builder().messageId("message_id").build() + + assertThat(params._pathParam(0)).isEqualTo("message_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = MessageHistoryParams.builder().messageId("message_id").type("type").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("type", "type").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = MessageHistoryParams.builder().messageId("message_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt new file mode 100644 index 00000000..3840c4e3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageHistoryResponseTest { + + @Test + fun create() { + val messageHistoryResponse = + MessageHistoryResponse.builder() + .addResult( + MessageHistoryResponse.Result.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(messageHistoryResponse.results()) + .containsExactly( + MessageHistoryResponse.Result.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageHistoryResponse = + MessageHistoryResponse.builder() + .addResult( + MessageHistoryResponse.Result.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val roundtrippedMessageHistoryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageHistoryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageHistoryResponse).isEqualTo(messageHistoryResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt new file mode 100644 index 00000000..06844658 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageListParamsTest { + + @Test + fun create() { + MessageListParams.builder() + .archived(true) + .cursor("cursor") + .enqueuedAfter("enqueued_after") + .event("event") + .list("list") + .messageId("messageId") + .notification("notification") + .addProvider("string") + .recipient("recipient") + .addStatus("string") + .addTag("string") + .tags("tags") + .tenantId("tenant_id") + .traceId("traceId") + .build() + } + + @Test + fun queryParams() { + val params = + MessageListParams.builder() + .archived(true) + .cursor("cursor") + .enqueuedAfter("enqueued_after") + .event("event") + .list("list") + .messageId("messageId") + .notification("notification") + .addProvider("string") + .recipient("recipient") + .addStatus("string") + .addTag("string") + .tags("tags") + .tenantId("tenant_id") + .traceId("traceId") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("archived", "true") + .put("cursor", "cursor") + .put("enqueued_after", "enqueued_after") + .put("event", "event") + .put("list", "list") + .put("messageId", "messageId") + .put("notification", "notification") + .put("provider", listOf("string").joinToString(",")) + .put("recipient", "recipient") + .put("status", listOf("string").joinToString(",")) + .put("tag", listOf("string").joinToString(",")) + .put("tags", "tags") + .put("tenant_id", "tenant_id") + .put("traceId", "traceId") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = MessageListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt new file mode 100644 index 00000000..bba292c7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageListResponseTest { + + @Test + fun create() { + val messageListResponse = + MessageListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + MessageDetails.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .build() + ) + .build() + + assertThat(messageListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + assertThat(messageListResponse.results()) + .containsExactly( + MessageDetails.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageListResponse = + MessageListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + MessageDetails.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .build() + ) + .build() + + val roundtrippedMessageListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageListResponse).isEqualTo(messageListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt new file mode 100644 index 00000000..111a3262 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageRetrieveParamsTest { + + @Test + fun create() { + MessageRetrieveParams.builder().messageId("message_id").build() + } + + @Test + fun pathParams() { + val params = MessageRetrieveParams.builder().messageId("message_id").build() + + assertThat(params._pathParam(0)).isEqualTo("message_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt new file mode 100644 index 00000000..5c604358 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.messages + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageRetrieveResponseTest { + + @Test + fun create() { + val messageRetrieveResponse = + MessageRetrieveResponse.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .addProvider( + MessageRetrieveResponse.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(messageRetrieveResponse.id()).isEqualTo("id") + assertThat(messageRetrieveResponse.clicked()).isEqualTo(0L) + assertThat(messageRetrieveResponse.delivered()).isEqualTo(0L) + assertThat(messageRetrieveResponse.enqueued()).isEqualTo(0L) + assertThat(messageRetrieveResponse.event()).isEqualTo("event") + assertThat(messageRetrieveResponse.notification()).isEqualTo("notification") + assertThat(messageRetrieveResponse.opened()).isEqualTo(0L) + assertThat(messageRetrieveResponse.recipient()).isEqualTo("recipient") + assertThat(messageRetrieveResponse.sent()).isEqualTo(0L) + assertThat(messageRetrieveResponse.status()).isEqualTo(MessageDetails.Status.CANCELED) + assertThat(messageRetrieveResponse.error()).contains("error") + assertThat(messageRetrieveResponse.reason()).contains(MessageDetails.Reason.FILTERED) + assertThat(messageRetrieveResponse.providers().getOrNull()) + .containsExactly( + MessageRetrieveResponse.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageRetrieveResponse = + MessageRetrieveResponse.builder() + .id("id") + .clicked(0L) + .delivered(0L) + .enqueued(0L) + .event("event") + .notification("notification") + .opened(0L) + .recipient("recipient") + .sent(0L) + .status(MessageDetails.Status.CANCELED) + .error("error") + .reason(MessageDetails.Reason.FILTERED) + .addProvider( + MessageRetrieveResponse.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val roundtrippedMessageRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageRetrieveResponse).isEqualTo(messageRetrieveResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt new file mode 100644 index 00000000..bf77a1d7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +internal class MessageRoutingChannelTest { + + @Test + fun ofString() { + val string = "string" + + val messageRoutingChannel = MessageRoutingChannel.ofString(string) + + assertThat(messageRoutingChannel.string()).contains(string) + assertThat(messageRoutingChannel.messageRouting()).isEmpty + } + + @Test + fun ofStringRoundtrip() { + val jsonMapper = jsonMapper() + val messageRoutingChannel = MessageRoutingChannel.ofString("string") + + val roundtrippedMessageRoutingChannel = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageRoutingChannel), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageRoutingChannel).isEqualTo(messageRoutingChannel) + } + + @Test + fun ofMessageRouting() { + val messageRouting = + MessageRouting.builder().addChannel("string").method(MessageRouting.Method.ALL).build() + + val messageRoutingChannel = MessageRoutingChannel.ofMessageRouting(messageRouting) + + assertThat(messageRoutingChannel.string()).isEmpty + assertThat(messageRoutingChannel.messageRouting()).contains(messageRouting) + } + + @Test + fun ofMessageRoutingRoundtrip() { + val jsonMapper = jsonMapper() + val messageRoutingChannel = + MessageRoutingChannel.ofMessageRouting( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + + val roundtrippedMessageRoutingChannel = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageRoutingChannel), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageRoutingChannel).isEqualTo(messageRoutingChannel) + } + + @Test + fun incompatibleJsonShapeDeserializesToUnknown() { + val value = JsonValue.from(listOf("invalid", "array")) + val messageRoutingChannel = + jsonMapper().convertValue(value, jacksonTypeRef()) + + val e = assertThrows { messageRoutingChannel.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt new file mode 100644 index 00000000..3b26b7ec --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageRoutingTest { + + @Test + fun create() { + val messageRouting = + MessageRouting.builder().addChannel("string").method(MessageRouting.Method.ALL).build() + + assertThat(messageRouting.channels()) + .containsExactly(MessageRoutingChannel.ofString("string")) + assertThat(messageRouting.method()).isEqualTo(MessageRouting.Method.ALL) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageRouting = + MessageRouting.builder().addChannel("string").method(MessageRouting.Method.ALL).build() + + val roundtrippedMessageRouting = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageRouting), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageRouting).isEqualTo(messageRouting) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt new file mode 100644 index 00000000..c53dd38f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NotificationGetContentTest { + + @Test + fun create() { + val notificationGetContent = + NotificationGetContent.builder() + .addBlock( + NotificationGetContent.Block.builder() + .id("id") + .type(NotificationGetContent.Block.Type.ACTION) + .alias("alias") + .checksum("checksum") + .content("string") + .context("context") + .locales( + NotificationGetContent.Block.Locales.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addChannel( + NotificationGetContent.Channel.builder() + .id("id") + .checksum("checksum") + .content( + NotificationGetContent.Channel.Content.builder() + .subject("subject") + .title("title") + .build() + ) + .locales( + NotificationGetContent.Channel.Locales.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf("subject" to "subject", "title" to "title") + ), + ) + .build() + ) + .type("type") + .build() + ) + .checksum("checksum") + .build() + + assertThat(notificationGetContent.blocks().getOrNull()) + .containsExactly( + NotificationGetContent.Block.builder() + .id("id") + .type(NotificationGetContent.Block.Type.ACTION) + .alias("alias") + .checksum("checksum") + .content("string") + .context("context") + .locales( + NotificationGetContent.Block.Locales.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + assertThat(notificationGetContent.channels().getOrNull()) + .containsExactly( + NotificationGetContent.Channel.builder() + .id("id") + .checksum("checksum") + .content( + NotificationGetContent.Channel.Content.builder() + .subject("subject") + .title("title") + .build() + ) + .locales( + NotificationGetContent.Channel.Locales.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf("subject" to "subject", "title" to "title")), + ) + .build() + ) + .type("type") + .build() + ) + assertThat(notificationGetContent.checksum()).contains("checksum") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val notificationGetContent = + NotificationGetContent.builder() + .addBlock( + NotificationGetContent.Block.builder() + .id("id") + .type(NotificationGetContent.Block.Type.ACTION) + .alias("alias") + .checksum("checksum") + .content("string") + .context("context") + .locales( + NotificationGetContent.Block.Locales.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .addChannel( + NotificationGetContent.Channel.builder() + .id("id") + .checksum("checksum") + .content( + NotificationGetContent.Channel.Content.builder() + .subject("subject") + .title("title") + .build() + ) + .locales( + NotificationGetContent.Channel.Locales.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf("subject" to "subject", "title" to "title") + ), + ) + .build() + ) + .type("type") + .build() + ) + .checksum("checksum") + .build() + + val roundtrippedNotificationGetContent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(notificationGetContent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNotificationGetContent).isEqualTo(notificationGetContent) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt new file mode 100644 index 00000000..0fb4a5ea --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NotificationListParamsTest { + + @Test + fun create() { + NotificationListParams.builder().cursor("cursor").notes(true).build() + } + + @Test + fun queryParams() { + val params = NotificationListParams.builder().cursor("cursor").notes(true).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("notes", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = NotificationListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt new file mode 100644 index 00000000..8346a157 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NotificationListResponseTest { + + @Test + fun create() { + val notificationListResponse = + NotificationListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + NotificationListResponse.Result.builder() + .id("id") + .createdAt(0L) + .note("note") + .routing( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + .topicId("topic_id") + .updatedAt(0L) + .tags( + NotificationListResponse.Result.Tags.builder() + .addData( + NotificationListResponse.Result.Tags.Data.builder() + .id("id") + .name("name") + .build() + ) + .build() + ) + .title("title") + .build() + ) + .build() + + assertThat(notificationListResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + assertThat(notificationListResponse.results()) + .containsExactly( + NotificationListResponse.Result.builder() + .id("id") + .createdAt(0L) + .note("note") + .routing( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + .topicId("topic_id") + .updatedAt(0L) + .tags( + NotificationListResponse.Result.Tags.builder() + .addData( + NotificationListResponse.Result.Tags.Data.builder() + .id("id") + .name("name") + .build() + ) + .build() + ) + .title("title") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val notificationListResponse = + NotificationListResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + NotificationListResponse.Result.builder() + .id("id") + .createdAt(0L) + .note("note") + .routing( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + .topicId("topic_id") + .updatedAt(0L) + .tags( + NotificationListResponse.Result.Tags.builder() + .addData( + NotificationListResponse.Result.Tags.Data.builder() + .id("id") + .name("name") + .build() + ) + .build() + ) + .title("title") + .build() + ) + .build() + + val roundtrippedNotificationListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(notificationListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNotificationListResponse).isEqualTo(notificationListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt new file mode 100644 index 00000000..e402cd97 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NotificationRetrieveContentParamsTest { + + @Test + fun create() { + NotificationRetrieveContentParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = NotificationRetrieveContentParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt new file mode 100644 index 00000000..6c71dfd8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseCheckTest { + + @Test + fun create() { + val baseCheck = + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + + assertThat(baseCheck.id()).isEqualTo("id") + assertThat(baseCheck.status()).isEqualTo(BaseCheck.Status.RESOLVED) + assertThat(baseCheck.type()).isEqualTo(BaseCheck.Type.CUSTOM) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseCheck = + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + + val roundtrippedBaseCheck = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseCheck), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseCheck).isEqualTo(baseCheck) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt new file mode 100644 index 00000000..b6052a50 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CheckDeleteParamsTest { + + @Test + fun create() { + CheckDeleteParams.builder().id("id").submissionId("submissionId").build() + } + + @Test + fun pathParams() { + val params = CheckDeleteParams.builder().id("id").submissionId("submissionId").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(1)).isEqualTo("submissionId") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt new file mode 100644 index 00000000..08bf67b8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CheckListParamsTest { + + @Test + fun create() { + CheckListParams.builder().id("id").submissionId("submissionId").build() + } + + @Test + fun pathParams() { + val params = CheckListParams.builder().id("id").submissionId("submissionId").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(1)).isEqualTo("submissionId") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt new file mode 100644 index 00000000..8a962db5 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CheckListResponseTest { + + @Test + fun create() { + val checkListResponse = + CheckListResponse.builder() + .addCheck( + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + ) + .build() + + assertThat(checkListResponse.checks()) + .containsExactly( + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val checkListResponse = + CheckListResponse.builder() + .addCheck( + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + ) + .build() + + val roundtrippedCheckListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(checkListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCheckListResponse).isEqualTo(checkListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt new file mode 100644 index 00000000..541aa366 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CheckTest { + + @Test + fun create() { + val check = + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + + assertThat(check.id()).isEqualTo("id") + assertThat(check.status()).isEqualTo(BaseCheck.Status.RESOLVED) + assertThat(check.type()).isEqualTo(BaseCheck.Type.CUSTOM) + assertThat(check.updated()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val check = + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + + val roundtrippedCheck = + jsonMapper.readValue(jsonMapper.writeValueAsString(check), jacksonTypeRef()) + + assertThat(roundtrippedCheck).isEqualTo(check) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt new file mode 100644 index 00000000..e16d02bd --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CheckUpdateParamsTest { + + @Test + fun create() { + CheckUpdateParams.builder() + .id("id") + .submissionId("submissionId") + .addCheck( + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + CheckUpdateParams.builder() + .id("id") + .submissionId("submissionId") + .addCheck( + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("id") + assertThat(params._pathParam(1)).isEqualTo("submissionId") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + CheckUpdateParams.builder() + .id("id") + .submissionId("submissionId") + .addCheck( + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.checks()) + .containsExactly( + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt new file mode 100644 index 00000000..d9023651 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.checks + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CheckUpdateResponseTest { + + @Test + fun create() { + val checkUpdateResponse = + CheckUpdateResponse.builder() + .addCheck( + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + ) + .build() + + assertThat(checkUpdateResponse.checks()) + .containsExactly( + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val checkUpdateResponse = + CheckUpdateResponse.builder() + .addCheck( + Check.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .updated(0L) + .build() + ) + .build() + + val roundtrippedCheckUpdateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(checkUpdateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCheckUpdateResponse).isEqualTo(checkUpdateResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt new file mode 100644 index 00000000..04f83d08 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.notifications.draft + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DraftRetrieveContentParamsTest { + + @Test + fun create() { + DraftRetrieveContentParams.builder().id("id").build() + } + + @Test + fun pathParams() { + val params = DraftRetrieveContentParams.builder().id("id").build() + + assertThat(params._pathParam(0)).isEqualTo("id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt new file mode 100644 index 00000000..d5fcdf04 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileCreateParamsTest { + + @Test + fun create() { + ProfileCreateParams.builder() + .userId("user_id") + .profile( + ProfileCreateParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ProfileCreateParams.builder() + .userId("user_id") + .profile( + ProfileCreateParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ProfileCreateParams.builder() + .userId("user_id") + .profile( + ProfileCreateParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.profile()) + .isEqualTo( + ProfileCreateParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt new file mode 100644 index 00000000..f116cca8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileCreateResponseTest { + + @Test + fun create() { + val profileCreateResponse = + ProfileCreateResponse.builder().status(ProfileCreateResponse.Status.SUCCESS).build() + + assertThat(profileCreateResponse.status()).isEqualTo(ProfileCreateResponse.Status.SUCCESS) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val profileCreateResponse = + ProfileCreateResponse.builder().status(ProfileCreateResponse.Status.SUCCESS).build() + + val roundtrippedProfileCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(profileCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProfileCreateResponse).isEqualTo(profileCreateResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt new file mode 100644 index 00000000..25329c9f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileDeleteParamsTest { + + @Test + fun create() { + ProfileDeleteParams.builder().userId("user_id").build() + } + + @Test + fun pathParams() { + val params = ProfileDeleteParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt new file mode 100644 index 00000000..c526eba3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileReplaceParamsTest { + + @Test + fun create() { + ProfileReplaceParams.builder() + .userId("user_id") + .profile( + ProfileReplaceParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ProfileReplaceParams.builder() + .userId("user_id") + .profile( + ProfileReplaceParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ProfileReplaceParams.builder() + .userId("user_id") + .profile( + ProfileReplaceParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.profile()) + .isEqualTo( + ProfileReplaceParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt new file mode 100644 index 00000000..b7c84d1a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileReplaceResponseTest { + + @Test + fun create() { + val profileReplaceResponse = + ProfileReplaceResponse.builder().status(ProfileReplaceResponse.Status.SUCCESS).build() + + assertThat(profileReplaceResponse.status()).isEqualTo(ProfileReplaceResponse.Status.SUCCESS) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val profileReplaceResponse = + ProfileReplaceResponse.builder().status(ProfileReplaceResponse.Status.SUCCESS).build() + + val roundtrippedProfileReplaceResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(profileReplaceResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProfileReplaceResponse).isEqualTo(profileReplaceResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt new file mode 100644 index 00000000..27296002 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileRetrieveParamsTest { + + @Test + fun create() { + ProfileRetrieveParams.builder().userId("user_id").build() + } + + @Test + fun pathParams() { + val params = ProfileRetrieveParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt new file mode 100644 index 00000000..b33a0038 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileRetrieveResponseTest { + + @Test + fun create() { + val profileRetrieveResponse = + ProfileRetrieveResponse.builder() + .profile( + ProfileRetrieveResponse.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + + assertThat(profileRetrieveResponse.profile()) + .isEqualTo( + ProfileRetrieveResponse.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(profileRetrieveResponse.preferences()) + .contains( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + ) + ), + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val profileRetrieveResponse = + ProfileRetrieveResponse.builder() + .profile( + ProfileRetrieveResponse.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedProfileRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(profileRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedProfileRetrieveResponse).isEqualTo(profileRetrieveResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt new file mode 100644 index 00000000..6ff75916 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProfileUpdateParamsTest { + + @Test + fun create() { + ProfileUpdateParams.builder() + .userId("user_id") + .addPatch( + ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ProfileUpdateParams.builder() + .userId("user_id") + .addPatch( + ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ProfileUpdateParams.builder() + .userId("user_id") + .addPatch( + ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + + val body = params._body() + + assertThat(body.patch()) + .containsExactly( + ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt new file mode 100644 index 00000000..7bc7cad6 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListDeleteParamsTest { + + @Test + fun create() { + ListDeleteParams.builder().userId("user_id").build() + } + + @Test + fun pathParams() { + val params = ListDeleteParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt new file mode 100644 index 00000000..5263496f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListDeleteResponseTest { + + @Test + fun create() { + val listDeleteResponse = + ListDeleteResponse.builder().status(ListDeleteResponse.Status.SUCCESS).build() + + assertThat(listDeleteResponse.status()).isEqualTo(ListDeleteResponse.Status.SUCCESS) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listDeleteResponse = + ListDeleteResponse.builder().status(ListDeleteResponse.Status.SUCCESS).build() + + val roundtrippedListDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListDeleteResponse).isEqualTo(listDeleteResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt new file mode 100644 index 00000000..9cda2937 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRetrieveParamsTest { + + @Test + fun create() { + ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() + } + + @Test + fun pathParams() { + val params = ListRetrieveParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ListRetrieveParams.builder().userId("user_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt new file mode 100644 index 00000000..a4cf478f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListRetrieveResponseTest { + + @Test + fun create() { + val listRetrieveResponse = + ListRetrieveResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + ListRetrieveResponse.Result.builder() + .id("id") + .created("created") + .name("name") + .updated("updated") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + + assertThat(listRetrieveResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + assertThat(listRetrieveResponse.results()) + .containsExactly( + ListRetrieveResponse.Result.builder() + .id("id") + .created("created") + .name("name") + .updated("updated") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listRetrieveResponse = + ListRetrieveResponse.builder() + .paging(Paging.builder().more(true).cursor("cursor").build()) + .addResult( + ListRetrieveResponse.Result.builder() + .id("id") + .created("created") + .name("name") + .updated("updated") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + + val roundtrippedListRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListRetrieveResponse).isEqualTo(listRetrieveResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt new file mode 100644 index 00000000..f4f5f703 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListSubscribeParamsTest { + + @Test + fun create() { + ListSubscribeParams.builder() + .userId("user_id") + .addList( + ListSubscribeParams.List.builder() + .listId("listId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ListSubscribeParams.builder() + .userId("user_id") + .addList(ListSubscribeParams.List.builder().listId("listId").build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + ListSubscribeParams.builder() + .userId("user_id") + .addList( + ListSubscribeParams.List.builder() + .listId("listId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.lists()) + .containsExactly( + ListSubscribeParams.List.builder() + .listId("listId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ListSubscribeParams.builder() + .userId("user_id") + .addList(ListSubscribeParams.List.builder().listId("listId").build()) + .build() + + val body = params._body() + + assertThat(body.lists()) + .containsExactly(ListSubscribeParams.List.builder().listId("listId").build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt new file mode 100644 index 00000000..952fea61 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.profiles.lists + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ListSubscribeResponseTest { + + @Test + fun create() { + val listSubscribeResponse = + ListSubscribeResponse.builder().status(ListSubscribeResponse.Status.SUCCESS).build() + + assertThat(listSubscribeResponse.status()).isEqualTo(ListSubscribeResponse.Status.SUCCESS) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val listSubscribeResponse = + ListSubscribeResponse.builder().status(ListSubscribeResponse.Status.SUCCESS).build() + + val roundtrippedListSubscribeResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(listSubscribeResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedListSubscribeResponse).isEqualTo(listSubscribeResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt new file mode 100644 index 00000000..b450b2c0 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.requests + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RequestArchiveParamsTest { + + @Test + fun create() { + RequestArchiveParams.builder().requestId("request_id").build() + } + + @Test + fun pathParams() { + val params = RequestArchiveParams.builder().requestId("request_id").build() + + assertThat(params._pathParam(0)).isEqualTo("request_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt new file mode 100644 index 00000000..1e206ee4 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseMessageSendToTest { + + @Test + fun create() { + val baseMessageSendTo = + BaseMessageSendTo.builder() + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF + ) + .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + ) + .build() + + assertThat(baseMessageSendTo.to()) + .contains( + BaseMessageSendTo.To.ofAudienceRecipient( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF + ) + .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseMessageSendTo = + BaseMessageSendTo.builder() + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF + ) + .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + ) + .build() + + val roundtrippedBaseMessageSendTo = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseMessageSendTo), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseMessageSendTo).isEqualTo(baseMessageSendTo) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt new file mode 100644 index 00000000..481297c7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt @@ -0,0 +1,483 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseMessageTest { + + @Test + fun create() { + val baseMessage = + BaseMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .build() + + assertThat(baseMessage.brandId()).contains("brand_id") + assertThat(baseMessage.channels()) + .contains( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + assertThat(baseMessage.context()) + .contains(MessageContext.builder().tenantId("tenant_id").build()) + assertThat(baseMessage.data()) + .contains( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(baseMessage.delay()) + .contains(BaseMessage.Delay.builder().duration(0L).until("until").build()) + assertThat(baseMessage.expiry()) + .contains( + BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() + ) + assertThat(baseMessage.metadata()) + .contains( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + assertThat(baseMessage.preferences()) + .contains( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + assertThat(baseMessage.providers()) + .contains( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + assertThat(baseMessage.routing()) + .contains( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + assertThat(baseMessage.timeout()) + .contains( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseMessage = + BaseMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .build() + + val roundtrippedBaseMessage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseMessage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseMessage).isEqualTo(baseMessage) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt new file mode 100644 index 00000000..37c66cfa --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt @@ -0,0 +1,107 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ContentTest { + + @Test + fun ofElemental() { + val elemental = + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + + val content = Content.ofElemental(elemental) + + assertThat(content.elemental()).contains(elemental) + assertThat(content.elementalContentSugar()).isEmpty + } + + @Test + fun ofElementalRoundtrip() { + val jsonMapper = jsonMapper() + val content = + Content.ofElemental( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + + val roundtrippedContent = + jsonMapper.readValue(jsonMapper.writeValueAsString(content), jacksonTypeRef()) + + assertThat(roundtrippedContent).isEqualTo(content) + } + + @Test + fun ofElementalContentSugar() { + val elementalContentSugar = + Content.ElementalContentSugar.builder().body("body").title("title").build() + + val content = Content.ofElementalContentSugar(elementalContentSugar) + + assertThat(content.elemental()).isEmpty + assertThat(content.elementalContentSugar()).contains(elementalContentSugar) + } + + @Test + fun ofElementalContentSugarRoundtrip() { + val jsonMapper = jsonMapper() + val content = + Content.ofElementalContentSugar( + Content.ElementalContentSugar.builder().body("body").title("title").build() + ) + + val roundtrippedContent = + jsonMapper.readValue(jsonMapper.writeValueAsString(content), jacksonTypeRef()) + + assertThat(roundtrippedContent).isEqualTo(content) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val content = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { content.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt new file mode 100644 index 00000000..4587d04e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalChannelNodeTest { + + @Test + fun create() { + val elementalChannelNode = + ElementalChannelNode.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .build() + + assertThat(elementalChannelNode.channel()).isEqualTo("channel") + assertThat(elementalChannelNode.channels().getOrNull()).containsExactly("string") + assertThat(elementalChannelNode.elements().getOrNull()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalChannelNode.if_()).contains("if") + assertThat(elementalChannelNode.loop()).contains("loop") + assertThat(elementalChannelNode.raw()) + .contains( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(elementalChannelNode.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalChannelNode = + ElementalChannelNode.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .build() + + val roundtrippedElementalChannelNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalChannelNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalChannelNode).isEqualTo(elementalChannelNode) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt new file mode 100644 index 00000000..bf51afd4 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalGroupNodeTest { + + @Test + fun create() { + val elementalGroupNode = + ElementalGroupNode.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .build() + + assertThat(elementalGroupNode.elements()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalGroupNode.channels().getOrNull()).containsExactly("string") + assertThat(elementalGroupNode.if_()).contains("if") + assertThat(elementalGroupNode.loop()).contains("loop") + assertThat(elementalGroupNode.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalGroupNode = + ElementalGroupNode.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .build() + + val roundtrippedElementalGroupNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalGroupNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalGroupNode).isEqualTo(elementalGroupNode) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt new file mode 100644 index 00000000..df5c7d9d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt @@ -0,0 +1,450 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ElementalNodeTest { + + @Test + fun ofUnionMember0() { + val unionMember0 = + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + + val elementalNode = ElementalNode.ofUnionMember0(unionMember0) + + assertThat(elementalNode.unionMember0()).contains(unionMember0) + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember1() { + val unionMember1 = + ElementalNode.UnionMember1.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember1.Type.META) + .build() + + val elementalNode = ElementalNode.ofUnionMember1(unionMember1) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).contains(unionMember1) + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember1Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember1( + ElementalNode.UnionMember1.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember1.Type.META) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember2() { + val unionMember2 = + ElementalNode.UnionMember2.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .type(ElementalNode.UnionMember2.Type.CHANNEL) + .build() + + val elementalNode = ElementalNode.ofUnionMember2(unionMember2) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).contains(unionMember2) + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember2Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember2( + ElementalNode.UnionMember2.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .type(ElementalNode.UnionMember2.Type.CHANNEL) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember3() { + val unionMember3 = + ElementalNode.UnionMember3.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember3.Type.IMAGE) + .build() + + val elementalNode = ElementalNode.ofUnionMember3(unionMember3) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).contains(unionMember3) + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember3Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember3( + ElementalNode.UnionMember3.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember3.Type.IMAGE) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember4() { + val unionMember4 = + ElementalNode.UnionMember4.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember4.Type.ACTION) + .build() + + val elementalNode = ElementalNode.ofUnionMember4(unionMember4) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).contains(unionMember4) + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember4Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember4( + ElementalNode.UnionMember4.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember4.Type.ACTION) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember5() { + val unionMember5 = + ElementalNode.UnionMember5.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember5.Type.DIVIDER) + .build() + + val elementalNode = ElementalNode.ofUnionMember5(unionMember5) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).contains(unionMember5) + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember5Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember5( + ElementalNode.UnionMember5.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember5.Type.DIVIDER) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember6() { + val unionMember6 = + ElementalNode.UnionMember6.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember6.Type.GROUP) + .build() + + val elementalNode = ElementalNode.ofUnionMember6(unionMember6) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).contains(unionMember6) + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember6Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember6( + ElementalNode.UnionMember6.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember6.Type.GROUP) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember7() { + val unionMember7 = + ElementalNode.UnionMember7.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember7.Type.QUOTE) + .build() + + val elementalNode = ElementalNode.ofUnionMember7(unionMember7) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).contains(unionMember7) + } + + @Test + fun ofUnionMember7Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember7( + ElementalNode.UnionMember7.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember7.Type.QUOTE) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val elementalNode = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { elementalNode.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageContextTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageContextTest.kt new file mode 100644 index 00000000..fbad3227 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageContextTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MessageContextTest { + + @Test + fun create() { + val messageContext = MessageContext.builder().tenantId("tenant_id").build() + + assertThat(messageContext.tenantId()).contains("tenant_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val messageContext = MessageContext.builder().tenantId("tenant_id").build() + + val roundtrippedMessageContext = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageContext), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMessageContext).isEqualTo(messageContext) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt new file mode 100644 index 00000000..cfd8399f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt @@ -0,0 +1,793 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class MessageTest { + + @Test + fun ofContent() { + val content = + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF + ) + .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + + val message = Message.ofContent(content) + + assertThat(message.content()).contains(content) + assertThat(message.template()).isEmpty + } + + @Test + fun ofContentRoundtrip() { + val jsonMapper = jsonMapper() + val message = + Message.ofContent( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + + val roundtrippedMessage = + jsonMapper.readValue(jsonMapper.writeValueAsString(message), jacksonTypeRef()) + + assertThat(roundtrippedMessage).isEqualTo(message) + } + + @Test + fun ofTemplate() { + val template = + Message.TemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF + ) + .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + ) + .template("template") + .build() + + val message = Message.ofTemplate(template) + + assertThat(message.content()).isEmpty + assertThat(message.template()).contains(template) + } + + @Test + fun ofTemplateRoundtrip() { + val jsonMapper = jsonMapper() + val message = + Message.ofTemplate( + Message.TemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .template("template") + .build() + ) + + val roundtrippedMessage = + jsonMapper.readValue(jsonMapper.writeValueAsString(message), jacksonTypeRef()) + + assertThat(roundtrippedMessage).isEqualTo(message) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val message = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { message.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt new file mode 100644 index 00000000..c544d37e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MsTeamsBasePropertiesTest { + + @Test + fun create() { + val msTeamsBaseProperties = + MsTeamsBaseProperties.builder().serviceUrl("service_url").tenantId("tenant_id").build() + + assertThat(msTeamsBaseProperties.serviceUrl()).isEqualTo("service_url") + assertThat(msTeamsBaseProperties.tenantId()).isEqualTo("tenant_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val msTeamsBaseProperties = + MsTeamsBaseProperties.builder().serviceUrl("service_url").tenantId("tenant_id").build() + + val roundtrippedMsTeamsBaseProperties = + jsonMapper.readValue( + jsonMapper.writeValueAsString(msTeamsBaseProperties), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMsTeamsBaseProperties).isEqualTo(msTeamsBaseProperties) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt new file mode 100644 index 00000000..15f3ccf2 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt @@ -0,0 +1,633 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.bulk.UserRecipient +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class RecipientTest { + + @Test + fun ofAudience() { + val audience = + Recipient.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + Recipient.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + Recipient.AudienceRecipient.Filter.builder() + .operator(Recipient.AudienceRecipient.Filter.Operator.MEMBER_OF) + .path(Recipient.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + + val recipient = Recipient.ofAudience(audience) + + assertThat(recipient.audience()).contains(audience) + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofAudienceRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofAudience( + Recipient.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + Recipient.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + Recipient.AudienceRecipient.Filter.builder() + .operator(Recipient.AudienceRecipient.Filter.Operator.MEMBER_OF) + .path(Recipient.AudienceRecipient.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofUnionMember1() { + val unionMember1 = + Recipient.UnionMember1.builder() + .data( + Recipient.UnionMember1.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + Recipient.UnionMember1.Filter.builder() + .operator(Recipient.UnionMember1.Filter.Operator.MEMBER_OF) + .path(Recipient.UnionMember1.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .listId("list_id") + .build() + + val recipient = Recipient.ofUnionMember1(unionMember1) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).contains(unionMember1) + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofUnionMember1Roundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofUnionMember1( + Recipient.UnionMember1.builder() + .data( + Recipient.UnionMember1.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + Recipient.UnionMember1.Filter.builder() + .operator(Recipient.UnionMember1.Filter.Operator.MEMBER_OF) + .path(Recipient.UnionMember1.Filter.Path.ACCOUNT_ID) + .value("value") + .build() + ) + .listId("list_id") + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofUnionMember2() { + val unionMember2 = + Recipient.UnionMember2.builder() + .data( + Recipient.UnionMember2.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .listPattern("list_pattern") + .build() + + val recipient = Recipient.ofUnionMember2(unionMember2) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).contains(unionMember2) + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofUnionMember2Roundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofUnionMember2( + Recipient.UnionMember2.builder() + .data( + Recipient.UnionMember2.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .listPattern("list_pattern") + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofUser() { + val user = + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + + val recipient = Recipient.ofUser(user) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).contains(user) + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofUserRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofUser( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofSlack() { + val slack = + Recipient.SlackRecipient.builder() + .slack( + Recipient.SlackRecipient.Slack.SendToSlackChannel.builder() + .accessToken("access_token") + .channel("channel") + .build() + ) + .build() + + val recipient = Recipient.ofSlack(slack) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).contains(slack) + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofSlackRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofSlack( + Recipient.SlackRecipient.builder() + .slack( + Recipient.SlackRecipient.Slack.SendToSlackChannel.builder() + .accessToken("access_token") + .channel("channel") + .build() + ) + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofMsTeams() { + val msTeams = + Recipient.MsTeamsRecipient.builder() + .msTeams( + Recipient.MsTeamsRecipient.MsTeams.SendToMsTeamsUserId.builder() + .serviceUrl("service_url") + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + + val recipient = Recipient.ofMsTeams(msTeams) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).contains(msTeams) + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofMsTeamsRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofMsTeams( + Recipient.MsTeamsRecipient.builder() + .msTeams( + Recipient.MsTeamsRecipient.MsTeams.SendToMsTeamsUserId.builder() + .serviceUrl("service_url") + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofData() { + val data = + Recipient.RecipientData.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + + val recipient = Recipient.ofData(data) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).contains(data) + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofDataRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofData( + Recipient.RecipientData.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofPagerduty() { + val pagerduty = + Recipient.PagerdutyRecipient.builder() + .pagerduty( + Recipient.PagerdutyRecipient.Pagerduty.builder() + .eventAction("event_action") + .routingKey("routing_key") + .severity("severity") + .source("source") + .build() + ) + .build() + + val recipient = Recipient.ofPagerduty(pagerduty) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).contains(pagerduty) + assertThat(recipient.webhook()).isEmpty + } + + @Test + fun ofPagerdutyRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofPagerduty( + Recipient.PagerdutyRecipient.builder() + .pagerduty( + Recipient.PagerdutyRecipient.Pagerduty.builder() + .eventAction("event_action") + .routingKey("routing_key") + .severity("severity") + .source("source") + .build() + ) + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + @Test + fun ofWebhook() { + val webhook = + Recipient.WebhookRecipient.builder() + .webhook( + Recipient.WebhookRecipient.Webhook.builder() + .url("url") + .authentication( + Recipient.WebhookRecipient.Webhook.Authentication.builder() + .mode(Recipient.WebhookRecipient.Webhook.Authentication.Mode.NONE) + .token("token") + .password("password") + .username("username") + .build() + ) + .headers( + Recipient.WebhookRecipient.Webhook.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .method(Recipient.WebhookRecipient.Webhook.Method.POST) + .profile(Recipient.WebhookRecipient.Webhook.Profile.LIMITED) + .build() + ) + .build() + + val recipient = Recipient.ofWebhook(webhook) + + assertThat(recipient.audience()).isEmpty + assertThat(recipient.unionMember1()).isEmpty + assertThat(recipient.unionMember2()).isEmpty + assertThat(recipient.user()).isEmpty + assertThat(recipient.slack()).isEmpty + assertThat(recipient.msTeams()).isEmpty + assertThat(recipient.data()).isEmpty + assertThat(recipient.pagerduty()).isEmpty + assertThat(recipient.webhook()).contains(webhook) + } + + @Test + fun ofWebhookRoundtrip() { + val jsonMapper = jsonMapper() + val recipient = + Recipient.ofWebhook( + Recipient.WebhookRecipient.builder() + .webhook( + Recipient.WebhookRecipient.Webhook.builder() + .url("url") + .authentication( + Recipient.WebhookRecipient.Webhook.Authentication.builder() + .mode( + Recipient.WebhookRecipient.Webhook.Authentication.Mode.NONE + ) + .token("token") + .password("password") + .username("username") + .build() + ) + .headers( + Recipient.WebhookRecipient.Webhook.Headers.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .method(Recipient.WebhookRecipient.Webhook.Method.POST) + .profile(Recipient.WebhookRecipient.Webhook.Profile.LIMITED) + .build() + ) + .build() + ) + + val roundtrippedRecipient = + jsonMapper.readValue( + jsonMapper.writeValueAsString(recipient), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRecipient).isEqualTo(recipient) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val recipient = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { recipient.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt new file mode 100644 index 00000000..35068e0f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt @@ -0,0 +1,641 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SendSendMessageParamsTest { + + @Test + fun create() { + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.message()) + .isEqualTo( + Message.ofContent( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .content( + Content.ElementalContent.builder() + .addElement(ElementalNode.UnionMember0.builder().build()) + .version("version") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.message()) + .isEqualTo( + Message.ofContent( + Message.ContentMessage.builder() + .content( + Content.ElementalContent.builder() + .addElement(ElementalNode.UnionMember0.builder().build()) + .version("version") + .build() + ) + .build() + ) + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt new file mode 100644 index 00000000..5912fb9f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SendSendMessageResponseTest { + + @Test + fun create() { + val sendSendMessageResponse = + SendSendMessageResponse.builder().requestId("requestId").build() + + assertThat(sendSendMessageResponse.requestId()).isEqualTo("requestId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sendSendMessageResponse = + SendSendMessageResponse.builder().requestId("requestId").build() + + val roundtrippedSendSendMessageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sendSendMessageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSendSendMessageResponse).isEqualTo(sendSendMessageResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt new file mode 100644 index 00000000..557ada7d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SlackBasePropertiesTest { + + @Test + fun create() { + val slackBaseProperties = SlackBaseProperties.builder().accessToken("access_token").build() + + assertThat(slackBaseProperties.accessToken()).isEqualTo("access_token") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val slackBaseProperties = SlackBaseProperties.builder().accessToken("access_token").build() + + val roundtrippedSlackBaseProperties = + jsonMapper.readValue( + jsonMapper.writeValueAsString(slackBaseProperties), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSlackBaseProperties).isEqualTo(slackBaseProperties) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt new file mode 100644 index 00000000..889e13b8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtmTest { + + @Test + fun create() { + val utm = + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + + assertThat(utm.campaign()).contains("campaign") + assertThat(utm.content()).contains("content") + assertThat(utm.medium()).contains("medium") + assertThat(utm.source()).contains("source") + assertThat(utm.term()).contains("term") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val utm = + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + + val roundtrippedUtm = + jsonMapper.readValue(jsonMapper.writeValueAsString(utm), jacksonTypeRef()) + + assertThat(roundtrippedUtm).isEqualTo(utm) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt new file mode 100644 index 00000000..4e7b4acb --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.jsonMapper +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DefaultPreferencesTest { + + @Test + fun create() { + val defaultPreferences = + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + + assertThat(defaultPreferences.items().getOrNull()) + .containsExactly( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val defaultPreferences = + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + + val roundtrippedDefaultPreferences = + jsonMapper.readValue( + jsonMapper.writeValueAsString(defaultPreferences), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDefaultPreferences).isEqualTo(defaultPreferences) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt new file mode 100644 index 00000000..73af19c6 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantDeleteParamsTest { + + @Test + fun create() { + TenantDeleteParams.builder().tenantId("tenant_id").build() + } + + @Test + fun pathParams() { + val params = TenantDeleteParams.builder().tenantId("tenant_id").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt new file mode 100644 index 00000000..4ccb72f5 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListParamsTest { + + @Test + fun create() { + TenantListParams.builder() + .cursor("cursor") + .limit(0L) + .parentTenantId("parent_tenant_id") + .build() + } + + @Test + fun queryParams() { + val params = + TenantListParams.builder() + .cursor("cursor") + .limit(0L) + .parentTenantId("parent_tenant_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("cursor", "cursor") + .put("limit", "0") + .put("parent_tenant_id", "parent_tenant_id") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = TenantListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt new file mode 100644 index 00000000..2cdaf64f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt @@ -0,0 +1,144 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListResponseTest { + + @Test + fun create() { + val tenantListResponse = + TenantListResponse.builder() + .hasMore(true) + .addItem( + Tenant.builder() + .id("id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + Tenant.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + Tenant.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .type(TenantListResponse.Type.LIST) + .url("url") + .cursor("cursor") + .nextUrl("next_url") + .build() + + assertThat(tenantListResponse.hasMore()).isEqualTo(true) + assertThat(tenantListResponse.items()) + .containsExactly( + Tenant.builder() + .id("id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + Tenant.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + Tenant.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + assertThat(tenantListResponse.type()).isEqualTo(TenantListResponse.Type.LIST) + assertThat(tenantListResponse.url()).isEqualTo("url") + assertThat(tenantListResponse.cursor()).contains("cursor") + assertThat(tenantListResponse.nextUrl()).contains("next_url") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tenantListResponse = + TenantListResponse.builder() + .hasMore(true) + .addItem( + Tenant.builder() + .id("id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + Tenant.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + Tenant.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .type(TenantListResponse.Type.LIST) + .url("url") + .cursor("cursor") + .nextUrl("next_url") + .build() + + val roundtrippedTenantListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tenantListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTenantListResponse).isEqualTo(tenantListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt new file mode 100644 index 00000000..633d142b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListUsersParamsTest { + + @Test + fun create() { + TenantListUsersParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() + } + + @Test + fun pathParams() { + val params = TenantListUsersParams.builder().tenantId("tenant_id").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + TenantListUsersParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "0").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = TenantListUsersParams.builder().tenantId("tenant_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt new file mode 100644 index 00000000..d6445bd4 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt @@ -0,0 +1,90 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.users.tenants.TenantAssociation +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListUsersResponseTest { + + @Test + fun create() { + val tenantListUsersResponse = + TenantListUsersResponse.builder() + .hasMore(true) + .type(TenantListUsersResponse.Type.LIST) + .url("url") + .cursor("cursor") + .addItem( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .nextUrl("next_url") + .build() + + assertThat(tenantListUsersResponse.hasMore()).isEqualTo(true) + assertThat(tenantListUsersResponse.type()).isEqualTo(TenantListUsersResponse.Type.LIST) + assertThat(tenantListUsersResponse.url()).isEqualTo("url") + assertThat(tenantListUsersResponse.cursor()).contains("cursor") + assertThat(tenantListUsersResponse.items().getOrNull()) + .containsExactly( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + assertThat(tenantListUsersResponse.nextUrl()).contains("next_url") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tenantListUsersResponse = + TenantListUsersResponse.builder() + .hasMore(true) + .type(TenantListUsersResponse.Type.LIST) + .url("url") + .cursor("cursor") + .addItem( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .nextUrl("next_url") + .build() + + val roundtrippedTenantListUsersResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tenantListUsersResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTenantListUsersResponse).isEqualTo(tenantListUsersResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt new file mode 100644 index 00000000..81b74128 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantRetrieveParamsTest { + + @Test + fun create() { + TenantRetrieveParams.builder().tenantId("tenant_id").build() + } + + @Test + fun pathParams() { + val params = TenantRetrieveParams.builder().tenantId("tenant_id").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt new file mode 100644 index 00000000..b4e30b15 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantTest { + + @Test + fun create() { + val tenant = + Tenant.builder() + .id("id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + Tenant.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + Tenant.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + assertThat(tenant.id()).isEqualTo("id") + assertThat(tenant.name()).isEqualTo("name") + assertThat(tenant.brandId()).contains("brand_id") + assertThat(tenant.defaultPreferences()) + .contains( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + assertThat(tenant.parentTenantId()).contains("parent_tenant_id") + assertThat(tenant.properties()) + .contains( + Tenant.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tenant.userProfile()) + .contains( + Tenant.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tenant = + Tenant.builder() + .id("id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + Tenant.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + Tenant.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val roundtrippedTenant = + jsonMapper.readValue(jsonMapper.writeValueAsString(tenant), jacksonTypeRef()) + + assertThat(roundtrippedTenant).isEqualTo(tenant) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt new file mode 100644 index 00000000..f56d4f3c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantUpdateParamsTest { + + @Test + fun create() { + TenantUpdateParams.builder() + .tenantId("tenant_id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + TenantUpdateParams.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + TenantUpdateParams.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = TenantUpdateParams.builder().tenantId("tenant_id").name("name").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + TenantUpdateParams.builder() + .tenantId("tenant_id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + TenantUpdateParams.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + TenantUpdateParams.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + assertThat(body.brandId()).contains("brand_id") + assertThat(body.defaultPreferences()) + .contains( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + assertThat(body.parentTenantId()).contains("parent_tenant_id") + assertThat(body.properties()) + .contains( + TenantUpdateParams.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(body.userProfile()) + .contains( + TenantUpdateParams.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = TenantUpdateParams.builder().tenantId("tenant_id").name("name").build() + + val body = params._body() + + assertThat(body.name()).isEqualTo("name") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt new file mode 100644 index 00000000..b24fe6a7 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemDeleteParamsTest { + + @Test + fun create() { + ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() + } + + @Test + fun pathParams() { + val params = ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + assertThat(params._pathParam(1)).isEqualTo("topic_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt new file mode 100644 index 00000000..7e048ddd --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ItemUpdateParamsTest { + + @Test + fun create() { + ItemUpdateParams.builder() + .tenantId("tenant_id") + .topicId("topic_id") + .subscriptionTopicNew( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .hasCustomRouting(true) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + ItemUpdateParams.builder() + .tenantId("tenant_id") + .topicId("topic_id") + .subscriptionTopicNew( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + assertThat(params._pathParam(1)).isEqualTo("topic_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + ItemUpdateParams.builder() + .tenantId("tenant_id") + .topicId("topic_id") + .subscriptionTopicNew( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .hasCustomRouting(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .hasCustomRouting(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + ItemUpdateParams.builder() + .tenantId("tenant_id") + .topicId("topic_id") + .subscriptionTopicNew( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + SubscriptionTopicNew.builder().status(SubscriptionTopicNew.Status.OPTED_IN).build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt new file mode 100644 index 00000000..bc9799a9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.defaultpreferences.items + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SubscriptionTopicNewTest { + + @Test + fun create() { + val subscriptionTopicNew = + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + + assertThat(subscriptionTopicNew.status()).isEqualTo(SubscriptionTopicNew.Status.OPTED_OUT) + assertThat(subscriptionTopicNew.customRouting().getOrNull()) + .containsExactly(ChannelClassification.DIRECT_MESSAGE) + assertThat(subscriptionTopicNew.hasCustomRouting()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val subscriptionTopicNew = + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + + val roundtrippedSubscriptionTopicNew = + jsonMapper.readValue( + jsonMapper.writeValueAsString(subscriptionTopicNew), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSubscriptionTopicNew).isEqualTo(subscriptionTopicNew) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt new file mode 100644 index 00000000..51f2c042 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.translations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TranslationRetrieveParamsTest { + + @Test + fun create() { + TranslationRetrieveParams.builder().domain("domain").locale("locale").build() + } + + @Test + fun pathParams() { + val params = TranslationRetrieveParams.builder().domain("domain").locale("locale").build() + + assertThat(params._pathParam(0)).isEqualTo("domain") + assertThat(params._pathParam(1)).isEqualTo("locale") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt new file mode 100644 index 00000000..8c1a69a5 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.translations + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TranslationUpdateParamsTest { + + @Test + fun create() { + TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() + } + + @Test + fun pathParams() { + val params = + TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() + + assertThat(params._pathParam(0)).isEqualTo("domain") + assertThat(params._pathParam(1)).isEqualTo("locale") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() + + val body = params._body() + + assertThat(body).isEqualTo("body") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt new file mode 100644 index 00000000..a647f715 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceRetrieveParamsTest { + + @Test + fun create() { + PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() + } + + @Test + fun pathParams() { + val params = PreferenceRetrieveParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("tenant_id", "tenant_id").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = PreferenceRetrieveParams.builder().userId("user_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt new file mode 100644 index 00000000..b0ccb74f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.jsonMapper +import com.courier.api.models.audiences.Paging +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceRetrieveResponseTest { + + @Test + fun create() { + val preferenceRetrieveResponse = + PreferenceRetrieveResponse.builder() + .addItem( + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + assertThat(preferenceRetrieveResponse.items()) + .containsExactly( + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + ) + assertThat(preferenceRetrieveResponse.paging()) + .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preferenceRetrieveResponse = + PreferenceRetrieveResponse.builder() + .addItem( + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + ) + .paging(Paging.builder().more(true).cursor("cursor").build()) + .build() + + val roundtrippedPreferenceRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preferenceRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreferenceRetrieveResponse).isEqualTo(preferenceRetrieveResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt new file mode 100644 index 00000000..3b991def --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceRetrieveTopicParamsTest { + + @Test + fun create() { + PreferenceRetrieveTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .build() + } + + @Test + fun pathParams() { + val params = + PreferenceRetrieveTopicParams.builder().userId("user_id").topicId("topic_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("topic_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + PreferenceRetrieveTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("tenant_id", "tenant_id").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + PreferenceRetrieveTopicParams.builder().userId("user_id").topicId("topic_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt new file mode 100644 index 00000000..436043f4 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.jsonMapper +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceRetrieveTopicResponseTest { + + @Test + fun create() { + val preferenceRetrieveTopicResponse = + PreferenceRetrieveTopicResponse.builder() + .topic( + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + ) + .build() + + assertThat(preferenceRetrieveTopicResponse.topic()) + .isEqualTo( + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preferenceRetrieveTopicResponse = + PreferenceRetrieveTopicResponse.builder() + .topic( + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + ) + .build() + + val roundtrippedPreferenceRetrieveTopicResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preferenceRetrieveTopicResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreferenceRetrieveTopicResponse) + .isEqualTo(preferenceRetrieveTopicResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt new file mode 100644 index 00000000..a7152c75 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.http.QueryParams +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceUpdateOrCreateTopicParamsTest { + + @Test + fun create() { + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .addCustomRouting(ChannelClassification.EMAIL) + .hasCustomRouting(true) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("topic_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .addCustomRouting(ChannelClassification.EMAIL) + .hasCustomRouting(true) + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("tenant_id", "tenant_id").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .addCustomRouting(ChannelClassification.EMAIL) + .hasCustomRouting(true) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.topic()) + .isEqualTo( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .addCustomRouting(ChannelClassification.EMAIL) + .hasCustomRouting(true) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.topic()) + .isEqualTo( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt new file mode 100644 index 00000000..179b2d82 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceUpdateOrCreateTopicResponseTest { + + @Test + fun create() { + val preferenceUpdateOrCreateTopicResponse = + PreferenceUpdateOrCreateTopicResponse.builder().message("success").build() + + assertThat(preferenceUpdateOrCreateTopicResponse.message()).isEqualTo("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preferenceUpdateOrCreateTopicResponse = + PreferenceUpdateOrCreateTopicResponse.builder().message("success").build() + + val roundtrippedPreferenceUpdateOrCreateTopicResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preferenceUpdateOrCreateTopicResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreferenceUpdateOrCreateTopicResponse) + .isEqualTo(preferenceUpdateOrCreateTopicResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt new file mode 100644 index 00000000..af9338f2 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.preferences + +import com.courier.api.core.jsonMapper +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TopicPreferenceTest { + + @Test + fun create() { + val topicPreference = + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + + assertThat(topicPreference.defaultStatus()).isEqualTo(PreferenceStatus.OPTED_IN) + assertThat(topicPreference.status()).isEqualTo(PreferenceStatus.OPTED_IN) + assertThat(topicPreference.topicId()).isEqualTo("topic_id") + assertThat(topicPreference.topicName()).isEqualTo("topic_name") + assertThat(topicPreference.customRouting().getOrNull()) + .containsExactly(ChannelClassification.DIRECT_MESSAGE) + assertThat(topicPreference.hasCustomRouting()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val topicPreference = + TopicPreference.builder() + .defaultStatus(PreferenceStatus.OPTED_IN) + .status(PreferenceStatus.OPTED_IN) + .topicId("topic_id") + .topicName("topic_name") + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .build() + + val roundtrippedTopicPreference = + jsonMapper.readValue( + jsonMapper.writeValueAsString(topicPreference), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTopicPreference).isEqualTo(topicPreference) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt new file mode 100644 index 00000000..9f403606 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt @@ -0,0 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantAddMultipleParamsTest { + + @Test + fun create() { + TenantAddMultipleParams.builder() + .userId("user_id") + .addTenant( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + TenantAddMultipleParams.builder() + .userId("user_id") + .addTenant(TenantAssociation.builder().tenantId("tenant_id").build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + TenantAddMultipleParams.builder() + .userId("user_id") + .addTenant( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.tenants()) + .containsExactly( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TenantAddMultipleParams.builder() + .userId("user_id") + .addTenant(TenantAssociation.builder().tenantId("tenant_id").build()) + .build() + + val body = params._body() + + assertThat(body.tenants()) + .containsExactly(TenantAssociation.builder().tenantId("tenant_id").build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt new file mode 100644 index 00000000..9352423e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantAddSingleParamsTest { + + @Test + fun create() { + TenantAddSingleParams.builder() + .userId("user_id") + .tenantId("tenant_id") + .profile( + TenantAddSingleParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = TenantAddSingleParams.builder().userId("user_id").tenantId("tenant_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + TenantAddSingleParams.builder() + .userId("user_id") + .tenantId("tenant_id") + .profile( + TenantAddSingleParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.profile()) + .contains( + TenantAddSingleParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = TenantAddSingleParams.builder().userId("user_id").tenantId("tenant_id").build() + + val body = params._body() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt new file mode 100644 index 00000000..57ac45b2 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantAssociationTest { + + @Test + fun create() { + val tenantAssociation = + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + + assertThat(tenantAssociation.tenantId()).isEqualTo("tenant_id") + assertThat(tenantAssociation.profile()) + .contains( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(tenantAssociation.type()).contains(TenantAssociation.Type.USER) + assertThat(tenantAssociation.userId()).contains("user_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tenantAssociation = + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + + val roundtrippedTenantAssociation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tenantAssociation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTenantAssociation).isEqualTo(tenantAssociation) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt new file mode 100644 index 00000000..1a86f423 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListParamsTest { + + @Test + fun create() { + TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() + } + + @Test + fun pathParams() { + val params = TenantListParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "0").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = TenantListParams.builder().userId("user_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt new file mode 100644 index 00000000..695e75ed --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantListResponseTest { + + @Test + fun create() { + val tenantListResponse = + TenantListResponse.builder() + .hasMore(true) + .type(TenantListResponse.Type.LIST) + .url("url") + .cursor("cursor") + .addItem( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .nextUrl("next_url") + .build() + + assertThat(tenantListResponse.hasMore()).isEqualTo(true) + assertThat(tenantListResponse.type()).isEqualTo(TenantListResponse.Type.LIST) + assertThat(tenantListResponse.url()).isEqualTo("url") + assertThat(tenantListResponse.cursor()).contains("cursor") + assertThat(tenantListResponse.items().getOrNull()) + .containsExactly( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + assertThat(tenantListResponse.nextUrl()).contains("next_url") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tenantListResponse = + TenantListResponse.builder() + .hasMore(true) + .type(TenantListResponse.Type.LIST) + .url("url") + .cursor("cursor") + .addItem( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .nextUrl("next_url") + .build() + + val roundtrippedTenantListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tenantListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTenantListResponse).isEqualTo(tenantListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt new file mode 100644 index 00000000..5affcc16 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantRemoveAllParamsTest { + + @Test + fun create() { + TenantRemoveAllParams.builder().userId("user_id").build() + } + + @Test + fun pathParams() { + val params = TenantRemoveAllParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt new file mode 100644 index 00000000..fb0f705e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tenants + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TenantRemoveSingleParamsTest { + + @Test + fun create() { + TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() + } + + @Test + fun pathParams() { + val params = + TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt new file mode 100644 index 00000000..67cdc296 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenAddMultipleParamsTest { + + @Test + fun create() { + TokenAddMultipleParams.builder().userId("user_id").build() + } + + @Test + fun pathParams() { + val params = TokenAddMultipleParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt new file mode 100644 index 00000000..f469be79 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenAddSingleParamsTest { + + @Test + fun create() { + TokenAddSingleParams.builder() + .userId("user_id") + .pathToken("token") + .userToken( + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + TokenAddSingleParams.builder() + .userId("user_id") + .pathToken("token") + .userToken( + UserToken.builder().providerKey(UserToken.ProviderKey.FIREBASE_FCM).build() + ) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("token") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + TokenAddSingleParams.builder() + .userId("user_id") + .pathToken("token") + .userToken( + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TokenAddSingleParams.builder() + .userId("user_id") + .pathToken("token") + .userToken( + UserToken.builder().providerKey(UserToken.ProviderKey.FIREBASE_FCM).build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo(UserToken.builder().providerKey(UserToken.ProviderKey.FIREBASE_FCM).build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt new file mode 100644 index 00000000..83ea313e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenDeleteParamsTest { + + @Test + fun create() { + TokenDeleteParams.builder().userId("user_id").token("token").build() + } + + @Test + fun pathParams() { + val params = TokenDeleteParams.builder().userId("user_id").token("token").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("token") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt new file mode 100644 index 00000000..6bd6f11f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenListParamsTest { + + @Test + fun create() { + TokenListParams.builder().userId("user_id").build() + } + + @Test + fun pathParams() { + val params = TokenListParams.builder().userId("user_id").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt new file mode 100644 index 00000000..11211c56 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenRetrieveSingleParamsTest { + + @Test + fun create() { + TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() + } + + @Test + fun pathParams() { + val params = TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("token") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt new file mode 100644 index 00000000..511a3c56 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenRetrieveSingleResponseTest { + + @Test + fun create() { + val tokenRetrieveSingleResponse = + TokenRetrieveSingleResponse.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .status(TokenRetrieveSingleResponse.Status.ACTIVE) + .statusReason("status_reason") + .build() + + assertThat(tokenRetrieveSingleResponse.providerKey()) + .isEqualTo(UserToken.ProviderKey.FIREBASE_FCM) + assertThat(tokenRetrieveSingleResponse.token()).contains("token") + assertThat(tokenRetrieveSingleResponse.device()) + .contains( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + assertThat(tokenRetrieveSingleResponse.expiryDate()) + .contains(UserToken.ExpiryDate.ofString("string")) + assertThat(tokenRetrieveSingleResponse._properties()) + .isEqualTo(JsonValue.from(mapOf())) + assertThat(tokenRetrieveSingleResponse.tracking()) + .contains( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + assertThat(tokenRetrieveSingleResponse.status()) + .contains(TokenRetrieveSingleResponse.Status.ACTIVE) + assertThat(tokenRetrieveSingleResponse.statusReason()).contains("status_reason") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val tokenRetrieveSingleResponse = + TokenRetrieveSingleResponse.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .status(TokenRetrieveSingleResponse.Status.ACTIVE) + .statusReason("status_reason") + .build() + + val roundtrippedTokenRetrieveSingleResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(tokenRetrieveSingleResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTokenRetrieveSingleResponse).isEqualTo(tokenRetrieveSingleResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt new file mode 100644 index 00000000..53deb2f8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TokenUpdateParamsTest { + + @Test + fun create() { + TokenUpdateParams.builder() + .userId("user_id") + .token("token") + .addPatch( + TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + } + + @Test + fun pathParams() { + val params = + TokenUpdateParams.builder() + .userId("user_id") + .token("token") + .addPatch(TokenUpdateParams.Patch.builder().op("op").path("path").build()) + .build() + + assertThat(params._pathParam(0)).isEqualTo("user_id") + assertThat(params._pathParam(1)).isEqualTo("token") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } + + @Test + fun body() { + val params = + TokenUpdateParams.builder() + .userId("user_id") + .token("token") + .addPatch( + TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + + val body = params._body() + + assertThat(body.patch()) + .containsExactly( + TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TokenUpdateParams.builder() + .userId("user_id") + .token("token") + .addPatch(TokenUpdateParams.Patch.builder().op("op").path("path").build()) + .build() + + val body = params._body() + + assertThat(body.patch()) + .containsExactly(TokenUpdateParams.Patch.builder().op("op").path("path").build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt new file mode 100644 index 00000000..299f2391 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.users.tokens + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UserTokenTest { + + @Test + fun create() { + val userToken = + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + + assertThat(userToken.providerKey()).isEqualTo(UserToken.ProviderKey.FIREBASE_FCM) + assertThat(userToken.token()).contains("token") + assertThat(userToken.device()) + .contains( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + assertThat(userToken.expiryDate()).contains(UserToken.ExpiryDate.ofString("string")) + assertThat(userToken._properties()).isEqualTo(JsonValue.from(mapOf())) + assertThat(userToken.tracking()) + .contains( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val userToken = + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + + val roundtrippedUserToken = + jsonMapper.readValue( + jsonMapper.writeValueAsString(userToken), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUserToken).isEqualTo(userToken) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt new file mode 100644 index 00000000..2f385f95 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -0,0 +1,4013 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services + +import com.courier.api.client.CourierClient +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.core.http.Headers +import com.courier.api.core.jsonMapper +import com.courier.api.errors.BadRequestException +import com.courier.api.errors.CourierException +import com.courier.api.errors.InternalServerException +import com.courier.api.errors.NotFoundException +import com.courier.api.errors.PermissionDeniedException +import com.courier.api.errors.RateLimitException +import com.courier.api.errors.UnauthorizedException +import com.courier.api.errors.UnexpectedStatusCodeException +import com.courier.api.errors.UnprocessableEntityException +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.BaseMessageSendTo +import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode +import com.courier.api.models.send.Message +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.Utm +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.status +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.entry +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ErrorHandlingTest { + + companion object { + + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) + + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) + + private const val HEADER_NAME: String = "Error-Header" + + private const val HEADER_VALUE: String = "42" + + private const val NOT_JSON: String = "Not JSON" + } + + private lateinit var client: CourierClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + CourierOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + } + + @Test + fun sendSendMessage400() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage400WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(400) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage401() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage401WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(401) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage403() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage403WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(403) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage404() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage404WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(404) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage422() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage422WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(422) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage429() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage429WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(429) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage500() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage500WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(500) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage999() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessage999WithRawResponse() { + val sendService = client.send().withRawResponse() + stubFor( + post(anyUrl()) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e.statusCode()).isEqualTo(999) + assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) + } + + @Test + fun sendSendMessageInvalidJsonBody() { + val sendService = client.send() + stubFor( + post(anyUrl()) + .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) + ) + + val e = + assertThrows { + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder().duration(0L).until("until").build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + } + + assertThat(e).hasMessage("Error reading response") + } + + private fun Headers.toMap(): Map> = + mutableMapOf>().also { map -> + names().forEach { map[it] = values(it) } + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt new file mode 100644 index 00000000..e694c478 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -0,0 +1,262 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services + +import com.courier.api.client.CourierClient +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.BaseMessageSendTo +import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode +import com.courier.api.models.send.Message +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.Utm +import com.github.tomakehurst.wiremock.client.WireMock.anyUrl +import com.github.tomakehurst.wiremock.client.WireMock.equalTo +import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath +import com.github.tomakehurst.wiremock.client.WireMock.ok +import com.github.tomakehurst.wiremock.client.WireMock.post +import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor +import com.github.tomakehurst.wiremock.client.WireMock.stubFor +import com.github.tomakehurst.wiremock.client.WireMock.verify +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class ServiceParamsTest { + + private lateinit var client: CourierClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + client = + CourierOkHttpClient.builder() + .baseUrl(wmRuntimeInfo.httpBaseUrl) + .apiKey("My API Key") + .build() + } + + @Disabled("Prism tests are disabled") + @Test + fun sendMessage() { + val sendService = client.send() + stubFor(post(anyUrl()).willReturn(ok("{}"))) + + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") + .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) + .build() + ) + + verify( + postRequestedFor(anyUrl()) + .withHeader("Secret-Header", equalTo("42")) + .withQueryParam("secret_query_param", equalTo("42")) + .withRequestBody(matchingJsonPath("$.secretProperty", equalTo("42"))) + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt new file mode 100644 index 00000000..ed40e354 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.audiences.AudienceListMembersParams +import com.courier.api.models.audiences.AudienceListParams +import com.courier.api.models.audiences.AudienceUpdateParams +import com.courier.api.models.audiences.Filter +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AudienceServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceServiceAsync = client.audiences() + + val audienceFuture = audienceServiceAsync.retrieve("audience_id") + + val audience = audienceFuture.get() + audience.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceServiceAsync = client.audiences() + + val audienceFuture = + audienceServiceAsync.update( + AudienceUpdateParams.builder() + .audienceId("audience_id") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .build() + ) + + val audience = audienceFuture.get() + audience.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceServiceAsync = client.audiences() + + val audiencesFuture = + audienceServiceAsync.list(AudienceListParams.builder().cursor("cursor").build()) + + val audiences = audiencesFuture.get() + audiences.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceServiceAsync = client.audiences() + + val future = audienceServiceAsync.delete("audience_id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun listMembers() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceServiceAsync = client.audiences() + + val responseFuture = + audienceServiceAsync.listMembers( + AudienceListMembersParams.builder() + .audienceId("audience_id") + .cursor("cursor") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt new file mode 100644 index 00000000..0a290b6b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.auditevents.AuditEventListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AuditEventServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val auditEventServiceAsync = client.auditEvents() + + val auditEventFuture = auditEventServiceAsync.retrieve("audit-event-id") + + val auditEvent = auditEventFuture.get() + auditEvent.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val auditEventServiceAsync = client.auditEvents() + + val auditEventsFuture = + auditEventServiceAsync.list(AuditEventListParams.builder().cursor("cursor").build()) + + val auditEvents = auditEventsFuture.get() + auditEvents.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt new file mode 100644 index 00000000..63da8a0b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.auth.AuthIssueTokenParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AuthServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun issueToken() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val authServiceAsync = client.auth() + + val responseFuture = + authServiceAsync.issueToken( + AuthIssueTokenParams.builder() + .expiresIn("expires_in") + .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt new file mode 100644 index 00000000..3d31a7ce --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.automations.AutomationInvokeAdHocParams +import com.courier.api.models.automations.AutomationInvokeByTemplateParams +import com.courier.api.models.automations.invoke.AutomationInvokeParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AutomationServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun invokeAdHoc() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val automationServiceAsync = client.automations() + + val automationInvokeResponseFuture = + automationServiceAsync.invokeAdHoc( + AutomationInvokeAdHocParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .automation( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .builder() + .if_("if") + .ref("ref") + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .cancelationToken("cancelation_token") + .build() + ) + .build() + ) + + val automationInvokeResponse = automationInvokeResponseFuture.get() + automationInvokeResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun invokeByTemplate() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val automationServiceAsync = client.automations() + + val automationInvokeResponseFuture = + automationServiceAsync.invokeByTemplate( + AutomationInvokeByTemplateParams.builder() + .templateId("templateId") + .automationInvokeParams( + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + ) + .build() + ) + + val automationInvokeResponse = automationInvokeResponseFuture.get() + automationInvokeResponse.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt new file mode 100644 index 00000000..ddb33187 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.brands.BrandCreateParams +import com.courier.api.models.brands.BrandListParams +import com.courier.api.models.brands.BrandSettings +import com.courier.api.models.brands.BrandSnippets +import com.courier.api.models.brands.BrandUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BrandServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandServiceAsync = client.brands() + + val brandFuture = + brandServiceAsync.create( + BrandCreateParams.builder() + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + + val brand = brandFuture.get() + brand.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandServiceAsync = client.brands() + + val brandFuture = brandServiceAsync.retrieve("brand_id") + + val brand = brandFuture.get() + brand.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandServiceAsync = client.brands() + + val brandFuture = + brandServiceAsync.update( + BrandUpdateParams.builder() + .brandId("brand_id") + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + + val brand = brandFuture.get() + brand.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandServiceAsync = client.brands() + + val brandsFuture = + brandServiceAsync.list(BrandListParams.builder().cursor("cursor").build()) + + val brands = brandsFuture.get() + brands.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandServiceAsync = client.brands() + + val future = brandServiceAsync.delete("brand_id") + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt new file mode 100644 index 00000000..0dad4e99 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt @@ -0,0 +1,438 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.bulk.BulkAddUsersParams +import com.courier.api.models.bulk.BulkCreateJobParams +import com.courier.api.models.bulk.BulkListUsersParams +import com.courier.api.models.bulk.InboundBulkMessage +import com.courier.api.models.bulk.InboundBulkMessageUser +import com.courier.api.models.bulk.UserRecipient +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.Utm +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun addUsers() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkServiceAsync = client.bulk() + + val future = + bulkServiceAsync.addUsers( + BulkAddUsersParams.builder() + .jobId("job_id") + .addUser( + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun createJob() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkServiceAsync = client.bulk() + + val responseFuture = + bulkServiceAsync.createJob( + BulkCreateJobParams.builder() + .message( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to + "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun listUsers() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkServiceAsync = client.bulk() + + val responseFuture = + bulkServiceAsync.listUsers( + BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveJob() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkServiceAsync = client.bulk() + + val responseFuture = bulkServiceAsync.retrieveJob("job_id") + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun runJob() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkServiceAsync = client.bulk() + + val future = bulkServiceAsync.runJob("job_id") + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt new file mode 100644 index 00000000..ce7e1ac1 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.inbound.InboundTrackEventParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InboundServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun trackEvent() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboundServiceAsync = client.inbound() + + val responseFuture = + inboundServiceAsync.trackEvent( + InboundTrackEventParams.builder() + .event("New Order Placed") + .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") + .properties( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + .type(InboundTrackEventParams.Type.TRACK) + .userId("1234") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt new file mode 100644 index 00000000..a0bdfdab --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListUpdateParams +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ListServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.lists() + + val listFuture = listServiceAsync.retrieve("list_id") + + val list = listFuture.get() + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.lists() + + val listFuture = + listServiceAsync.update( + ListUpdateParams.builder() + .listId("list_id") + .name("name") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + + val list = listFuture.get() + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.lists() + + val listsFuture = + listServiceAsync.list( + ListListParams.builder().cursor("cursor").pattern("pattern").build() + ) + + val lists = listsFuture.get() + lists.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.lists() + + val future = listServiceAsync.delete("list_id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun restore() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.lists() + + val future = listServiceAsync.restore("list_id") + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt new file mode 100644 index 00000000..52f3d5e0 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.messages.MessageHistoryParams +import com.courier.api.models.messages.MessageListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MessageServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageServiceAsync = client.messages() + + val messageFuture = messageServiceAsync.retrieve("message_id") + + val message = messageFuture.get() + message.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageServiceAsync = client.messages() + + val messagesFuture = + messageServiceAsync.list( + MessageListParams.builder() + .archived(true) + .cursor("cursor") + .enqueuedAfter("enqueued_after") + .event("event") + .list("list") + .messageId("messageId") + .notification("notification") + .addProvider("string") + .recipient("recipient") + .addStatus("string") + .addTag("string") + .tags("tags") + .tenantId("tenant_id") + .traceId("traceId") + .build() + ) + + val messages = messagesFuture.get() + messages.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun cancel() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageServiceAsync = client.messages() + + val messageDetailsFuture = messageServiceAsync.cancel("message_id") + + val messageDetails = messageDetailsFuture.get() + messageDetails.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun getContent() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageServiceAsync = client.messages() + + val responseFuture = messageServiceAsync.getContent("message_id") + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun history() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageServiceAsync = client.messages() + + val responseFuture = + messageServiceAsync.history( + MessageHistoryParams.builder().messageId("message_id").type("type").build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt new file mode 100644 index 00000000..e01bd772 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.notifications.NotificationListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class NotificationServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val notificationServiceAsync = client.notifications() + + val notificationsFuture = + notificationServiceAsync.list( + NotificationListParams.builder().cursor("cursor").notes(true).build() + ) + + val notifications = notificationsFuture.get() + notifications.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveContent() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val notificationServiceAsync = client.notifications() + + val notificationGetContentFuture = notificationServiceAsync.retrieveContent("id") + + val notificationGetContent = notificationGetContentFuture.get() + notificationGetContent.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt new file mode 100644 index 00000000..4a25544b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt @@ -0,0 +1,127 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.profiles.ProfileCreateParams +import com.courier.api.models.profiles.ProfileReplaceParams +import com.courier.api.models.profiles.ProfileUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ProfileServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileServiceAsync = client.profiles() + + val profileFuture = + profileServiceAsync.create( + ProfileCreateParams.builder() + .userId("user_id") + .profile( + ProfileCreateParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val profile = profileFuture.get() + profile.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileServiceAsync = client.profiles() + + val profileFuture = profileServiceAsync.retrieve("user_id") + + val profile = profileFuture.get() + profile.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileServiceAsync = client.profiles() + + val future = + profileServiceAsync.update( + ProfileUpdateParams.builder() + .userId("user_id") + .addPatch( + ProfileUpdateParams.Patch.builder() + .op("op") + .path("path") + .value("value") + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileServiceAsync = client.profiles() + + val future = profileServiceAsync.delete("user_id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun replace() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileServiceAsync = client.profiles() + + val responseFuture = + profileServiceAsync.replace( + ProfileReplaceParams.builder() + .userId("user_id") + .profile( + ProfileReplaceParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt new file mode 100644 index 00000000..98b519d3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RequestServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun archive() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val requestServiceAsync = client.requests() + + val future = requestServiceAsync.archive("request_id") + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt new file mode 100644 index 00000000..5097f433 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.BaseMessageSendTo +import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode +import com.courier.api.models.send.Message +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.Utm +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SendServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun sendMessage() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val sendServiceAsync = client.send() + + val responseFuture = + sendServiceAsync.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt new file mode 100644 index 00000000..4bbb28f9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.tenants.DefaultPreferences +import com.courier.api.models.tenants.TenantListParams +import com.courier.api.models.tenants.TenantListUsersParams +import com.courier.api.models.tenants.TenantUpdateParams +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TenantServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.tenants() + + val tenantFuture = tenantServiceAsync.retrieve("tenant_id") + + val tenant = tenantFuture.get() + tenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.tenants() + + val tenantFuture = + tenantServiceAsync.update( + TenantUpdateParams.builder() + .tenantId("tenant_id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + TenantUpdateParams.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + TenantUpdateParams.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val tenant = tenantFuture.get() + tenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.tenants() + + val tenantsFuture = + tenantServiceAsync.list( + TenantListParams.builder() + .cursor("cursor") + .limit(0L) + .parentTenantId("parent_tenant_id") + .build() + ) + + val tenants = tenantsFuture.get() + tenants.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.tenants() + + val future = tenantServiceAsync.delete("tenant_id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun listUsers() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.tenants() + + val responseFuture = + tenantServiceAsync.listUsers( + TenantListUsersParams.builder() + .tenantId("tenant_id") + .cursor("cursor") + .limit(0L) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt new file mode 100644 index 00000000..2f131cfa --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.translations.TranslationRetrieveParams +import com.courier.api.models.translations.TranslationUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TranslationServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val translationServiceAsync = client.translations() + + val translationFuture = + translationServiceAsync.retrieve( + TranslationRetrieveParams.builder().domain("domain").locale("locale").build() + ) + + val translation = translationFuture.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val translationServiceAsync = client.translations() + + val future = + translationServiceAsync.update( + TranslationUpdateParams.builder() + .domain("domain") + .locale("locale") + .body("body") + .build() + ) + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt new file mode 100644 index 00000000..ac98bbfd --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt @@ -0,0 +1,278 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.lists + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.PutSubscriptionsRecipient +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.lists.subscriptions.SubscriptionAddParams +import com.courier.api.models.lists.subscriptions.SubscriptionListParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams +import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SubscriptionServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionServiceAsync = client.lists().subscriptions() + + val subscriptionsFuture = + subscriptionServiceAsync.list( + SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() + ) + + val subscriptions = subscriptionsFuture.get() + subscriptions.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun add() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionServiceAsync = client.lists().subscriptions() + + val future = + subscriptionServiceAsync.add( + SubscriptionAddParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun subscribe() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionServiceAsync = client.lists().subscriptions() + + val future = + subscriptionServiceAsync.subscribe( + SubscriptionSubscribeParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun subscribeUser() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionServiceAsync = client.lists().subscriptions() + + val future = + subscriptionServiceAsync.subscribeUser( + SubscriptionSubscribeUserParams.builder() + .listId("list_id") + .userId("user_id") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun unsubscribeUser() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionServiceAsync = client.lists().subscriptions() + + val future = + subscriptionServiceAsync.unsubscribeUser( + SubscriptionUnsubscribeUserParams.builder() + .listId("list_id") + .userId("user_id") + .build() + ) + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt new file mode 100644 index 00000000..1286a01d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.notifications + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.notifications.checks.BaseCheck +import com.courier.api.models.notifications.checks.CheckDeleteParams +import com.courier.api.models.notifications.checks.CheckListParams +import com.courier.api.models.notifications.checks.CheckUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CheckServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val checkServiceAsync = client.notifications().checks() + + val checkFuture = + checkServiceAsync.update( + CheckUpdateParams.builder() + .id("id") + .submissionId("submissionId") + .addCheck( + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + ) + .build() + ) + + val check = checkFuture.get() + check.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val checkServiceAsync = client.notifications().checks() + + val checksFuture = + checkServiceAsync.list( + CheckListParams.builder().id("id").submissionId("submissionId").build() + ) + + val checks = checksFuture.get() + checks.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val checkServiceAsync = client.notifications().checks() + + val future = + checkServiceAsync.delete( + CheckDeleteParams.builder().id("id").submissionId("submissionId").build() + ) + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt new file mode 100644 index 00000000..b09a22cf --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.notifications + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DraftServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveContent() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val draftServiceAsync = client.notifications().draft() + + val notificationGetContentFuture = draftServiceAsync.retrieveContent("id") + + val notificationGetContent = notificationGetContentFuture.get() + notificationGetContent.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt new file mode 100644 index 00000000..a69c75b1 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.profiles + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.profiles.lists.ListRetrieveParams +import com.courier.api.models.profiles.lists.ListSubscribeParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ListServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.profiles().lists() + + val listFuture = + listServiceAsync.retrieve( + ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() + ) + + val list = listFuture.get() + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.profiles().lists() + + val listFuture = listServiceAsync.delete("user_id") + + val list = listFuture.get() + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun subscribe() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listServiceAsync = client.profiles().lists() + + val responseFuture = + listServiceAsync.subscribe( + ListSubscribeParams.builder() + .userId("user_id") + .addList( + ListSubscribeParams.List.builder() + .listId("listId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt new file mode 100644 index 00000000..178e844b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants.defaultpreferences + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams +import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ItemServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val itemServiceAsync = client.tenants().defaultPreferences().items() + + val future = + itemServiceAsync.update( + ItemUpdateParams.builder() + .tenantId("tenant_id") + .topicId("topic_id") + .subscriptionTopicNew( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .hasCustomRouting(true) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val itemServiceAsync = client.tenants().defaultPreferences().items() + + val future = + itemServiceAsync.delete( + ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() + ) + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt new file mode 100644 index 00000000..ae2b6af5 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.users.preferences.PreferenceRetrieveParams +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams +import com.courier.api.models.users.preferences.PreferenceStatus +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PreferenceServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val preferenceServiceAsync = client.users().preferences() + + val preferenceFuture = + preferenceServiceAsync.retrieve( + PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() + ) + + val preference = preferenceFuture.get() + preference.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTopic() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val preferenceServiceAsync = client.users().preferences() + + val responseFuture = + preferenceServiceAsync.retrieveTopic( + PreferenceRetrieveTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun updateOrCreateTopic() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val preferenceServiceAsync = client.users().preferences() + + val responseFuture = + preferenceServiceAsync.updateOrCreateTopic( + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .addCustomRouting(ChannelClassification.EMAIL) + .hasCustomRouting(true) + .build() + ) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt new file mode 100644 index 00000000..aeacc695 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.users.tenants.TenantAddMultipleParams +import com.courier.api.models.users.tenants.TenantAddSingleParams +import com.courier.api.models.users.tenants.TenantAssociation +import com.courier.api.models.users.tenants.TenantListParams +import com.courier.api.models.users.tenants.TenantRemoveSingleParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TenantServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.users().tenants() + + val tenantsFuture = + tenantServiceAsync.list( + TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() + ) + + val tenants = tenantsFuture.get() + tenants.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun addMultiple() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.users().tenants() + + val future = + tenantServiceAsync.addMultiple( + TenantAddMultipleParams.builder() + .userId("user_id") + .addTenant( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun addSingle() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.users().tenants() + + val future = + tenantServiceAsync.addSingle( + TenantAddSingleParams.builder() + .userId("user_id") + .tenantId("tenant_id") + .profile( + TenantAddSingleParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun removeAll() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.users().tenants() + + val future = tenantServiceAsync.removeAll("user_id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun removeSingle() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantServiceAsync = client.users().tenants() + + val future = + tenantServiceAsync.removeSingle( + TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() + ) + + val response = future.get() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt new file mode 100644 index 00000000..a200b7cb --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.users + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.core.JsonValue +import com.courier.api.models.users.tokens.TokenAddSingleParams +import com.courier.api.models.users.tokens.TokenDeleteParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenUpdateParams +import com.courier.api.models.users.tokens.UserToken +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TokenServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val future = + tokenServiceAsync.update( + TokenUpdateParams.builder() + .userId("user_id") + .token("token") + .addPatch( + TokenUpdateParams.Patch.builder() + .op("op") + .path("path") + .value("value") + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val userTokensFuture = tokenServiceAsync.list("user_id") + + val userTokens = userTokensFuture.get() + userTokens.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val future = + tokenServiceAsync.delete( + TokenDeleteParams.builder().userId("user_id").token("token").build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun addMultiple() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val future = tokenServiceAsync.addMultiple("user_id") + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun addSingle() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val future = + tokenServiceAsync.addSingle( + TokenAddSingleParams.builder() + .userId("user_id") + .pathToken("token") + .userToken( + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + ) + .build() + ) + + val response = future.get() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSingle() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val responseFuture = + tokenServiceAsync.retrieveSingle( + TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt new file mode 100644 index 00000000..7495c8a9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.audiences.AudienceListMembersParams +import com.courier.api.models.audiences.AudienceListParams +import com.courier.api.models.audiences.AudienceUpdateParams +import com.courier.api.models.audiences.Filter +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AudienceServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceService = client.audiences() + + val audience = audienceService.retrieve("audience_id") + + audience.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceService = client.audiences() + + val audience = + audienceService.update( + AudienceUpdateParams.builder() + .audienceId("audience_id") + .description("description") + .filter( + Filter.UnionMember0.builder() + .operator(Filter.UnionMember0.Operator.ENDS_WITH) + .path("path") + .value("value") + .build() + ) + .name("name") + .build() + ) + + audience.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceService = client.audiences() + + val audiences = audienceService.list(AudienceListParams.builder().cursor("cursor").build()) + + audiences.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceService = client.audiences() + + audienceService.delete("audience_id") + } + + @Disabled("Prism tests are disabled") + @Test + fun listMembers() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val audienceService = client.audiences() + + val response = + audienceService.listMembers( + AudienceListMembersParams.builder() + .audienceId("audience_id") + .cursor("cursor") + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt new file mode 100644 index 00000000..999fc16b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.auditevents.AuditEventListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AuditEventServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val auditEventService = client.auditEvents() + + val auditEvent = auditEventService.retrieve("audit-event-id") + + auditEvent.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val auditEventService = client.auditEvents() + + val auditEvents = + auditEventService.list(AuditEventListParams.builder().cursor("cursor").build()) + + auditEvents.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt new file mode 100644 index 00000000..7b8cf586 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.auth.AuthIssueTokenParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AuthServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun issueToken() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val authService = client.auth() + + val response = + authService.issueToken( + AuthIssueTokenParams.builder() + .expiresIn("expires_in") + .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt new file mode 100644 index 00000000..a0098e6a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.automations.AutomationInvokeAdHocParams +import com.courier.api.models.automations.AutomationInvokeByTemplateParams +import com.courier.api.models.automations.invoke.AutomationInvokeParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AutomationServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun invokeAdHoc() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val automationService = client.automations() + + val automationInvokeResponse = + automationService.invokeAdHoc( + AutomationInvokeAdHocParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .automation( + AutomationInvokeAdHocParams.Automation.builder() + .addStep( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .builder() + .if_("if") + .ref("ref") + .action( + AutomationInvokeAdHocParams.Automation.Step + .AutomationAddToDigestStep + .Action + .ADD_TO_DIGEST + ) + .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") + .build() + ) + .cancelationToken("cancelation_token") + .build() + ) + .build() + ) + + automationInvokeResponse.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun invokeByTemplate() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val automationService = client.automations() + + val automationInvokeResponse = + automationService.invokeByTemplate( + AutomationInvokeByTemplateParams.builder() + .templateId("templateId") + .automationInvokeParams( + AutomationInvokeParams.builder() + .brand("brand") + .data( + AutomationInvokeParams.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .template("template") + .build() + ) + .build() + ) + + automationInvokeResponse.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt new file mode 100644 index 00000000..739ae31c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.brands.BrandCreateParams +import com.courier.api.models.brands.BrandListParams +import com.courier.api.models.brands.BrandSettings +import com.courier.api.models.brands.BrandSnippets +import com.courier.api.models.brands.BrandUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BrandServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandService = client.brands() + + val brand = + brandService.create( + BrandCreateParams.builder() + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .id("id") + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + + brand.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandService = client.brands() + + val brand = brandService.retrieve("brand_id") + + brand.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandService = client.brands() + + val brand = + brandService.update( + BrandUpdateParams.builder() + .brandId("brand_id") + .name("name") + .settings( + BrandSettings.builder() + .colors( + BrandSettings.Colors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + ) + .email( + BrandSettings.Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + ) + .inapp(JsonValue.from(mapOf())) + .build() + ) + .snippets( + BrandSnippets.builder() + .addItem( + BrandSnippets.Item.builder() + .format(BrandSnippets.Item.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + ) + .build() + ) + .build() + ) + + brand.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandService = client.brands() + + val brands = brandService.list(BrandListParams.builder().cursor("cursor").build()) + + brands.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val brandService = client.brands() + + brandService.delete("brand_id") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt new file mode 100644 index 00000000..4d065b1d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt @@ -0,0 +1,430 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.bulk.BulkAddUsersParams +import com.courier.api.models.bulk.BulkCreateJobParams +import com.courier.api.models.bulk.BulkListUsersParams +import com.courier.api.models.bulk.InboundBulkMessage +import com.courier.api.models.bulk.InboundBulkMessageUser +import com.courier.api.models.bulk.UserRecipient +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.Utm +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class BulkServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun addUsers() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkService = client.bulk() + + bulkService.addUsers( + BulkAddUsersParams.builder() + .jobId("job_id") + .addUser( + InboundBulkMessageUser.builder() + .data(JsonValue.from(mapOf())) + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .profile(JsonValue.from(mapOf())) + .recipient("recipient") + .to( + UserRecipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + UserRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + UserRecipient.Preferences.builder() + .notifications( + UserRecipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + UserRecipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun createJob() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkService = client.bulk() + + val response = + bulkService.createJob( + BulkCreateJobParams.builder() + .message( + InboundBulkMessage.builder() + .brand("brand") + .data( + InboundBulkMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .event("event") + .locale( + InboundBulkMessage.Locale.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .message( + InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to + mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay( + BaseMessage.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel + .RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to + "term", + ) + ), + "override" to + mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .template("template") + .build() + ) + .override(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun listUsers() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkService = client.bulk() + + val response = + bulkService.listUsers( + BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveJob() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkService = client.bulk() + + val response = bulkService.retrieveJob("job_id") + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun runJob() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val bulkService = client.bulk() + + bulkService.runJob("job_id") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt new file mode 100644 index 00000000..ef1daaa3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.inbound.InboundTrackEventParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InboundServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun trackEvent() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboundService = client.inbound() + + val response = + inboundService.trackEvent( + InboundTrackEventParams.builder() + .event("New Order Placed") + .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") + .properties( + InboundTrackEventParams.Properties.builder() + .putAdditionalProperty("order_id", JsonValue.from("bar")) + .putAdditionalProperty("total_orders", JsonValue.from("bar")) + .putAdditionalProperty("last_order_id", JsonValue.from("bar")) + .build() + ) + .type(InboundTrackEventParams.Type.TRACK) + .userId("1234") + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt new file mode 100644 index 00000000..3a3ac703 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListUpdateParams +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ListServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.lists() + + val list = listService.retrieve("list_id") + + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.lists() + + val list = + listService.update( + ListUpdateParams.builder() + .listId("list_id") + .name("name") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.lists() + + val lists = + listService.list(ListListParams.builder().cursor("cursor").pattern("pattern").build()) + + lists.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.lists() + + listService.delete("list_id") + } + + @Disabled("Prism tests are disabled") + @Test + fun restore() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.lists() + + listService.restore("list_id") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt new file mode 100644 index 00000000..bfa54e0b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.messages.MessageHistoryParams +import com.courier.api.models.messages.MessageListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MessageServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageService = client.messages() + + val message = messageService.retrieve("message_id") + + message.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageService = client.messages() + + val messages = + messageService.list( + MessageListParams.builder() + .archived(true) + .cursor("cursor") + .enqueuedAfter("enqueued_after") + .event("event") + .list("list") + .messageId("messageId") + .notification("notification") + .addProvider("string") + .recipient("recipient") + .addStatus("string") + .addTag("string") + .tags("tags") + .tenantId("tenant_id") + .traceId("traceId") + .build() + ) + + messages.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun cancel() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageService = client.messages() + + val messageDetails = messageService.cancel("message_id") + + messageDetails.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun getContent() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageService = client.messages() + + val response = messageService.getContent("message_id") + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun history() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val messageService = client.messages() + + val response = + messageService.history( + MessageHistoryParams.builder().messageId("message_id").type("type").build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt new file mode 100644 index 00000000..4fc3cacd --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.notifications.NotificationListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class NotificationServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val notificationService = client.notifications() + + val notifications = + notificationService.list( + NotificationListParams.builder().cursor("cursor").notes(true).build() + ) + + notifications.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveContent() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val notificationService = client.notifications() + + val notificationGetContent = notificationService.retrieveContent("id") + + notificationGetContent.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt new file mode 100644 index 00000000..e3af1883 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt @@ -0,0 +1,115 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.profiles.ProfileCreateParams +import com.courier.api.models.profiles.ProfileReplaceParams +import com.courier.api.models.profiles.ProfileUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ProfileServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileService = client.profiles() + + val profile = + profileService.create( + ProfileCreateParams.builder() + .userId("user_id") + .profile( + ProfileCreateParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + profile.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileService = client.profiles() + + val profile = profileService.retrieve("user_id") + + profile.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileService = client.profiles() + + profileService.update( + ProfileUpdateParams.builder() + .userId("user_id") + .addPatch( + ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileService = client.profiles() + + profileService.delete("user_id") + } + + @Disabled("Prism tests are disabled") + @Test + fun replace() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val profileService = client.profiles() + + val response = + profileService.replace( + ProfileReplaceParams.builder() + .userId("user_id") + .profile( + ProfileReplaceParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt new file mode 100644 index 00000000..f93af90b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class RequestServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun archive() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val requestService = client.requests() + + requestService.archive("request_id") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt new file mode 100644 index 00000000..0dc3c6e8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -0,0 +1,243 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.BaseMessageSendTo +import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode +import com.courier.api.models.send.Message +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.Utm +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SendServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun sendMessage() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val sendService = client.send() + + val response = + sendService.sendMessage( + SendSendMessageParams.builder() + .message( + Message.ContentMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Config + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from("bar"), + ) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel + .Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to + "campaign", + "content" to + "content", + "medium" to + "medium", + "source" to + "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + BaseMessageSendTo.To.AudienceRecipient.builder() + .audienceId("audience_id") + .data( + BaseMessageSendTo.To.AudienceRecipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .addFilter( + BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + .operator( + BaseMessageSendTo.To.AudienceRecipient.Filter + .Operator + .MEMBER_OF + ) + .path( + BaseMessageSendTo.To.AudienceRecipient.Filter.Path + .ACCOUNT_ID + ) + .value("value") + .build() + ) + .build() + ) + .content( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt new file mode 100644 index 00000000..369706d9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.tenants.DefaultPreferences +import com.courier.api.models.tenants.TenantListParams +import com.courier.api.models.tenants.TenantListUsersParams +import com.courier.api.models.tenants.TenantUpdateParams +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TenantServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.tenants() + + val tenant = tenantService.retrieve("tenant_id") + + tenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.tenants() + + val tenant = + tenantService.update( + TenantUpdateParams.builder() + .tenantId("tenant_id") + .name("name") + .brandId("brand_id") + .defaultPreferences( + DefaultPreferences.builder() + .addItem( + DefaultPreferences.Item.builder() + .status(SubscriptionTopicNew.Status.OPTED_OUT) + .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) + .hasCustomRouting(true) + .id("id") + .build() + ) + .build() + ) + .parentTenantId("parent_tenant_id") + .properties( + TenantUpdateParams.Properties.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .userProfile( + TenantUpdateParams.UserProfile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + + tenant.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.tenants() + + val tenants = + tenantService.list( + TenantListParams.builder() + .cursor("cursor") + .limit(0L) + .parentTenantId("parent_tenant_id") + .build() + ) + + tenants.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.tenants() + + tenantService.delete("tenant_id") + } + + @Disabled("Prism tests are disabled") + @Test + fun listUsers() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.tenants() + + val response = + tenantService.listUsers( + TenantListUsersParams.builder() + .tenantId("tenant_id") + .cursor("cursor") + .limit(0L) + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt new file mode 100644 index 00000000..a66eee8a --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.translations.TranslationRetrieveParams +import com.courier.api.models.translations.TranslationUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TranslationServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val translationService = client.translations() + + translationService.retrieve( + TranslationRetrieveParams.builder().domain("domain").locale("locale").build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val translationService = client.translations() + + translationService.update( + TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt new file mode 100644 index 00000000..b83e172c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.lists + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.PutSubscriptionsRecipient +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.lists.subscriptions.SubscriptionAddParams +import com.courier.api.models.lists.subscriptions.SubscriptionListParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams +import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams +import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SubscriptionServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionService = client.lists().subscriptions() + + val subscriptions = + subscriptionService.list( + SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() + ) + + subscriptions.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun add() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionService = client.lists().subscriptions() + + subscriptionService.add( + SubscriptionAddParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun subscribe() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionService = client.lists().subscriptions() + + subscriptionService.subscribe( + SubscriptionSubscribeParams.builder() + .listId("list_id") + .addRecipient( + PutSubscriptionsRecipient.builder() + .recipientId("recipientId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun subscribeUser() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionService = client.lists().subscriptions() + + subscriptionService.subscribeUser( + SubscriptionSubscribeUserParams.builder() + .listId("list_id") + .userId("user_id") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun unsubscribeUser() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val subscriptionService = client.lists().subscriptions() + + subscriptionService.unsubscribeUser( + SubscriptionUnsubscribeUserParams.builder().listId("list_id").userId("user_id").build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt new file mode 100644 index 00000000..5fc62ebd --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.notifications + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.notifications.checks.BaseCheck +import com.courier.api.models.notifications.checks.CheckDeleteParams +import com.courier.api.models.notifications.checks.CheckListParams +import com.courier.api.models.notifications.checks.CheckUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CheckServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val checkService = client.notifications().checks() + + val check = + checkService.update( + CheckUpdateParams.builder() + .id("id") + .submissionId("submissionId") + .addCheck( + BaseCheck.builder() + .id("id") + .status(BaseCheck.Status.RESOLVED) + .type(BaseCheck.Type.CUSTOM) + .build() + ) + .build() + ) + + check.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val checkService = client.notifications().checks() + + val checks = + checkService.list( + CheckListParams.builder().id("id").submissionId("submissionId").build() + ) + + checks.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val checkService = client.notifications().checks() + + checkService.delete( + CheckDeleteParams.builder().id("id").submissionId("submissionId").build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt new file mode 100644 index 00000000..a18eff3d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.notifications + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class DraftServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieveContent() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val draftService = client.notifications().draft() + + val notificationGetContent = draftService.retrieveContent("id") + + notificationGetContent.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt new file mode 100644 index 00000000..c461997e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.profiles + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.lists.subscriptions.RecipientPreferences +import com.courier.api.models.profiles.lists.ListRetrieveParams +import com.courier.api.models.profiles.lists.ListSubscribeParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ListServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.profiles().lists() + + val list = + listService.retrieve( + ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() + ) + + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.profiles().lists() + + val list = listService.delete("user_id") + + list.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun subscribe() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val listService = client.profiles().lists() + + val response = + listService.subscribe( + ListSubscribeParams.builder() + .userId("user_id") + .addList( + ListSubscribeParams.List.builder() + .listId("listId") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt new file mode 100644 index 00000000..61393e18 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants.defaultpreferences + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams +import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams +import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ItemServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val itemService = client.tenants().defaultPreferences().items() + + itemService.update( + ItemUpdateParams.builder() + .tenantId("tenant_id") + .topicId("topic_id") + .subscriptionTopicNew( + SubscriptionTopicNew.builder() + .status(SubscriptionTopicNew.Status.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .hasCustomRouting(true) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val itemService = client.tenants().defaultPreferences().items() + + itemService.delete( + ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt new file mode 100644 index 00000000..6b210735 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.users.preferences.PreferenceRetrieveParams +import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams +import com.courier.api.models.users.preferences.PreferenceStatus +import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class PreferenceServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val preferenceService = client.users().preferences() + + val preference = + preferenceService.retrieve( + PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() + ) + + preference.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveTopic() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val preferenceService = client.users().preferences() + + val response = + preferenceService.retrieveTopic( + PreferenceRetrieveTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun updateOrCreateTopic() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val preferenceService = client.users().preferences() + + val response = + preferenceService.updateOrCreateTopic( + PreferenceUpdateOrCreateTopicParams.builder() + .userId("user_id") + .topicId("topic_id") + .tenantId("tenant_id") + .topic( + PreferenceUpdateOrCreateTopicParams.Topic.builder() + .status(PreferenceStatus.OPTED_IN) + .addCustomRouting(ChannelClassification.INBOX) + .addCustomRouting(ChannelClassification.EMAIL) + .hasCustomRouting(true) + .build() + ) + .build() + ) + + response.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt new file mode 100644 index 00000000..508c58be --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt @@ -0,0 +1,117 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.users.tenants.TenantAddMultipleParams +import com.courier.api.models.users.tenants.TenantAddSingleParams +import com.courier.api.models.users.tenants.TenantAssociation +import com.courier.api.models.users.tenants.TenantListParams +import com.courier.api.models.users.tenants.TenantRemoveSingleParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TenantServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.users().tenants() + + val tenants = + tenantService.list( + TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() + ) + + tenants.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun addMultiple() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.users().tenants() + + tenantService.addMultiple( + TenantAddMultipleParams.builder() + .userId("user_id") + .addTenant( + TenantAssociation.builder() + .tenantId("tenant_id") + .profile( + TenantAssociation.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .type(TenantAssociation.Type.USER) + .userId("user_id") + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun addSingle() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.users().tenants() + + tenantService.addSingle( + TenantAddSingleParams.builder() + .userId("user_id") + .tenantId("tenant_id") + .profile( + TenantAddSingleParams.Profile.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun removeAll() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.users().tenants() + + tenantService.removeAll("user_id") + } + + @Disabled("Prism tests are disabled") + @Test + fun removeSingle() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tenantService = client.users().tenants() + + tenantService.removeSingle( + TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt new file mode 100644 index 00000000..b6781c61 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.users + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.models.users.tokens.TokenAddSingleParams +import com.courier.api.models.users.tokens.TokenDeleteParams +import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenUpdateParams +import com.courier.api.models.users.tokens.UserToken +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TokenServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun update() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + tokenService.update( + TokenUpdateParams.builder() + .userId("user_id") + .token("token") + .addPatch( + TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + val userTokens = tokenService.list("user_id") + + userTokens.forEach { it.validate() } + } + + @Disabled("Prism tests are disabled") + @Test + fun delete() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + tokenService.delete(TokenDeleteParams.builder().userId("user_id").token("token").build()) + } + + @Disabled("Prism tests are disabled") + @Test + fun addMultiple() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + tokenService.addMultiple("user_id") + } + + @Disabled("Prism tests are disabled") + @Test + fun addSingle() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + tokenService.addSingle( + TokenAddSingleParams.builder() + .userId("user_id") + .pathToken("token") + .userToken( + UserToken.builder() + .providerKey(UserToken.ProviderKey.FIREBASE_FCM) + .token("token") + .device( + UserToken.Device.builder() + .adId("ad_id") + .appId("app_id") + .deviceId("device_id") + .manufacturer("manufacturer") + .model("model") + .platform("platform") + .build() + ) + .expiryDate("string") + .properties(JsonValue.from(mapOf())) + .tracking( + UserToken.Tracking.builder() + .ip("ip") + .lat("lat") + .long_("long") + .osVersion("os_version") + .build() + ) + .build() + ) + .build() + ) + } + + @Disabled("Prism tests are disabled") + @Test + fun retrieveSingle() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + val response = + tokenService.retrieveSingle( + TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() + ) + + response.validate() + } +} diff --git a/courier-java-example/build.gradle.kts b/courier-java-example/build.gradle.kts new file mode 100644 index 00000000..2d4f66bd --- /dev/null +++ b/courier-java-example/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("courier.java") + application +} + +repositories { + mavenCentral() +} + +dependencies { + implementation(project(":courier-java")) +} + +tasks.withType().configureEach { + // Allow using more modern APIs, like `List.of` and `Map.of`, in examples. + options.release.set(9) +} + +application { + // Use `./gradlew :courier-java-example:run` to run `Main` + // Use `./gradlew :courier-java-example:run -Pexample=Something` to run `SomethingExample` + mainClass = "com.courier.api.example.${ + if (project.hasProperty("example")) + "${project.property("example")}Example" + else + "Main" + }" +} diff --git a/courier-java-lib/.keep b/courier-java-lib/.keep new file mode 100644 index 00000000..5e2c99fd --- /dev/null +++ b/courier-java-lib/.keep @@ -0,0 +1,4 @@ +File generated from our OpenAPI spec by Stainless. + +This directory can be used to store custom files to expand the SDK. +It is ignored by Stainless code generation and its content (other than this keep file) won't be touched. \ No newline at end of file diff --git a/courier-java-proguard-test/build.gradle.kts b/courier-java-proguard-test/build.gradle.kts new file mode 100644 index 00000000..68d7f8bc --- /dev/null +++ b/courier-java-proguard-test/build.gradle.kts @@ -0,0 +1,101 @@ +plugins { + id("courier.kotlin") + id("com.gradleup.shadow") version "8.3.8" +} + +buildscript { + repositories { + google() + } + + dependencies { + classpath("com.guardsquare:proguard-gradle:7.4.2") + classpath("com.android.tools:r8:8.3.37") + } +} + +dependencies { + testImplementation(project(":courier-java")) + testImplementation(kotlin("test")) + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") + testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") +} + +tasks.shadowJar { + from(sourceSets.test.get().output) + configurations = listOf(project.configurations.testRuntimeClasspath.get()) +} + +val proguardJarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-proguard.jar" +val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("ProGuard") + + injars(tasks.shadowJar) + outjars(proguardJarPath) + printmapping("${layout.buildDirectory.get()}/proguard-mapping.txt") + + val javaHome = System.getProperty("java.home") + if (System.getProperty("java.version").startsWith("1.")) { + // Before Java 9, the runtime classes were packaged in a single jar file. + libraryjars("$javaHome/lib/rt.jar") + } else { + // As of Java 9, the runtime classes are packaged in modular jmod files. + libraryjars( + // Filters must be specified first, as a map. + mapOf("jarfilter" to "!**.jar", "filter" to "!module-info.class"), + "$javaHome/jmods/java.base.jmod" + ) + } + + configuration("./test.pro") + configuration("../courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro") +} + +val testProGuard by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(proguardJar) + notCompatibleWithConfigurationCache("ProGuard") + + mainClass.set("com.courier.api.proguard.ProGuardCompatibilityTest") + classpath = files(proguardJarPath) +} + +val r8JarPath = "${layout.buildDirectory.get()}/libs/${project.name}-${project.version}-r8.jar" +val r8Jar by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(tasks.shadowJar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.android.tools.r8.R8") + classpath = buildscript.configurations["classpath"] + + args = listOf( + "--release", + "--classfile", + "--output", r8JarPath, + "--lib", System.getProperty("java.home"), + "--pg-conf", "./test.pro", + "--pg-conf", "../courier-java-core/src/main/resources/META-INF/proguard/courier-java-core.pro", + "--pg-map-output", "${layout.buildDirectory.get()}/r8-mapping.txt", + tasks.shadowJar.get().archiveFile.get().asFile.absolutePath, + ) +} + +val testR8 by tasks.registering(JavaExec::class) { + group = "verification" + dependsOn(r8Jar) + notCompatibleWithConfigurationCache("R8") + + mainClass.set("com.courier.api.proguard.ProGuardCompatibilityTest") + classpath = files(r8JarPath) +} + +tasks.test { + dependsOn(testProGuard) + dependsOn(testR8) + // We defer to the tests run via the ProGuard JAR. + enabled = false +} diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt new file mode 100644 index 00000000..40930df0 --- /dev/null +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.proguard + +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.models.send.BaseMessage +import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode +import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.RoutingMethod +import com.courier.api.models.send.Utm +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.reflect.full.memberFunctions +import kotlin.reflect.jvm.javaMethod +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ProGuardCompatibilityTest { + + companion object { + + @JvmStatic + fun main(args: Array) { + // To debug that we're using the right JAR. + val jarPath = this::class.java.getProtectionDomain().codeSource.location + println("JAR being used: $jarPath") + + // We have to manually run the test methods instead of using the JUnit runner because it + // seems impossible to get working with R8. + val test = ProGuardCompatibilityTest() + test::class + .memberFunctions + .asSequence() + .filter { function -> + function.javaMethod?.isAnnotationPresent(Test::class.java) == true + } + .forEach { it.call(test) } + } + } + + @Test + fun proguardRules() { + val rulesFile = + javaClass.classLoader.getResourceAsStream("META-INF/proguard/courier-java-core.pro") + + assertThat(rulesFile).isNotNull() + } + + @Test + fun client() { + val client = CourierOkHttpClient.builder().apiKey("My API Key").build() + + assertThat(client).isNotNull() + assertThat(client.send()).isNotNull() + assertThat(client.audiences()).isNotNull() + assertThat(client.auditEvents()).isNotNull() + assertThat(client.auth()).isNotNull() + assertThat(client.automations()).isNotNull() + assertThat(client.brands()).isNotNull() + assertThat(client.bulk()).isNotNull() + assertThat(client.inbound()).isNotNull() + assertThat(client.lists()).isNotNull() + assertThat(client.messages()).isNotNull() + assertThat(client.requests()).isNotNull() + assertThat(client.notifications()).isNotNull() + assertThat(client.profiles()).isNotNull() + assertThat(client.tenants()).isNotNull() + assertThat(client.translations()).isNotNull() + assertThat(client.users()).isNotNull() + } + + @Test + fun baseMessageRoundtrip() { + val jsonMapper = jsonMapper() + val baseMessage = + BaseMessage.builder() + .brandId("brand_id") + .channels( + BaseMessage.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .expiry( + BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() + ) + .metadata( + BaseMessage.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + BaseMessage.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + BaseMessage.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + BaseMessage.Routing.builder() + .addChannel( + BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() + .channel("channel") + .config( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Config + .builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .if_("if") + .method(RoutingMethod.ALL) + .providers( + BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .build() + ) + .method(RoutingMethod.ALL) + .build() + ) + .timeout( + BaseMessage.Timeout.builder() + .channel( + BaseMessage.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + BaseMessage.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .build() + + val roundtrippedBaseMessage = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseMessage), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseMessage).isEqualTo(baseMessage) + } + + @Test + fun contentRoundtrip() { + val jsonMapper = jsonMapper() + val content = + Content.ofElemental( + Content.ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + ) + + val roundtrippedContent = + jsonMapper.readValue(jsonMapper.writeValueAsString(content), jacksonTypeRef()) + + assertThat(roundtrippedContent).isEqualTo(content) + } + + @Test + fun routingMethodRoundtrip() { + val jsonMapper = jsonMapper() + val routingMethod = RoutingMethod.ALL + + val roundtrippedRoutingMethod = + jsonMapper.readValue( + jsonMapper.writeValueAsString(routingMethod), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRoutingMethod).isEqualTo(routingMethod) + } +} diff --git a/courier-java-proguard-test/test.pro b/courier-java-proguard-test/test.pro new file mode 100644 index 00000000..8e967398 --- /dev/null +++ b/courier-java-proguard-test/test.pro @@ -0,0 +1,9 @@ +# Specify the entrypoint where ProGuard starts to determine what's reachable. +-keep class com.courier.api.proguard.** { *; } + +# For the testing framework. +-keep class org.junit.** { *; } + +# Many warnings don't apply for our testing purposes. +-dontnote +-dontwarn \ No newline at end of file diff --git a/courier-java/build.gradle.kts b/courier-java/build.gradle.kts new file mode 100644 index 00000000..6196e5bd --- /dev/null +++ b/courier-java/build.gradle.kts @@ -0,0 +1,29 @@ +plugins { + id("courier.kotlin") + id("courier.publish") +} + +dependencies { + api(project(":courier-java-client-okhttp")) +} + +// Redefine `dokkaJavadoc` to: +// - Depend on the root project's task for merging the docs of all the projects +// - Forward that task's output to this task's output +tasks.named("dokkaJavadoc").configure { + actions.clear() + + val dokkaJavadocCollector = rootProject.tasks["dokkaJavadocCollector"] + dependsOn(dokkaJavadocCollector) + + val outputDirectory = project.layout.buildDirectory.dir("dokka/javadoc") + doLast { + copy { + from(dokkaJavadocCollector.outputs.files) + into(outputDirectory) + duplicatesStrategy = DuplicatesStrategy.INCLUDE + } + } + + outputs.dir(outputDirectory) +} diff --git a/gradle.properties b/gradle.properties index e69de29b..6680f9ce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -0,0 +1,18 @@ +org.gradle.caching=true +org.gradle.configuration-cache=true +org.gradle.parallel=true +org.gradle.daemon=false +# These options improve our compilation and test performance. They are inherited by the Kotlin daemon. +org.gradle.jvmargs=\ + -Xms2g \ + -Xmx8g \ + -XX:+UseParallelGC \ + -XX:InitialCodeCacheSize=256m \ + -XX:ReservedCodeCacheSize=1G \ + -XX:MetaspaceSize=512m \ + -XX:MaxMetaspaceSize=2G \ + -XX:TieredStopAtLevel=1 \ + -XX:GCTimeRatio=4 \ + -XX:CICompilerCount=4 \ + -XX:+OptimizeStringConcat \ + -XX:+UseStringDeduplication diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index e6441136f3d4ba8a0da8d277868979cfbc8ad796..a4b76b9530d66f5e68d973ea569d8e19de379189 100644 GIT binary patch delta 12612 zcmY+pRa6|n(lttO3GVLh?(Xh3xVuAe26uONcL=V5;I6?T_zdn2`Oi5I_gl9gx~lft zRjVKRp?B~8Wyrx5$mS3|py!Njy{0Wt4i%@s8v88pK z6fPNA45)|*9+*w5kcg$o)}2g}%JfXe6l9ig4T8ia3Hlw#3f^fAKW63%<~GZJd-0YA z9YjleCs~#Y?V+`#nr+49hhsr$K$k!lg}AZDw@>2j=f7t~5IW6#K|lAX7|^N}lJ)I!km`nrwx> z))1Es16__aXGVzQM0EC8xH+O!nqTFBg9Ci{NwRK*CP<6s`Gq(~#lqb(zOlh6ZDBK* zr$|NDj^s6VanrKa+QC;5>twePaexqRI%RO~OY075y?NN90I|f^(P# zF=b>fZ73b5JzD`#GC3lTQ_B3lMeBWgQUGYnFw*HQC}^z{$6G4j(n4y-pRxPT(d2Wgb%vCH(?+t&Pj z)QM`zc`U`+<~D+9E{4Uj2kc#*6eZMU$4Oj6QMfA^K!rbl`iBix=2sPrs7j@aqIrE zTaZJ2M09>rp$mgyUZ!r2$UK{+DGqgl`n;*qFF~M(r#eh`T{MO?2&j?xgr8FU$u3-` zhRDc_I23LL4)K&xg$^&l-W=!Jp-P(_Ie07q>Je;QLxi8LaEc%;WIacJD_T69egF?7 z;I_Sg_!+qrur8$Hq4grigaiVF>U7uWJ@Hkd&%kmFnQN-P^fq0gB1|uRt!U#X;DnlV zo?yHWTw7g5B;#xxY`adhi4yZn@f(7-Xa(J6S=#d@&rlFw!qfvholE>MEb|VWn^g}G zMSrK&zQ^vDId&ojL!{%{o7?s{7;{+u%L{|tar(gp?Uxq3p?xAysB>0E$eG#$tvkk9 z2Q2gEP17{U6@UD*v({5MP-CTZfvWMItVjb4c;i~WLq&{?Q1(koX&vt7+$z}10{^Id z{KDjGi0JpD7@;~odF__0m|p;5rIrHidOP9^mwKe#-&JX-X@acc)06G{LO1Wu)#gvZ za~y9(fhA%UwkDOVU1LBJ`0ROE z4&)dJKK%mG@+CIm?+wt9f~@xIMr8}UH*K1j| z0pppo{7gv3v{URwxVMeg>Ps!L5IKxm zjac2egjgb0vH5i75$s|sY_RYec#>faqJk|AGgV;v=^%BM(^p{p;(^SVt-88G9f!q; z>p}9E4^f0=01S2pQBE4}9YqE%TV)*hlU^8k9{&=K76+*Ax^r=AkBb%OCP^P2nm0Ri z;D-|Zk?gGeU<12ti2CnPVNA(Pb)02+r|&yTWW-OJO7 zNLb0pps6aN?A~NJp5kj{{IOlf!5KWMleV@-hYLift)D>-7K+tgs=7Ake}oBnIy-y1 z(Hn@Hjw=_(x>dO5ysQsrnE%A*bk0K<-j{1Yqz@#n#jOL^AzCr#wR|WYzqk6i7v)Lf zkXdKxzuu20aP{Tbg$(+9&oh7cd(Uoqqf<#ujb$q4sZ~gxFbQfS zS)kNklyL*{2AELgjZ(LBu*>S(oH5AaJ;YiB@;l@=O%F6B?oanzoYRM^fQ9-<~^=3$H0g^JPMLQo@SZ@QuNvy)tyJ)LSj`+()#fy?{aV4Yg^7dlQ7AQM^3GLCR2dAFR zJjtfKiVqF`l-H_fz0HD|9g>)pOxn}k!vdZ=DO!7Sikm{Z%P6BrRkBS6W?ZB5W&7rT z@uYpf@M@a!z7H&o@-yrcCL^Ff3e7p3T`R9p?@o-acXmbTSa0>ZANzCSgovsd%;i$| zVus`not!oL#(W`L-!9w0jdaECaG4hk{V7IOs676ZquZH~0TX5hDq|)x z6T497l|E?f4)LA>j=S8}b$0LS=I4h|hUFJYJODT8Li@#6kF$k0)@*l{RnM1HQ%?VT ze-Pqlc!~t(oumVC*?5fwR;P6u{tHaZ~*LlD;B)4f? z?lpWfa2P@)g57flVl83Ej%P`2)gGyaPjhvD(%i~{`2b>#3!+y&` z!2nuwHMFA-zUY}f1^0B8<`N)Gr=A4TS@b1qykmd0Pq{?r)+1^^+D(=xasb^Tf!oK9 zBLL+*p6M_#ufgLzgq1zcSwZsZnQWFLC3`Yxdg-2=*tT`J9nrfYt)RF)YryBf8_gW{ zvKbB+oZLehfT)S#<|y1)E0hW^?+AnqPXq9Hu;v3dsMGdr{SVyF63;K<8VcgI#~}1i zLYSBL0K;RTT(;>2x=*!1Di9w0mwr;`CN}kM65|Ay{~z}_^JKOsRaN<~#9O^iiW<5P zYN7r~HV!#Nz~IZU`P>1Xe%4f~K}KcF#X&5kO*G}-)74S*tQ8CietdPcA1Yl;S=Mr# z`#MYY!{s^uo=jn7;k6O%(}fN+*0cWMpt~#n9DR<3NyU?+3D^AgI}S)Cu-Tljg`VY} zX1=fq$?8$DtOeGxE6f8lbS_6Q3C4+LDTO$}_IpM$Xv<|QSC%+Oll^q$y`7o@jD{dp zNDl|&X)r7wETa-#h*d`KXntxI(Y{vLha{$0i7@G8xx^m=c<{lJ9?p-i!^W{%j7-oo z0W^SzZ^(Wkyz*We{lEn%Yhu-ycUOHtrRiVJL4~&S91*D0MrLu}Q>v-Mc?GcWfpyz% zX|UvcN@krFO#@v|CtYM}g|=L3%aMo$E5<@CM%c*;?u>LOTz00@+dt1{yg1y=$h+{|D17U}$*^fE^H&8b431EUE z<9tv0V_#%#&1N#j7AKCj!tTK@J%oFW*ESW<(#Gl#Xs%v<@AitI?s92nLzm<)w3Wkkom1f$gcdUi%g_*jofy&}N#luL<$GVIe{iQkQ)sIHVy zBgItnPBFamrv6Kb{eE($Q(f`ZPeW!Hm%Y@F*OF1sKB{Yy|C>WEv_mfvv-N-jh)B-5 z4a!1WcT@9a+hGaBrc~sz=>G?Q!*Zp^JFRUvBMyNR1;`)j$RhH$6gEyVKhd$&K-CFT zXaWC-Y=fyOnqT84iMn9o5oLEOI(_3fk!W^8-74|q1QhQ|CmT0i=b;6Z3u?E{p7V{? z;f#Q-33!L+4&QQcZ~GAqu$NS{M;u%`+#9=7^Oa5PKvCCCWNG_~l(CidS!+xr-*gg{ z$UQ`_1tLT_9jB=Hckkwu>G{s0b0F4bnR7GibmHo?>TR&<3?D;5Fb#gd8*wYa$$~ar z7epl1qM)L{kwiNjQk}?)CFpNTd?0wAOUZ|gC{Ub|c-7h~+Rm(JbdoRe!RNVBQi!M8 z+~U6E2X&KSA*T6KJvsqwqZl#1&==Dm(#b^&VAKQ>7ygv*Fyr;)q9*^F@dCTg2g!w~ z%hg)UXAUyIpIbLXJv1nZX+a_C)BOH2hUim|>=JHCRf(!dtTidb&*~I!JrfRe+PO>w z@ox$G2a3i9d_N9J=|2$y2m-P&#PTNwe!oLBZFs;z|F5kXvBDn<)WwE0E3$ow=zg3R zK(9;sf0t;VEV3@gAg7jRtnj%-6O@!Hvg*;XcUAw}!=2*aErvB(eQIm(-UGmq^J=XN zTqJo$Y|WKo^HlBF3BXJrA#}7ZLg=r*w`I*~Ix`o&2k8^(0mt8Rp=A>F`&gehhp@Jy z^e^#B2!~$LvNCKugg)8)-G%&THdk~kfextilegP9?#C#()F59U$&eo(h|5>ceo*Em z{PEE79T$YP|Kr7K`WBHbtQwyxFkCl6xX&+oUf90B5xoi3_5KHHCyEE*oPbOQkfMz& z6^hT8_NXd2iWk{q9IKae1{_7hMPH8I7_BMtVOM4 z6jm?E0QJOn$qrgsJ`9w##GB9?G})-GXSQo6(tYS(Q0-Ct$co?Zzl0?NHsDRron?;_ zZZgQg)%XW>P?8_&zoGuF(>Och2kEJXsu1_X&~w87x!b z>~h!a>e7{`p@+#hXF88wI*JeWRZ;J4ev4<}HWf|Z;(7$E!S5l9wzBHFe>^I{2`a;a)QnAwa2xv1e(bq$<}!8o^ofGvYpk7dBR+`*%iE;hUY5 zaHF}OjGO9r*{%lmcK^uFiTHgoUD`^9Nx@~;Bg!V* zuuJ&ti{DQiq7RyJAR94wem{}cPK1J(Yxnn_{=>?USqz-~&QXRStS^s-7TksZ$AEI! z#og36s3JGtGU{CnDHRFtipFqvrE*gw7_K@NN0h+ItTq@4fqN!HeQU1y7*X?9+IfZT4Vxebpt z%#VzgdDK~-&+=Z*#>=n#XUhNvBZp3=Cr41jMqwJkHLf3L7Vm~V#GgJ(Jpii~PmJ#s zA7Ft!{xD@z>9DUb4JbiUBdNEcU4BO$651iN*mp*f)HbRRM`Cx5cR?5IfEcU{IZWwf zz(M6CDv)>xa3x}K6%tP^i15P1&&DOLK=k~+jNR$UK3frSl+|PjSC-dBItvD~LL! z>_g(YYdO4k(5EbPOw+v+;G7~jYm>F@Ai|o`gs%F)F8tDz$dl7Q%aCe|v|$UkAul_R zNlA-beBX^IJU?kgS`E$it7nF4DaI!SJAGq)2P&Few(-|tp z?K+%D3e4{pfkayrcbm0ftu6Ol2ZzdKM+4i!hNP3NRL`EvvZJ3yvNr2MV%igZ4kj``Qrdb_OI$7jWP z;l0DYf&0(-*QcP5zrP`HVznW+SbH63Qx$7_9~NjRNg7eKqI!UJ=XH`g^=t8GiFTu( z?2L{JKEu%jJx&XjNzU(*!ZNmL1@RlJA0G$2_LrAb_7lmjil(GSlSM zwTes`m+3R;3#N~Xg#9owh3ycXV8@ZlaY_16kpPFA={721b~URO4HD3sp%fmkZM}k) zZB0#)kP=RkNB~R-MCk8aljG_bagt4vIb~8)BV%(b8_;)&Kf9GX+%O_cNG|(D$!3&D zL(I8}*LqN5NntipFlN13=`D>6!{D@CFMBH0kW3=HccJV+xW~|$qeFR5i-2{X+iWMu zI2$gepQ)H_B%ip_BlWOQ*|pErXs|4ir{IHccgaIJ84irE{?+$KDABXr&f`jB^V-c% z$$u`uU1YB^{<+UN2cNg#7&0bz@yF?5>j|;)5&IV3wIQp58X#OE-M^$HdyvL|Um5t? zhZlAG!Mz%XkUe3t471JM*Yur}o30vzu6RN7gJyNcf!IItsDO730mcJ*O!~V``y5=3 zNJGp34DZ}wd1H6V`Uuy%es>BiO_aE-S8jzir#$& zyk)@2a5tP$@g%jW^b^JGdo)X@Q%sE`^lDQmY9m%uDFpPX`w9%=yQ+nneMm#OaXcD` z9}{tn5A2b2z9783vL2_jSao?uxJhWJoq%47*RafM4o0@gY(p)F>qT4^XM5GLzV#6j zC+HoGhAne7o_w{WUo(B++z7lU3Y0k1rYv9|TSv0vR-Du(5=VakbbelgZTeDn+a_Wv zq_j-^+Qz1WAl;Zg>ahX|CERbX1V%B!hTKN?M}fGoA07M(WU&NfT&TmN`P@56U2 z^)vLDs|Ln~0iTtn-?KTeQl@T&bskJFuTUS!m+$CS9vnd}8(UMO|Kv6TCfGN9NUu&4 zL{)GTxPq>fwsJ~aU=4Qhuq8*RzDsP(LZh$BHezq&9gK$IS<|DYbm})$QTGCS6T;Dr zEkLct!b+#<1r9OKG@P!f1wm8>=Nz!7OzJm!g<+`?N3;YaA3(P@EL=(sTaRMDD!c8=-XN^4BXp(eVkj$NmEMYPP>YJ4bJ3yUud z<3BeJAJ$6z^TuywnfH5lv#$lgwraNw{IV=tIznPH1DT`v-5yS=!)J<}xxl}uZf9azA2A97Haf!;<3y01hlw?dWNEv@TLi1s-mO4vmIT%O_42nS z$VRWrs9NngqRRkWAnWkn%`Rw@?wH|)7XL`EL5EZu$qyJW31&CB^T_)qwIv!{;E_6 zo-9XAryQRlk-O0>o#-SZO>|6OYq;}<*>Wu1AsVRiXY4f8qb;+sItv3AyS!4Ry+q}) zA!pAB|BmC;=RIOk^^vlsEH(!Q!7_1FK~ZB2err*o!+b(r=m1b?$6d!%zmN+69LXnT z&gRmM+n_R-F@sT*IYv0_mGPvur!u`iWbQO7SqiGFLeY&yga zf`lM&B74FA2C?N@8_z652fjhBEoDUKbP8hL{0{HAF%qDo7)o3=3rg#6)T7%%5^wl% z9R0*S*<~>nzYOdQk2l`9h#t+gJy_xujw6xjV(8S<_DbVg61&pT%Hi42l%D73G?adn znB%UdNM0p}lEF-P2%TAMam2zpQev71e>a$$%i+r~b+D9G9pF|oY_*(-u*89oKsXLY+UIbqq)MQ%(GYS{(*n_S_*RN$*~`zUtab%0aKwhx znc)Yo?{xq1sJCgQD)TeTci1ucvbez9q=A72H(-SB18Kl&6^vHV8^i!p@>iF!DIw17 z+8Q)TNisB7>pwyww4y)yJx*wX6SJO78eLBC-ar1+k$Z9fy;wBD|3kzI{<+l*>PSY^ z_?nLOZaeWbU@C3hfK?X;Di*8CHCPkx2qco6(ZyJdqSzp^TJ_5Lpa0UP{Gy+!b0Lr% z@xYxSjUKoY6L#>$qx~KD$-0=|OF7zhVP~ntMgEALYPIfhj@+ z!;JJ7te>CcovruwHsJH6Lta$nm|%^C@=V-rmhU{+I~0(|XHQ9jt@L7pb{gx#{4r!) zg($FyFTslcgu(~6lYr$nW?)%*l#VJ=R-jxK(x=t1bWlu(nL66T#qj%3aZ@uVhy}Co zDU_q61DD5FqqJ*#c|(M5tV)XBN?Ac^12*q)VN4yKPJ|#==S_`_QD9|0ls!`2)SwuHDRA_OfXQDq3%qW&MZB}Z!=k-9xqev8jHz(H z{^D@cIB~QiK>~wa)A&^Ll^Wi6QgCzU;iv-BHsLBs zH7=jN%|>0S`SjP%M&AF1PNVDp_FZ?2Bm@7`DC&v(pYrw!!yD#4 z6+<=HS0Ln6MhoKxF<%~H`y20{vf#pxh=;j{zY381gvAFekgG|>G1zo8$&az{V=;JR zy_puF4$L$?EMhT?;TpQoR*j16ll`#AS4e96C}yp_aGKkBe?1H|k_;gG-~Xorc<;lI zkB}fB{$c-D2mGA&{rm<*@F5)c3X+6??g~XoEwuzSuch0D@W~P5(2I8v8F$c2$Vw51 zP#YLSBDqtWW^EYBl^QYHF+MA7am6f4DOhwnJM=W9$uvMOsZ%_~?)2C#wb?CkI$7{K zEi)=#|5pFvg^){zK5kpBLjB2kZ+$ZB|L=W|aNwyyb(gC2l7bcpx{E-H@)q6@D6N^xh`{1E%ItF2$eeB_SjI@b2WgTpS1thwg&n`jiIzw^TtXUyB{00($GIq>vbj|}bav}}Q_~wp3>k8!E@hVC;OMUTu|= zAy#vXH*GrUHu7^cNZWe1>y;2(51js9wbu+R3Aa*(wzH9+X0dIsf&gc_x|_LP z>~CF^?(~U}+l~ehe|i>?4eo!xkq&Lk+RR-1duNP#o~>@1x)s&i&u zRaYL@+D&_M|JLI6fHbEr_`U;HgPTh#E3?sB)A$*gqyBgg*ql|a-m*TX5rACbWKCE6 zdeQ`v8m6>g^ugv`p|HY^#1QZrGGUj0^HVDc@{?Q0yhalbBEV{+|HzC^-{&e{5K%z9 z6Bxtnfu1!@Mp+Q&*&~;FOg&*Vm<@4b;{FG0-!UUXX!|)1w}op!B_|7_s~d(+=9Gba zKp8`LaB4D(H=cGcspJ_TjYaOwMb=sGn^gtUVhK!UI~2KKYEE-NC}F>+BEY7IVvy%KRvm00tg!Q`y=er}wpEetX}K@;}(}{s9AzV#q2@ zBy7}->|N?13POrs`;U?(qAG(I$~Gt+Rgw%aNZ_0fs_utVvRJT-7z4!@x36v@=NBX=IqkK{#Kg0w48de@?#Yb4M(Svj5=T+<ONr8-oh7l?Cji@+erqur zFhZ=9|Lk=$`c}v4u`)-!!UI=!9Jo@h&7p4RlS#u! zZ7-prn75JkV?VjptX;@$#`U`{vB!=Z?V`T*FBF>J?vsML7e6@2GbUteMFfX-TUu{2 zLNIG*;dV)8GV8gAgEf#)X3A>p3^CRka1v?~8x^anBhQ=L=LsOl=&pcOYHo98m##ye z34MtGCDK!`ptl?taGMr5q{!zVc? zG00e){TV?`YA9eB;(lA3lXI?RrB4BYQGk?vOmTIUJED=(`_*gtn2DB-t4WW54as*W zb2kD-lWX>lb$+W!VFakki>B^Vc+u$?NLF>)!U%b@Y}gYJ>m2H=^x0=nsE0TF^Yu0h ztgH8-o1%+jCk(+&`|)tTfEVHq0cMeFa{Uz)X$;fCq%Y=SOWML6bYfeP8j5hktL`KK z(18`XrUn&WN9PtFxh&dX`y~YBsmdhi7Kw%tKzM%^VEhdD<_XkulW-x=JN6OPbFI4@ zzDDRN+f=@{0h*MswwOqG6gJ?{NuHx(y-|FUGsxyZ*x0~$MW(eY>vqq4Fh#t7uzw=- zKB?|!0N~!h^AMdLa)oR!Ca#HZ9&Zf)ghuO<^RN)4twRlygHnQG(BE{cDc5E}OF4;xss6gYyV~EcJvJkX)xNWb=@yw!uq0v-sf^rvkp-;?DPWK@*SEw|V;IH=7 zfQqEV_>DjOPT~8X*J|H8=&RnzK4~S7ML~nLX^%s-Vqc^aWy7N$y57qciZGcqy#=zU zs8hcHiI=D$+RB{|62{ohCTiaML6FI4Uhzo5D{Jik@poCs0w7F)*w}F4r0sJ~#u-72 z5bK=ANt=M$Dh5NKnxGsg9NRR?WD-x|FhTwBjd zD<-K>44DB~i%frJOfnzh1R>PRY34kw!6~p3M$JLaD1r@`=h)~Ngks-(gdXh^Q?BTP zZ^Zj5w1AwtuR2$~E7s9iZdF}z%pv1em^V2rM{1tLUY@-+Sc0(9jA|iZWml1;v13=U zHf?y@#mb--7z6$ue>`qjhE~brk$AY-RG90~5wcBbDReXR2)pKg{L>;H(DI`U!MLNQ zY9rFJP@ZQ}jlcMh%WSCo%vf+nd0Gmd*F%KMIe>slCUh)8Ma|;M_I+v#;|ueg9oLg; zq2HtZX%&#F7vdpNlkX?}(C7dGC^y#NB#m4%69RzTNrk%4ol~hSI%>2r6B|*ZkW(*P z;u#s;+faHo{tfy+1L^RzWDi*^JR0iY(zJDB36y_QJ+|E-2x+cY z!V8uLNktH~q>WQZuY!Ap66WP|E!0PA1jK~)^8oJVGbspJs6QL!!-5Qm7 zHYI|_`Actg?vDzdg5{86w@GS$G6ANzff7->6i5pB$T4O}`fZ_;{217Om0gN5zTr12 z5mW{hCzCE-QubjxN$TAE-XgI-8dTY@OZmq`y+y_>dk*(qXF0{nam|q@~i}Utp*k{yurq(DW54hkDT4bbg z=_etM?Nf5W^o-HEu9_?&xEqPg^P^mTxLH8n%u$!mWvFG|{&)jtnU&6|5-`~eaNz0%D1BDo`{ zS1N5(KW5v^2eLdd_%`uaRndF@h0Uo6=M|8?b~KbOLZk{HXEnGmtgZXf2inI*1r%n! zQ3&%RI4r{f&dwW~HwH0Ked9b!k6{>_19H z_Ai>5IChDMY(FfMyG%;30?SQ{iV9KyGru62+Y)~qSQ91}b~}w<&*}R&1c#$O`H@~c z5)2S_eXx}M#N{MuGeQS9@#UJB@;W_j50b}jIhxMPloEFQZdvwxiU^RYycTzgK)-vl3LT&$L8~@68$C8~5_U{cR$E#w*x65(qw&eoL@>%ZHvj zWnEMlSh*(o&oy|J7eJ5OD`ssy%F?*Vp?`Cq;FShyl{ZoKCG5g{y}>usznni#8ki(i zO{w@n{iAj1_ooX@+s*!uW60WcH~*bNOT6z%0jVML5};wVrQp~`Uss_{cO2oud_nNA8^B$?07fJ6?iI)Q zuo9G)O-z)DqstrBqf>B%S05hf-wep0@$BFHKSrkZ{za3D)yVzRz)2{wf8(Wp+xyAM z$rtyx$gi3A=V~V!`Q3;BM0$>*VVtxEM|xDL^gew7ydy3Q6YzD&THRz*q33Ms_D;M- zbCx1Ft#UNB)V3bf`~{ImI72OTp^|bF8?G8#FRj+Biy8ET5#rA3sd|0FR@U(LAJ%w8 zS1%n8Z=Amhw)92rIsof=YVWF4jw&F*j1LG@-`+cR0-~2LqXRH8(Ccne{y#MCPncF64U`0uO zWmi$dlii~1D0rLR{qc|_2M!C$t8^=G7xQY)9!#Y331A|>N)EhmyVdLWL9I3YLJ`7? zZmpqUJB>Ni9oiL)^1IK1UoMyhWE{$9M2M6Xi zPKk7GpMsA6vjZbU7~i+u|J6Nk|Ci!Y3UMUT2|`M;JsNQACdJ%ooo9Yt{?A+0hMpxi znEa~~sxC>rKrU6bd=WRb;%wsH>A#j4{({&1GYSNR57Gama(3)2A;SM>qop}l>Jk2* zn1+C$fIxuwzg3mCU#SOqb-wOCb6mBcYlA5+mt<&_J~sBxc(GQtBFINUO~Mr7<-uu($>P HJ4oML2Lo<@i8BwbL^1~GkG`E7C$SEa_ zF^}Ea+#Je`Xy6;#D0FPnSrR%Y!QGA~NA^{oWmW8C<3dr{x6wWQ{4+bzemqV5W$i5~ z=J0jXZ>uZb>DT@0Ks?4QJ{`z?8JWl3$y;2pj#$XP*pv$>$g(z43{YH9KmmR6<#sIn zA`#=0#sgycaBQ^&}Xba!|KaZ8~b30v~nLt z9%#gz_*=~KD{3t^X~l>480*}PhKN=??g`RV|4Ud{Gyyl187MJ}r(#e+H$GEdI+p1s zq_25h;fV)$EPK%Dw-(G=f`yHB-_tttsC!?k7*#!|4a>`Ahj8nm?&n>NRs%jkZW^3-0P_yMP5&*6a26{MRj1&TPF zyE#|c)5uUHzMWx=rMKpuPih*V=S;W3MzIZTw2uTbr}8`p2bm+Z6Sa%vvWAWSf4H)p(+ zSQ8;EvUa#wqWV+9vmIio(%7wukK2SwjUS8Yl%Rq%=~PU)2$Tvm6`1!r3H@U#_|bB0 zmlT1PS3wPB(b&^+@YY7Y$n4l3mV3-X0$>z|gZp6O*Lhzn&?Gad2ZCF;+#95-Y?#y+ z?*l@Yf=a4w{Px=o!N|3~_XKfk&G;fN>Ps&dp2FpA~qD=0~=!NOS@B#XAKKkND>Y{4>rqxrViKD7;?>j8`R` z&G)3FN|dfsxnaI^!d1G%=>AbTTxZWo;n-DLrQ!sj=f~VAOe5zhGS(dgx|!ls62fbX zV@<7Ck^!}R=`Swr?(7w1rY6Nmq~sfXJ?TiKJLn=&SQdEt9$@0 zA+h1Wbwbri0s-stc8yVq;mRa6@kEf8^KXUz&jcic!+avDvvJFa>k0ioWug=T3oPw; zyj4it&0@>_*uI@2=^+T7sL1_!^aJW@Xfo8aC#3^WtQC7fET8b9C} z*u^ue6Ojn z7@(eskJ2+cNnH9~VyfIh<-|7!je~vGy*odz(sk-u$~SrYF3glruZ*W`{sqnS+9=;Z zh{D@MSG91%lr&ua8%$sJF%y1I<|e;EdfJykY8#D$Hc_81n5`$7;1N|b0tvvPLzSg& zn7!5x?T*@rQUKcUhTIjV(rw*5oQYlm5DbEO?60#mohHfbR$3_x#+PZoYi@Vd4`#YgKyTd^!4n{fN~WZDY61sAOm6 zl!d^i*a01QxpWM9Pcl?&{RgO}uq%ErOk5WpECvnfEh!*YP&1Sl)uTN4hg??Vqs~i5 zYsfufz3?{TtwuBN=`0~Qg1PlWH#OGG$ zLLWU17$v``)CE1cds_7kj8mJ{-+l8{DS|zAQ&3|qpOY=!J|kXUhXue9|H>4gqk|n) z-i34GmxLFj8asb3D#D&=ya*a5`C<=o?G;Ev^LV%;l#nH#O=7Nh@z1Do>j6Q;I5S2P zhg|AZbC&|c7}uSJt57s2IK#rSWuararn-02dkptTjo*R{c5o(bWV}_k3BBnKcE|6l zrHl&ezUyw^DmaMdDFVn<8ZY=7_{u{uW&*F<7Al6};lD(u;SB=RpIwI)PTyL=e25h* zGi{lRT}snjbMK~IUx|EGonH+w;iC2Ws)x>=5_{5$m?K z5(*1jMn%u0V1Y%m@`YS3kskt~`1p(rA4uk;Cs!w^KL$w>MH)+cP6|XKr4FfHIATJH z!EGAK4N>1yFR`-zW|w%ByRe#=&kA&#WyUldDGpt!wf-8SFWiSi!5QZL+l7*CE?u!NW1T$<1rdLJ9y3u{_zvHaM?#Rm4 zFk}^1!ffcrB|XK3gsO-s=wr*sUe&^$yN|KxrA)uW00Gu60%pw_+DcUjW`oW<35OC8 zq2{j8SgC}W$?10pvFU83(SL$%C?Kctu3*cs0aa%q!fjn1%xD*Jrm!F3HGR9-C{b?- zHp(cL;ezXMpL@0-1v0DMWddSDNZ5h?q50cOZyVi#bU3&PWE=(hpVn|M4_KYG5h9LffKNRsfhr^=SYiKg?#r&HNMi2@cd4aYL9lw(5_IvQJ zcB*DD()hUSAD^PdA0y|QrVnqwgI@pUXZXjHq3lG2OU&7sPOxxU$Y3&ytj6Qb=2#cC z;{d-{k|xI*bu+Vy&N+}{i(+1me!M;nshY_*&ZQLTGG*xNw#{RpI`3^eGfHck+*38NRgiGahkFethtVY=czJs#)VVc{T65rhU#3Vf?X)8f0)X{w!J3J{z|Sq|%?)nA+zo?$>L9@o`Kc|*7sJo4UjIqu0Ir~S5k^vEH};6K?-dZ0h*m%-1L zf!VC%YbM1~sZOG5zu&Sh>R;(md*_)kGHP)<;OA44W?y53PI%{&@MEN}9TOiqu+1a3AGetBr$c)Ao3OX>iGxmA;^^_alwS818r4Pn&uYe^;z6dh z)68T|AN=hjNdGpF7n>y+RTAZc9&opTXf zqWfK_dUv=mW{p_vN>|(cIkd(+Jy}qnK{IW%X*3!l`^H~FbAHwof+vLZ0C2ZXN1$v7 zgN&R9c8IO`fkR{6U%ERq8FN<1DQYbAN0-pH7EfcA{A&nhT!Be>jj>J!bNRw4NF|}! z1c70_#fkk!VQ!q1h2ff@`yDyrI1`np>*e#D4-Z~*!T^8#o*$V~!8bWQaie?P@KGBb z8rXc!YDL!$3ZgZZ%;-%~0Kn<+d+{xJ$stQbtN8GWV?MCJvzPU|(E(1z;rFw{&6vy) z3*@y%7Tx8rH-p$boS>bLyod?OKRE8v`QSBvGfY6f}_{Zo1q85xoyOF16n~yHx2W ziydUoYLkJmzq|n&2S(O!ZmLdP1(o1Jsq88cX)x3V-BK5eF&0e_0G!5?U7&3KN0`mc zH&Lt)q8!d_VgzxyL^(@xrbp2y)Hmr^V48));RSfE=*Ly0uh9!$3dv-vMZr2URf@l5zdwLjGZB zugY>7_fd_vbV*Qv1?H~>Z%RD%nEeFSI$n$$Lrpc6g>i4+XdBB!%zM$Bhrz5Swzyg? z$~I~n@~-wTBY3-T&pr+|gC+OHDoR?I(eLWa{Z#Rsh>lc~%u0!&R|s0pA*w<7QZ}{i z*AFr~0F3y~f$MGh_HDL7J_1?SxKL}fWIk!$G}`^{)xh*dZ5kK>xGL9>V`WZZg_ z)^Vm)EQK`yfh5KiR(vb&aHvhich z_5o+{d~0+4BEBqYJXyXBIEb1UgVDs;a!N2$9WA>CbfrWryqT25)S4E4)QXBd*3jN} z?phkAt`1rKW?xoLzEm!*IfkH|P>BtECVr0l8-IGk_`UjE#IWkUGqvyS+dMrCnFl<7RCgSMX^qn|Ld_4iYRldO zY&cHhv)GDo8nKvKwAbfyLR%t?9gG?R7~PSD#4D-;?F&!kV59O}neYut5AGbKwy-(U zqyBi=&Mgj|VIo>$u!DHM`R7O?W8-idbePuxiJMH``6c_5L-chKd}=rGC5Gfrc{f!* zWFEBm?l@_b7kzY7%1RQQbG5V<4=ZlkZ%sF74Q|mKOc7Ak7dP2#quiGcZ0_J%7Q?j{ zv9{WFw;n5G-Mn%r#0R;{jLt{yy}9J6rQ(>X9pJ`7Xy?Zv z=lNit#qXaq?CnElK^zF~sG}U5oCpR0T>FH=ZX}Prju$);?;VOhFH8L3I><9P_A|C+ z{;>~dk%9rrq(snjsEm}oUz2FQ21MCG*e?g)?{!&|eg7PX@I+Q0!hL6C7ZVY|g2E>i zr!Ri2@OfEu$)d52+>+cpgh6Z;cLYCZ&EMR0i<^~4&wEu_bdo;y^6}+U2GIQgW$|Od z_jg{O=pU>0-H$P-EOlWyQy#W0r@@_uT}Lg+!d5NxMii7aT1=|qm6BRaWOf{Pws54v zTu=}LR!V(JzI07>QR;;px0+zq=(s+XH-0~rVbmGp8<)7G+Jf)UYs<$Dd>-K+4}CsD zS}KYLmkbRvjwBO3PB%2@j(vOpm)!JABH_E7X^f#V-bzifSaKtE)|QrczC1$sC<<*Y z$hY*3E10fYk`2W09gM_U<2>+r^+ro$Bqh-O7uSa)cfPE_<#^O) zF+5V;-8LaCLKdIh3UB@idQZL`0Vx8`OE#6*1<;8(zi&E7MWB1S%~HAm%axyIHN2vd zA(pJGm_PraB0Aat3~?obWBs?iSc*NhM!{-l_WNCx4@F7I?)5&oI|z{o@JKd1HZ}zf*#}JjK3$ z-;3V*WJZvUcKvSOBH4c7C{fl8oRw8-vfgKQjNiR|KhQ%k6hWNEke(k8w-Ro| z7Y3)FsY-?7%;VT64vRM)l0%&HI~BXkSAOV#F3Bf#|3QLZM%6C{paqLTb3MU-_)`{R zRdfVQ)uX90VCa3ja$8m;cdtxQ*(tNjIfVb%#TCJWeH?o4RY#LWpyZBJHR| z6G-!4W5O^Z8U}e5GfZ!_M{B``ve{r0Z#CXV0x@~X#Pc;}{{ClY_uw^=wWurj0RKnoFzeY` z;gS!PCLCo*c}-hLc?C&wv&>P1hH75=p#;D3{Q8UZ0ctX!b)_@Ur=WCMEuz>pTs$@s z#7bIutL9Pm2FDb~d+H}uBI#pu6R}T{nzpz9U0XLb9lu@=9bTY&PEyFwhHHtXFX~6C zrcg|qqTk(|MIM%KQ<@j=DOjt|V)+8K26wE_CBNnZTg+Z+s}AU|jp6CFoIptG1{J*# z7Ne~l;ba*=bSwAMQ|Vq#fW~+je4PXA91YFzBubNF?ovIOw-$C-8=Ehed{lGD0}(Id zRe4sh8L>&T%{>8o))he}eE;5_ zxoXk3wX?MyNl-xF!q1d$G?=wp^`@09(jU&X zOqZIBI#dN`2PJNdATR3ivtub|nO$dulSaP|e4)WXF1YAGN1pDQIbIjXFG!oC85Mt; zW$eteoL{y^5t4TMRwP$jNPjZFpGsWnGe=jMMqKtcZm9Y9PFZLi*1p@qoKKub^T@2+ zk$@*KYdQ?Z`}<%4ALwk*Yc{(WTf@#u;as(fvE^9{Gk)lWbJP*SjttWofV0s?AB({~l zZI1hZVWFT~W-T?nfMMcnCS4-#6H-MU7H$KxD;yaM46K4Kc@~Q>xzB+QnD_I`b_l3m zo9pRx46b!p?a^&zCDwygqqV3epjs(s0NQI6ARA1n!Yy-qduipxQ& zUAlqRpNjBS+y-ZheD(!R;F}&^V_}b_gqH%tVZ5%%ziO7k^w=es+wZtK^i*vmrWNLMs{oWu_CIov|s1raZiS)>38>pYu;i+-t zI_DiNe6aA4KTZ2P09qPj(0~K4nUq^0+f(2$g`229zkG4jLzRvJUWE0oF1XHL4t3UN zDH466G56sy9hTZoAJB!C3;@F;ONxEk5u6Mv%zdo}Rq`=* zw1n7MOhfNSV48TS989ArIcj`C%Gk8~93~u>)!Yt2b4ZriKj9x2d`H2HQNJ=I>hkDlcZn zqRj>!;oRMTIOu zx|Zfsu~v76T{z7AC(jxj^c@tnJHZtGPsq$DE!8kqvkDx5W?KUJPL+!Ffpwfa+|5z5 zKPCiOPqZZrAG;2%OH0T$W|`C@C*!Z`@Wkop{CTjB&Tk`+{XPnt`ND`Haz;xV`H^RS zyXYtw@WlqTvToi;=mq1<-|IQ(gcOpU%)b#_46|IuWL#4$oYLbqwuk6=Q@xZaJSKVF zZcHs~ZBl;&lF3=+nK; zF`4gSCeZXlwmC_t4I`#PUNQ*)Uv&oGxMALip|sxv^lyVV73tKI7)+QY5=tEMas{vTD-BaTJ^*Y6gq~PU;F5X!sxqiq$iFCo+Uv7m%1w((=e}Vf*=dtds|6 zbX}91!G?C*KG03eHoN}RZS9DJxa&8YwNCT8?JxMXyZqZr13NA|GB{+vG`08C{V(yy zf*Lw$+tYSU_+dI`3n{bMrPdDb`A=Mkg!O=k>1|*3MC8j~- zXL79J4E=U^H=iBLTeHE_OKzE&dws8RNynsSJ!d;`zK?P92U{f)xvD7VQVosrXZrL+ z6lMVdD1YgL;%(1cq{#bS6yXmp|DS@nax#AqqlZhtUQdh<^2vr5`EpAO

LGYq)sa(w9^3-f}NHy=GR4v%t2YZly3m1G@5y`xBh_HGrD%f z>;|Ty?9FiJAc&UVD(StT4I` zfVQwxhE9bXE6r2mKO8Ag7{L^jCyqQb0QqKDPE=RAgqn8q1O^>(z7h5kE(6va%QqRZ zkIOmp(})rLSS(2{=C12e&@!W2=Jel-^_R``0xHO^+t!(oXbcv5yhD4g*$t_F)_5Dl zSVCgesW%;DtYPCFs{G;GX_o?1J3;QQPPv)rWw;>} zJ&KwnUqwNXloNXlK_+pNDfI~hON#SokVJb&ilg8d7^NWo2ZQymCqQMnjfi>ePibjr z-Z@q!?RGN$Mj}Nk){X_vaj6?Mj$>ACR*z|6MsXy3VZ^PFn@yHkPo(>m(iWepn8SC@ z>D2;R4m+gDRZ=SIX!b+CP(qE=JDIUkn=D$aUu+Ihn9-+k1LS3PreQg0N5eWIG@x${nC3v^7caS>1!PKNAY9J z#}E}Q9w#SP>(GY7Hbj&z4$Li6o5taBO|4+F`yS9zq*LJ<38wy4I>HA9(&GYrk4dLajKGww))BWli6Ln1A^Lda@N~p+snkb9C z@OthI+<##vp8!HVQT4Wk(=@zQ{OvZ$EKWS73+JHb)eYLGD-cqi6^|vd$<+IHuc?Nq zW7JertT~3))4?J|28n$I@nAD0c1%9C&IVhEZX~mUsf{efyS(XNG%ch;!N~d7S(Ri7 zb&=BuON95aVA&kLn6&MVU|x}xPMp7xwWxNU1wS+F6#y}1@^wQZB*(&ecT?RnQcI}Y z2*z!^!D?gDUhc@;M^OpLs4mq>C&p{}OWVv<)S9KMars@0JQ{c_ScGsFo3BJ)Irg++ zAWwypJdTO-_{Uh8m(Z!3KL7K{ZZzKHj;{M8I$mV>k znTM?sa0);^=X^cglL`uC+^J)M7nEa$w=VwFULg~%DJllw+7dJAj3{qnP5i3@wr7%y zjXp?Wl2%Th=my&3u?Q$RV6N5tzKMSPTsc#J+-cDDp~qFB6bL2C8AS7Y3PKtVhdhl) zIaLqH5+OnWPWSt(lQCgkN8lczc-V%_iZ{>#1%Z$N*>lu#S;0MZ$T2Y8Kg!U;hAZj> z6S#%$DQ_`Ic%Zr@?}GgjRXg@qTj^17n`65oJ@Wj0u1X8&+UVd|Xs?J+i_^GZ94m6= zUc96~Q`OJvlKB_Lr15*Yw_PUPEr?f?H&00b^-W%26mD)(n(rGGNfK9~2h=C>p-7BZ zFd&*&Msdu{w~(eyFOglwCPH^Rb}O(N7LtS+nnEwDx*pGD?|&9Si~M43a+*L(b0$5A zv`T`(G3xO;I_sx;FwTP21ZlfDpz zOo?}Vlgf~fo{YWm@n_JyD*frOg{XsvBA~|Tn4V6hu>Gd>89-rblfVJUaGvj6X%NZ} z$tFF9sx=4_$*c~G`9iPLGh@=sV+O{D2-t*K@J7H=`V+oVt}8?04WwU3h1BgS!f%1P zFak-T#7`TtLcR=Yz>g0R!ZQrH!YiZOQN=_V-UyncN1Rc18?KY?#O`v#JK+pq0K$~H z3D@v9DZF42R)b9#BBX{^$DOMlJ!g)Gc za{o-1e%F6NvgKq9tC8pV+9S$;9*zNv{J*)n&dmf~anP1)4~N%~h#c(=B#3*KgzhCKhFdgDoWi2IDog{RVyzK|Y`rCUs3T~pJMmdZJy4?b z&s5G=zhf**(t7Y^oC_mcTsE-{^}wiaoUu&?kojLKs>SJPxjcP>{a5CbXCx92AcBE) zHtqP}LjZ{W>PH?Tu(E0X=%{PBMW@F_?#7b&#!^q`<-5$ur+-q6 z{dn=(^UZw6*3-XM_(=@<1_*i&XM4=0t5u!gm6 z{UlmNGPKgO_;e;q9|#esq~Sq`<}%d{+sRmhvsA{5i*91=tub>OZZ%)xUA#4q$dDyy z1`w4%?OPLg3JeZb#cqSMO?*Xn%|-FCcuH2i2fn_{IFusub6;NQdN|7TD1N?%E8*g? z$apAt@cEe!I%jB=*q$p_3=t_5R0ph%{qaq+QDg!c99Y!Xa!&oDZOeis_ot)gNXr{l zdY$|So2Qed2Y7KMNBrS^E169kG%h<+z{Z_p_;shB!uY)>yAVcK=&!bg`lVg)4T1|7 z0}7FpfydVH4F87K@c!nEG+WGKm{Ouo)Slpl;#qcEIQ0zdMfLA#;dBxYw;p;KoVv6| z3_D5&7rJdG12CnDSvZUW?$UC6^UVSW^|vw|o-_4bz)(w5(3AiVhpeT(|=f#x_}E?s#qHZF#xA6AF_ujl$G z-jHD%q(d2}v2PhXx&6YWps~m(^+RXl91Q#xRRJBhjKl$FG4bk);|ag;ieUZ&!Ii3$ z(iGz1+0m7#g5>ASldBbNZL=ZHh=tmmJt$!71; zIML2GhEz1pg@1rQN(M^_691wAGkJ@Pga_05WuQ6! zG5RkGY2^`@(H~pp7&Ga+Pwh3L!Njj!-rc;^bTIfo5hP@H##1X8xUZJckrx>id`bAd3QUx9GuomqBYZ!uN1-&o zvTxC?;p8vL67&fW8fw(YOqt>L@bdLrEF*3OgYe$4n4{ zEB40LiU#6-0@5jdN`0w}N0qi@c0~oT2FP z)LNk&a82my?jv(tQpiMi$TK_L@lub#lsM$R{Dk?Ya@%%%huZkct~tSWM714c!45k}-ZLVA-bVM`>|_ZBbW_m-7| z3U%xrAhi}n?T(2F{_n4EZ10inkIFl#y09?7$uwBoJgqY8vylwev)fDOn;>0R!aEnV zBz%j0Mqpx~EZU3q@%+oV7;}|vt7$~ou@faEIq{p?FY$XXg&6*K)b_LP=}gi9`Bij3 zN`zEo|B6*|-;>S`rNa^BKRDbDAk>X#MsR`EvL>6bqU@SaDDs z8>bu@3YdRaWs*Te@G-UHjU%F~kTHw5(0PVJ+pwh#ha2u;DB+UMo@A5UYIl#5rtBV- zGX_hIpw}3C@H*Us(Cc-d#-gNrG#w$(9+S=GxO>3SR`SE2fHZ2KrDc#_C^$jI>Y}#; zMwY=R6@+dWi~0RXw(c@3GZ&%~9K(q&ee0Zw;pwL`E_tZak-#8^_b)Dpyi73^he?xV zXJ08&wh5-M&}qy4f7!D&=E)puDD(Nmg1d_(j`4LvxM5x_huNg-pGG%9rYqO6mImyJ@}*3Y>^3OvcnTG%EV1) zq_Ap?Z!Iw__7#D=pOWnQN$gB!Mr0!9yx|g<4icJh{cFOu3B8}&RiYm+Mb;VEK``LK zL(NcpcTiGieOIssSjr?ob}^``nNf&UcJhXyncO9m{6gD$kqSD`S69(aF8dkWz5>!9 zBLe4Sib7Hs2x_L2Ls6Ish$MGVKrGt5+_2zCyP1byaCg3upo+-I}R4&$m)8 zQ7|jc1Z^VWggpuQj*cP;>Zo9LS!VSzrqmZczaf;u`d0J(f%Z9r%An@s!e>n9%y=n!IZ_tVGu{Jmsbp}Fk%HJIU?a+-~bjfLTuH|JExA8EROowzr zqW9{YyZhR0a4clRK>1I4Ncx&WER~{iE;F^$T7K%X@3PGOA%6#Z%p3TS^&M;Dnjw@i z^o!$9nhcsmcHcY4?4j9+ofL_CWsZ4Hcch(rjsGfGD(nsH>w}^ERqGnz%iGj0j{g}h z7wMkJ-2Z2~eS>2!i}0~B63i;>SyFJU2+>VCS^AxaDOx%g6-t0eM^P<3+*z`ztvOqrG3)&#$K?& z_Y0wbWID47@cU`E1A6A&!`aZk0ZE@z-h#l1NqX2#`$Uev2gepW`rf8*!=rD5&;Jb{ zl08rU>dPo=K%-1Ao1~G-@4ve~y5#9E8x;TE0k5d^TC(=Zc>mwjW^c=+U-<9}b0ku~}gj z3sbW>R2M6DR!g#NUP;nxo>)@7*=RP{U18SDop6b2&PHce^&h97@xx3t+VK+!keE#} z;(Uf&89as9k8{$nkLbuB!-d7TP`_VJpL^Xs8OKB~ri$YUbW8fch64}7|0EWoT(TRj{ z*GT<7Y<7DsrCi79ZsM)z#c(!nNOGySOCkY1fAuQOq12&iUVC!a`#O;dBLf=d?&4*B zI~LgAO7E0qxK(uRTM;IgJ}+z^gD+bi-6I!3x{r9`l~%8TRP%UE0V8E*Sz>Nl1NVG<<7(wDHZ+HcOkQm$O&k+vyx)y)x{Pz!U8hS$*m zByc0h6BUI*BOpuL==P+H|Hx%`>7!W+1H!l9vi&)`V zyn2o9{z=lc+VX*!Vh~SF=)L}Z40XeG>LF6cP^b+R$NxSeUqbK^Q*UTalKzP8X%{9@RSCXm_NhF>{=S2 zi}ezam_^P`S!!-cyEW9y7DBbK93roz@Raccy*v}?mKXScU9E_4g;hBU7}zSofAFda zKYEe?{{I54 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138..cea7a793 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index b740cf13..f3b75f3b 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -84,7 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 7101f8e4..9d21a218 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,94 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. 1>&2 -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 -echo. 1>&2 -echo Please set the JAVA_HOME variable in your environment to match the 1>&2 -echo location of your Java installation. 1>&2 - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/sample-app/build.gradle b/sample-app/build.gradle deleted file mode 100644 index 4ee8f227..00000000 --- a/sample-app/build.gradle +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - id 'java-library' -} - -repositories { - mavenCentral() - maven { - url 'https://s01.oss.sonatype.org/content/repositories/releases/' - } -} - -dependencies { - implementation rootProject -} - - -sourceCompatibility = 1.8 -targetCompatibility = 1.8 - diff --git a/sample-app/src/main/java/sample/App.java b/sample-app/src/main/java/sample/App.java deleted file mode 100644 index 39226741..00000000 --- a/sample-app/src/main/java/sample/App.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -package sample; - -import java.lang.String; - -public final class App { - public static void main(String[] args) { - // import com.courier.api.Courier - } -} diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..f4063482 --- /dev/null +++ b/scripts/build @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Building classes" +./gradlew build testClasses -x test diff --git a/scripts/fast-format b/scripts/fast-format new file mode 100755 index 00000000..1b3bc473 --- /dev/null +++ b/scripts/fast-format @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +set -euo pipefail + +echo "Script started with $# arguments" +echo "Arguments: $*" +echo "Script location: $(dirname "$0")" + +cd "$(dirname "$0")/.." +echo "Changed to directory: $(pwd)" + +if [ $# -eq 0 ]; then + echo "Usage: $0 [additional-formatter-args...]" + echo "The file should contain one file path per line" + exit 1 +fi + +FILE_LIST="$1" + +echo "Looking for file: $FILE_LIST" + +if [ ! -f "$FILE_LIST" ]; then + echo "Error: File '$FILE_LIST' not found" + exit 1 +fi + +if ! command -v ktfmt-fast-format &> /dev/null; then + echo "Error: ktfmt-fast-format not found" + exit 1 +fi + +# Process Kotlin files +echo "==> Looking for Kotlin files" +kt_files=$(grep -E '\.kt$' "$FILE_LIST" | grep -v './buildSrc/build/' || true) +echo "==> Done looking for Kotlin files" + +if [[ -n "$kt_files" ]]; then + echo "==> will format Kotlin files" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" +else + echo "No Kotlin files to format -- expected outcome during incremental formatting" +fi + +# TODO(mbudayr): support palantir-java-format +# Process Java files +# grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/format b/scripts/format new file mode 100755 index 00000000..65db1769 --- /dev/null +++ b/scripts/format @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if command -v ktfmt &> /dev/null; then + echo "==> Running ktfmt" + ./scripts/kotlin-format +else + echo "==> Running gradlew formatKotlin" + ./gradlew formatKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Running palantir-java-format" + ./scripts/java-format +else + echo "==> Running gradlew formatJava" + ./gradlew formatJava +fi diff --git a/scripts/java-format b/scripts/java-format new file mode 100755 index 00000000..ad5febce --- /dev/null +++ b/scripts/java-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@" diff --git a/scripts/kotlin-format b/scripts/kotlin-format new file mode 100755 index 00000000..3b8be9ea --- /dev/null +++ b/scripts/kotlin-format @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@" diff --git a/scripts/lint b/scripts/lint new file mode 100755 index 00000000..dbc8f776 --- /dev/null +++ b/scripts/lint @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +echo "==> Running lints" + +if command -v ktfmt &> /dev/null; then + echo "==> Checking ktfmt" + ./scripts/kotlin-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintKotlin" + ./gradlew lintKotlin +fi + +if command -v palantir-java-format &> /dev/null; then + echo "==> Checking palantir-java-format" + ./scripts/java-format --dry-run --set-exit-if-changed +else + echo "==> Running gradlew lintJava" + ./gradlew lintJava +fi diff --git a/scripts/mock b/scripts/mock new file mode 100755 index 00000000..0b28f6ea --- /dev/null +++ b/scripts/mock @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +if [[ -n "$1" && "$1" != '--'* ]]; then + URL="$1" + shift +else + URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" +fi + +# Check if the URL is empty +if [ -z "$URL" ]; then + echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" + exit 1 +fi + +echo "==> Starting mock server with URL ${URL}" + +# Run prism mock on the given spec +if [ "$1" == "--daemon" ]; then + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + + # Wait for server to come online + echo -n "Waiting for server" + while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + echo -n "." + sleep 0.1 + done + + if grep -q "✖ fatal" ".prism.log"; then + cat .prism.log + exit 1 + fi + + echo +else + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" +fi diff --git a/scripts/test b/scripts/test new file mode 100755 index 00000000..047bc1db --- /dev/null +++ b/scripts/test @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e + +cd "$(dirname "$0")/.." + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +function prism_is_running() { + curl --silent "http://localhost:4010" >/dev/null 2>&1 +} + +kill_server_on_port() { + pids=$(lsof -t -i tcp:"$1" || echo "") + if [ "$pids" != "" ]; then + kill "$pids" + echo "Stopped $pids." + fi +} + +function is_overriding_api_base_url() { + [ -n "$TEST_API_BASE_URL" ] +} + +if ! is_overriding_api_base_url && ! prism_is_running ; then + # When we exit this script, make sure to kill the background mock server process + trap 'kill_server_on_port 4010' EXIT + + # Start the dev server + ./scripts/mock --daemon +fi + +if is_overriding_api_base_url ; then + echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" + echo +elif ! prism_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" + echo -e "running against your OpenAPI spec." + echo + echo -e "To run the server, pass in the path or url of your OpenAPI" + echo -e "spec to the prism command:" + echo + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo + + exit 1 +else + echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo +fi + +echo "==> Running tests" +./gradlew test "$@" diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index aed36fec..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include 'sample-app' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..196eb7cf --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,14 @@ +rootProject.name = "courier-java-root" + +val projectNames = rootDir.listFiles() + ?.asSequence() + .orEmpty() + .filter { file -> + file.isDirectory && + file.name.startsWith("courier-java") && + file.listFiles()?.asSequence().orEmpty().any { it.name == "build.gradle.kts" } + } + .map { it.name } + .toList() +println("projects: $projectNames") +projectNames.forEach { include(it) } diff --git a/src/main/java/com/courier/api/Courier.java b/src/main/java/com/courier/api/Courier.java deleted file mode 100644 index a87055a8..00000000 --- a/src/main/java/com/courier/api/Courier.java +++ /dev/null @@ -1,203 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.Suppliers; -import com.courier.api.requests.SendMessageRequest; -import com.courier.api.resources.audiences.AudiencesClient; -import com.courier.api.resources.auditevents.AuditEventsClient; -import com.courier.api.resources.authtokens.AuthTokensClient; -import com.courier.api.resources.automations.AutomationsClient; -import com.courier.api.resources.brands.BrandsClient; -import com.courier.api.resources.bulk.BulkClient; -import com.courier.api.resources.inbound.InboundClient; -import com.courier.api.resources.lists.ListsClient; -import com.courier.api.resources.messages.MessagesClient; -import com.courier.api.resources.notifications.NotificationsClient; -import com.courier.api.resources.profiles.ProfilesClient; -import com.courier.api.resources.templates.TemplatesClient; -import com.courier.api.resources.tenants.TenantsClient; -import com.courier.api.resources.translations.TranslationsClient; -import com.courier.api.resources.users.UsersClient; -import com.courier.api.types.SendMessageResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import java.util.function.Supplier; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class Courier { - protected final ClientOptions clientOptions; - - protected final Supplier audiencesClient; - - protected final Supplier auditEventsClient; - - protected final Supplier authTokensClient; - - protected final Supplier automationsClient; - - protected final Supplier brandsClient; - - protected final Supplier bulkClient; - - protected final Supplier inboundClient; - - protected final Supplier listsClient; - - protected final Supplier messagesClient; - - protected final Supplier notificationsClient; - - protected final Supplier profilesClient; - - protected final Supplier templatesClient; - - protected final Supplier tenantsClient; - - protected final Supplier translationsClient; - - protected final Supplier usersClient; - - public Courier(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.audiencesClient = Suppliers.memoize(() -> new AudiencesClient(clientOptions)); - this.auditEventsClient = Suppliers.memoize(() -> new AuditEventsClient(clientOptions)); - this.authTokensClient = Suppliers.memoize(() -> new AuthTokensClient(clientOptions)); - this.automationsClient = Suppliers.memoize(() -> new AutomationsClient(clientOptions)); - this.brandsClient = Suppliers.memoize(() -> new BrandsClient(clientOptions)); - this.bulkClient = Suppliers.memoize(() -> new BulkClient(clientOptions)); - this.inboundClient = Suppliers.memoize(() -> new InboundClient(clientOptions)); - this.listsClient = Suppliers.memoize(() -> new ListsClient(clientOptions)); - this.messagesClient = Suppliers.memoize(() -> new MessagesClient(clientOptions)); - this.notificationsClient = Suppliers.memoize(() -> new NotificationsClient(clientOptions)); - this.profilesClient = Suppliers.memoize(() -> new ProfilesClient(clientOptions)); - this.templatesClient = Suppliers.memoize(() -> new TemplatesClient(clientOptions)); - this.tenantsClient = Suppliers.memoize(() -> new TenantsClient(clientOptions)); - this.translationsClient = Suppliers.memoize(() -> new TranslationsClient(clientOptions)); - this.usersClient = Suppliers.memoize(() -> new UsersClient(clientOptions)); - } - - /** - * Use the send API to send a message to one or more recipients. - */ - public SendMessageResponse send(SendMessageRequest request) { - return send(request, null); - } - - /** - * Use the send API to send a message to one or more recipients. - */ - public SendMessageResponse send(SendMessageRequest request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("send") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SendMessageResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public AudiencesClient audiences() { - return this.audiencesClient.get(); - } - - public AuditEventsClient auditEvents() { - return this.auditEventsClient.get(); - } - - public AuthTokensClient authTokens() { - return this.authTokensClient.get(); - } - - public AutomationsClient automations() { - return this.automationsClient.get(); - } - - public BrandsClient brands() { - return this.brandsClient.get(); - } - - public BulkClient bulk() { - return this.bulkClient.get(); - } - - public InboundClient inbound() { - return this.inboundClient.get(); - } - - public ListsClient lists() { - return this.listsClient.get(); - } - - public MessagesClient messages() { - return this.messagesClient.get(); - } - - public NotificationsClient notifications() { - return this.notificationsClient.get(); - } - - public ProfilesClient profiles() { - return this.profilesClient.get(); - } - - public TemplatesClient templates() { - return this.templatesClient.get(); - } - - public TenantsClient tenants() { - return this.tenantsClient.get(); - } - - public TranslationsClient translations() { - return this.translationsClient.get(); - } - - public UsersClient users() { - return this.usersClient.get(); - } - - public static CourierBuilder builder() { - return new CourierBuilder(); - } -} diff --git a/src/main/java/com/courier/api/CourierBuilder.java b/src/main/java/com/courier/api/CourierBuilder.java deleted file mode 100644 index be42cdc5..00000000 --- a/src/main/java/com/courier/api/CourierBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.Environment; - -public final class CourierBuilder { - private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder(); - - private String authorizationToken = System.getenv("COURIER_AUTH_TOKEN"); - - private Environment environment = Environment.PRODUCTION; - - /** - * Sets authorizationToken. - * Defaults to the COURIER_AUTH_TOKEN environment variable. - */ - public CourierBuilder authorizationToken(String authorizationToken) { - this.authorizationToken = authorizationToken; - return this; - } - - public CourierBuilder environment(Environment environment) { - this.environment = environment; - return this; - } - - public CourierBuilder url(String url) { - this.environment = Environment.custom(url); - return this; - } - - public Courier build() { - if (authorizationToken == null) { - throw new RuntimeException( - "Please provide authorizationToken or set the COURIER_AUTH_TOKEN environment variable."); - } - this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.authorizationToken); - clientOptionsBuilder.environment(this.environment); - return new Courier(clientOptionsBuilder.build()); - } -} diff --git a/src/main/java/com/courier/api/core/ClientOptions.java b/src/main/java/com/courier/api/core/ClientOptions.java deleted file mode 100644 index 7ceb0b38..00000000 --- a/src/main/java/com/courier/api/core/ClientOptions.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import java.util.function.Supplier; -import okhttp3.OkHttpClient; - -public final class ClientOptions { - private final Environment environment; - - private final Map headers; - - private final Map> headerSuppliers; - - private final OkHttpClient httpClient; - - private ClientOptions( - Environment environment, - Map headers, - Map> headerSuppliers, - OkHttpClient httpClient) { - this.environment = environment; - this.headers = new HashMap<>(); - this.headers.putAll(headers); - this.headers.putAll(new HashMap() { - { - put("X-Fern-Language", "JAVA"); - put("X-Fern-SDK-Name", "com.courier.fern:api-sdk"); - put("X-Fern-SDK-Version", "3.6.0"); - } - }); - this.headerSuppliers = headerSuppliers; - this.httpClient = httpClient; - } - - public Environment environment() { - return this.environment; - } - - public Map headers(RequestOptions requestOptions) { - Map values = new HashMap<>(this.headers); - headerSuppliers.forEach((key, supplier) -> { - values.put(key, supplier.get()); - }); - if (requestOptions != null) { - values.putAll(requestOptions.getHeaders()); - } - return values; - } - - public Map headers(IdempotentRequestOptions requestOptions) { - Map values = new HashMap<>(this.headers); - headerSuppliers.forEach((key, supplier) -> { - values.put(key, supplier.get()); - }); - if (requestOptions != null) { - values.putAll(requestOptions.getHeaders()); - } - return values; - } - - public OkHttpClient httpClientWithTimeout(IdempotentRequestOptions requestOptions) { - if (requestOptions == null) { - return this.httpClient; - } - return this.httpClient - .newBuilder() - .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .build(); - } - - public OkHttpClient httpClient() { - return this.httpClient; - } - - public OkHttpClient httpClientWithTimeout(RequestOptions requestOptions) { - if (requestOptions == null) { - return this.httpClient; - } - return this.httpClient - .newBuilder() - .callTimeout(requestOptions.getTimeout().get(), requestOptions.getTimeoutTimeUnit()) - .connectTimeout(0, TimeUnit.SECONDS) - .writeTimeout(0, TimeUnit.SECONDS) - .readTimeout(0, TimeUnit.SECONDS) - .build(); - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private Environment environment; - - private final Map headers = new HashMap<>(); - - private final Map> headerSuppliers = new HashMap<>(); - - public Builder environment(Environment environment) { - this.environment = environment; - return this; - } - - public Builder addHeader(String key, String value) { - this.headers.put(key, value); - return this; - } - - public Builder addHeader(String key, Supplier value) { - this.headerSuppliers.put(key, value); - return this; - } - - public ClientOptions build() { - OkHttpClient okhttpClient = new OkHttpClient.Builder() - .addInterceptor(new RetryInterceptor(3)) - .build(); - return new ClientOptions(environment, headers, headerSuppliers, okhttpClient); - } - } -} diff --git a/src/main/java/com/courier/api/core/CourierApiApiError.java b/src/main/java/com/courier/api/core/CourierApiApiError.java deleted file mode 100644 index 3a7e4eda..00000000 --- a/src/main/java/com/courier/api/core/CourierApiApiError.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -/** - * This exception type will be thrown for any non-2XX API responses. - */ -public class CourierApiApiError extends CourierApiError { - /** - * The error code of the response that triggered the exception. - */ - private final int statusCode; - - /** - * The body of the response that triggered the exception. - */ - private final Object body; - - public CourierApiApiError(String message, int statusCode, Object body) { - super(message); - this.statusCode = statusCode; - this.body = body; - } - - /** - * @return the statusCode - */ - public int statusCode() { - return this.statusCode; - } - - /** - * @return the body - */ - public Object body() { - return this.body; - } - - @java.lang.Override - public String toString() { - return "CourierApiApiError{" + "message: " + getMessage() + ", statusCode: " + statusCode + ", body: " + body - + "}"; - } -} diff --git a/src/main/java/com/courier/api/core/CourierApiError.java b/src/main/java/com/courier/api/core/CourierApiError.java deleted file mode 100644 index 3641459f..00000000 --- a/src/main/java/com/courier/api/core/CourierApiError.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -/** - * This class serves as the base exception for all errors in the SDK. - */ -public class CourierApiError extends RuntimeException { - public CourierApiError(String message) { - super(message); - } - - public CourierApiError(String message, Exception e) { - super(message, e); - } -} diff --git a/src/main/java/com/courier/api/core/DateTimeDeserializer.java b/src/main/java/com/courier/api/core/DateTimeDeserializer.java deleted file mode 100644 index 98c04b15..00000000 --- a/src/main/java/com/courier/api/core/DateTimeDeserializer.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.module.SimpleModule; -import java.io.IOException; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.format.DateTimeFormatter; -import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQueries; - -/** - * Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects. - */ -class DateTimeDeserializer extends JsonDeserializer { - private static final SimpleModule MODULE; - - static { - MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer()); - } - - /** - * Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper. - * - * @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper. - */ - public static SimpleModule getModule() { - return MODULE; - } - - @Override - public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { - JsonToken token = parser.currentToken(); - if (token == JsonToken.VALUE_NUMBER_INT) { - return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC); - } else { - TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest( - parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from); - - if (temporal.query(TemporalQueries.offset()) == null) { - return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC); - } else { - return OffsetDateTime.from(temporal); - } - } - } -} diff --git a/src/main/java/com/courier/api/core/Environment.java b/src/main/java/com/courier/api/core/Environment.java deleted file mode 100644 index 00a91946..00000000 --- a/src/main/java/com/courier/api/core/Environment.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -public final class Environment { - public static final Environment PRODUCTION = new Environment("https://api.courier.com"); - - private final String url; - - private Environment(String url) { - this.url = url; - } - - public String getUrl() { - return this.url; - } - - public static Environment custom(String url) { - return new Environment(url); - } -} diff --git a/src/main/java/com/courier/api/core/IdempotentRequestOptions.java b/src/main/java/com/courier/api/core/IdempotentRequestOptions.java deleted file mode 100644 index 0e271802..00000000 --- a/src/main/java/com/courier/api/core/IdempotentRequestOptions.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeUnit; - -public final class IdempotentRequestOptions { - private final String authorizationToken; - - private final String idempotencyKey; - - private final String idempotencyExpiry; - - private final Optional timeout; - - private final TimeUnit timeoutTimeUnit; - - private IdempotentRequestOptions( - String authorizationToken, - String idempotencyKey, - String idempotencyExpiry, - Optional timeout, - TimeUnit timeoutTimeUnit) { - this.authorizationToken = authorizationToken; - this.idempotencyKey = idempotencyKey; - this.idempotencyExpiry = idempotencyExpiry; - this.timeout = timeout; - this.timeoutTimeUnit = timeoutTimeUnit; - } - - public Optional getTimeout() { - return timeout; - } - - public TimeUnit getTimeoutTimeUnit() { - return timeoutTimeUnit; - } - - public Map getHeaders() { - Map headers = new HashMap<>(); - if (this.authorizationToken != null) { - headers.put("Authorization", "Bearer " + this.authorizationToken); - } - if (this.idempotencyKey != null) { - headers.put("Idempotency-Key", this.idempotencyKey); - } - if (this.idempotencyExpiry != null) { - headers.put("X-Idempotency-Expiration", this.idempotencyExpiry); - } - return headers; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private String authorizationToken = null; - - private String idempotencyKey = null; - - private String idempotencyExpiry = null; - - private Optional timeout = Optional.empty(); - - private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; - - public Builder authorizationToken(String authorizationToken) { - this.authorizationToken = authorizationToken; - return this; - } - - public Builder idempotencyKey(String idempotencyKey) { - this.idempotencyKey = idempotencyKey; - return this; - } - - public Builder idempotencyExpiry(String idempotencyExpiry) { - this.idempotencyExpiry = idempotencyExpiry; - return this; - } - - public Builder timeout(Integer timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { - this.timeout = Optional.of(timeout); - this.timeoutTimeUnit = timeoutTimeUnit; - return this; - } - - public IdempotentRequestOptions build() { - return new IdempotentRequestOptions( - authorizationToken, idempotencyKey, idempotencyExpiry, timeout, timeoutTimeUnit); - } - } -} diff --git a/src/main/java/com/courier/api/core/MediaTypes.java b/src/main/java/com/courier/api/core/MediaTypes.java deleted file mode 100644 index 175c971f..00000000 --- a/src/main/java/com/courier/api/core/MediaTypes.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import okhttp3.MediaType; - -public final class MediaTypes { - - public static final MediaType APPLICATION_JSON = MediaType.parse("application/json"); - - private MediaTypes() {} -} diff --git a/src/main/java/com/courier/api/core/ObjectMappers.java b/src/main/java/com/courier/api/core/ObjectMappers.java deleted file mode 100644 index 146ef3e9..00000000 --- a/src/main/java/com/courier/api/core/ObjectMappers.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.json.JsonMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import java.io.IOException; - -public final class ObjectMappers { - public static final ObjectMapper JSON_MAPPER = JsonMapper.builder() - .addModule(new Jdk8Module()) - .addModule(new JavaTimeModule()) - .addModule(DateTimeDeserializer.getModule()) - .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) - .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) - .build(); - - private ObjectMappers() {} - - public static String stringify(Object o) { - try { - return JSON_MAPPER - .setSerializationInclusion(JsonInclude.Include.ALWAYS) - .writerWithDefaultPrettyPrinter() - .writeValueAsString(o); - } catch (IOException e) { - return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode()); - } - } -} diff --git a/src/main/java/com/courier/api/core/RequestOptions.java b/src/main/java/com/courier/api/core/RequestOptions.java deleted file mode 100644 index bdc8008c..00000000 --- a/src/main/java/com/courier/api/core/RequestOptions.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.TimeUnit; - -public final class RequestOptions { - private final String authorizationToken; - - private final Optional timeout; - - private final TimeUnit timeoutTimeUnit; - - private RequestOptions(String authorizationToken, Optional timeout, TimeUnit timeoutTimeUnit) { - this.authorizationToken = authorizationToken; - this.timeout = timeout; - this.timeoutTimeUnit = timeoutTimeUnit; - } - - public Optional getTimeout() { - return timeout; - } - - public TimeUnit getTimeoutTimeUnit() { - return timeoutTimeUnit; - } - - public Map getHeaders() { - Map headers = new HashMap<>(); - if (this.authorizationToken != null) { - headers.put("Authorization", "Bearer " + this.authorizationToken); - } - return headers; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Builder { - private String authorizationToken = null; - - private Optional timeout = Optional.empty(); - - private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS; - - public Builder authorizationToken(String authorizationToken) { - this.authorizationToken = authorizationToken; - return this; - } - - public Builder timeout(Integer timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) { - this.timeout = Optional.of(timeout); - this.timeoutTimeUnit = timeoutTimeUnit; - return this; - } - - public RequestOptions build() { - return new RequestOptions(authorizationToken, timeout, timeoutTimeUnit); - } - } -} diff --git a/src/main/java/com/courier/api/core/RetryInterceptor.java b/src/main/java/com/courier/api/core/RetryInterceptor.java deleted file mode 100644 index e8c27c5f..00000000 --- a/src/main/java/com/courier/api/core/RetryInterceptor.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import java.io.IOException; -import java.time.Duration; -import java.util.Optional; -import java.util.Random; -import okhttp3.Interceptor; -import okhttp3.Response; - -public class RetryInterceptor implements Interceptor { - - private static final Duration ONE_SECOND = Duration.ofSeconds(1); - private final ExponentialBackoff backoff; - private final Random random = new Random(); - - public RetryInterceptor(int maxRetries) { - this.backoff = new ExponentialBackoff(maxRetries); - } - - @Override - public Response intercept(Chain chain) throws IOException { - Response response = chain.proceed(chain.request()); - - if (shouldRetry(response.code())) { - return retryChain(response, chain); - } - - return response; - } - - private Response retryChain(Response response, Chain chain) throws IOException { - Optional nextBackoff = this.backoff.nextBackoff(); - while (nextBackoff.isPresent()) { - try { - Thread.sleep(nextBackoff.get().toMillis()); - } catch (InterruptedException e) { - throw new IOException("Interrupted while trying request", e); - } - response.close(); - response = chain.proceed(chain.request()); - if (shouldRetry(response.code())) { - nextBackoff = this.backoff.nextBackoff(); - } else { - return response; - } - } - - return response; - } - - private static boolean shouldRetry(int statusCode) { - return statusCode == 408 || statusCode == 409 || statusCode == 429 || statusCode >= 500; - } - - private final class ExponentialBackoff { - - private final int maxNumRetries; - - private int retryNumber = 0; - - ExponentialBackoff(int maxNumRetries) { - this.maxNumRetries = maxNumRetries; - } - - public Optional nextBackoff() { - retryNumber += 1; - if (retryNumber > maxNumRetries) { - return Optional.empty(); - } - - int upperBound = (int) Math.pow(2, retryNumber); - return Optional.of(ONE_SECOND.multipliedBy(random.nextInt(upperBound))); - } - } -} diff --git a/src/main/java/com/courier/api/core/Stream.java b/src/main/java/com/courier/api/core/Stream.java deleted file mode 100644 index d5e9ef87..00000000 --- a/src/main/java/com/courier/api/core/Stream.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import java.io.Reader; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Scanner; - -/** - * The {@code Stream} class implmenets {@link Iterable} to provide a simple mechanism for reading and parsing - * objects of a given type from data streamed via a {@link Reader} using a specified delimiter. - *

- * {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a - * {@code Scanner} to block during iteration if the next object is not available. - * - * @param The type of objects in the stream. - */ -public final class Stream implements Iterable { - /** - * The {@link Class} of the objects in the stream. - */ - private final Class valueType; - /** - * The {@link Scanner} used for reading from the input stream and blocking when neede during iteration. - */ - private final Scanner scanner; - - /** - * Constructs a new {@code Stream} with the specified value type, reader, and delimiter. - * - * @param valueType The class of the objects in the stream. - * @param reader The reader that provides the streamed data. - * @param delimiter The delimiter used to separate elements in the stream. - */ - public Stream(Class valueType, Reader reader, String delimiter) { - this.scanner = new Scanner(reader).useDelimiter(delimiter); - this.valueType = valueType; - } - - /** - * Returns an iterator over the elements in this stream that blocks during iteration when the next object is - * not yet available. - * - * @return An iterator that can be used to traverse the elements in the stream. - */ - @Override - public Iterator iterator() { - return new Iterator() { - /** - * Returns {@code true} if there are more elements in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return {@code true} if there are more elements, {@code false} otherwise. - */ - @Override - public boolean hasNext() { - return scanner.hasNext(); - } - - /** - * Returns the next element in the stream. - *

- * Will block and wait for input if the stream has not ended and the next object is not yet available. - * - * @return The next element in the stream. - * @throws NoSuchElementException If there are no more elements in the stream. - */ - @Override - public T next() { - if (!scanner.hasNext()) { - throw new NoSuchElementException(); - } else { - try { - T parsedResponse = ObjectMappers.JSON_MAPPER.readValue( - scanner.next().trim(), valueType); - return parsedResponse; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - /** - * Removing elements from {@code Stream} is not supported. - * - * @throws UnsupportedOperationException Always, as removal is not supported. - */ - @Override - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } -} diff --git a/src/main/java/com/courier/api/core/Suppliers.java b/src/main/java/com/courier/api/core/Suppliers.java deleted file mode 100644 index 9ce4482f..00000000 --- a/src/main/java/com/courier/api/core/Suppliers.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.core; - -import java.util.Objects; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Supplier; - -public final class Suppliers { - private Suppliers() {} - - public static Supplier memoize(Supplier delegate) { - AtomicReference value = new AtomicReference<>(); - return () -> { - T val = value.get(); - if (val == null) { - val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); - } - return val; - }; - } -} diff --git a/src/main/java/com/courier/api/requests/SendMessageRequest.java b/src/main/java/com/courier/api/requests/SendMessageRequest.java deleted file mode 100644 index 5d8c969b..00000000 --- a/src/main/java/com/courier/api/requests/SendMessageRequest.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.send.types.Message; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendMessageRequest.Builder.class) -public final class SendMessageRequest { - private final Message message; - - private final Map additionalProperties; - - private SendMessageRequest(Message message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return Defines the message to be delivered - */ - @JsonProperty("message") - public Message getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendMessageRequest && equalTo((SendMessageRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendMessageRequest other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(Message message); - - Builder from(SendMessageRequest other); - } - - public interface _FinalStage { - SendMessageRequest build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private Message message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendMessageRequest other) { - message(other.getMessage()); - return this; - } - - /** - *

Defines the message to be delivered

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(Message message) { - this.message = message; - return this; - } - - @java.lang.Override - public SendMessageRequest build() { - return new SendMessageRequest(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/AudiencesClient.java b/src/main/java/com/courier/api/resources/audiences/AudiencesClient.java deleted file mode 100644 index 08c6cf2e..00000000 --- a/src/main/java/com/courier/api/resources/audiences/AudiencesClient.java +++ /dev/null @@ -1,291 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.audiences.requests.AudienceMembersListParams; -import com.courier.api.resources.audiences.requests.AudienceUpdateParams; -import com.courier.api.resources.audiences.requests.AudiencesListParams; -import com.courier.api.resources.audiences.types.Audience; -import com.courier.api.resources.audiences.types.AudienceListResponse; -import com.courier.api.resources.audiences.types.AudienceMemberListResponse; -import com.courier.api.resources.audiences.types.AudienceUpdateResponse; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.types.BadRequest; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class AudiencesClient { - protected final ClientOptions clientOptions; - - public AudiencesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns the specified audience by id. - */ - public Audience get(String audienceId) { - return get(audienceId, null); - } - - /** - * Returns the specified audience by id. - */ - public Audience get(String audienceId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audiences") - .addPathSegment(audienceId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Audience.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Creates or updates audience. - */ - public AudienceUpdateResponse update(String audienceId) { - return update(audienceId, AudienceUpdateParams.builder().build()); - } - - /** - * Creates or updates audience. - */ - public AudienceUpdateResponse update(String audienceId, AudienceUpdateParams request) { - return update(audienceId, request, null); - } - - /** - * Creates or updates audience. - */ - public AudienceUpdateResponse update( - String audienceId, AudienceUpdateParams request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audiences") - .addPathSegment(audienceId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AudienceUpdateResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Deletes the specified audience. - */ - public void delete(String audienceId) { - delete(audienceId, null); - } - - /** - * Deletes the specified audience. - */ - public void delete(String audienceId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audiences") - .addPathSegment(audienceId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get list of members of an audience. - */ - public AudienceMemberListResponse listMembers(String audienceId) { - return listMembers(audienceId, AudienceMembersListParams.builder().build()); - } - - /** - * Get list of members of an audience. - */ - public AudienceMemberListResponse listMembers(String audienceId, AudienceMembersListParams request) { - return listMembers(audienceId, request, null); - } - - /** - * Get list of members of an audience. - */ - public AudienceMemberListResponse listMembers( - String audienceId, AudienceMembersListParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audiences") - .addPathSegment(audienceId) - .addPathSegments("members"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AudienceMemberListResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get the audiences associated with the authorization token. - */ - public AudienceListResponse listAudiences() { - return listAudiences(AudiencesListParams.builder().build()); - } - - /** - * Get the audiences associated with the authorization token. - */ - public AudienceListResponse listAudiences(AudiencesListParams request) { - return listAudiences(request, null); - } - - /** - * Get the audiences associated with the authorization token. - */ - public AudienceListResponse listAudiences(AudiencesListParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audiences"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AudienceListResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/requests/AudienceMembersListParams.java b/src/main/java/com/courier/api/resources/audiences/requests/AudienceMembersListParams.java deleted file mode 100644 index 35109806..00000000 --- a/src/main/java/com/courier/api/resources/audiences/requests/AudienceMembersListParams.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceMembersListParams.Builder.class) -public final class AudienceMembersListParams { - private final Optional cursor; - - private final Map additionalProperties; - - private AudienceMembersListParams(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of members - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceMembersListParams && equalTo((AudienceMembersListParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceMembersListParams other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AudienceMembersListParams other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public AudienceMembersListParams build() { - return new AudienceMembersListParams(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/requests/AudienceUpdateParams.java b/src/main/java/com/courier/api/resources/audiences/requests/AudienceUpdateParams.java deleted file mode 100644 index 75b0b326..00000000 --- a/src/main/java/com/courier/api/resources/audiences/requests/AudienceUpdateParams.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.audiences.types.Filter; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceUpdateParams.Builder.class) -public final class AudienceUpdateParams { - private final Optional name; - - private final Optional description; - - private final Optional filter; - - private final Map additionalProperties; - - private AudienceUpdateParams( - Optional name, - Optional description, - Optional filter, - Map additionalProperties) { - this.name = name; - this.description = description; - this.filter = filter; - this.additionalProperties = additionalProperties; - } - - /** - * @return The name of the audience - */ - @JsonProperty("name") - public Optional getName() { - return name; - } - - /** - * @return A description of the audience - */ - @JsonProperty("description") - public Optional getDescription() { - return description; - } - - @JsonProperty("filter") - public Optional getFilter() { - return filter; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceUpdateParams && equalTo((AudienceUpdateParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceUpdateParams other) { - return name.equals(other.name) && description.equals(other.description) && filter.equals(other.filter); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.name, this.description, this.filter); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional name = Optional.empty(); - - private Optional description = Optional.empty(); - - private Optional filter = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AudienceUpdateParams other) { - name(other.getName()); - description(other.getDescription()); - filter(other.getFilter()); - return this; - } - - @JsonSetter(value = "name", nulls = Nulls.SKIP) - public Builder name(Optional name) { - this.name = name; - return this; - } - - public Builder name(String name) { - this.name = Optional.of(name); - return this; - } - - @JsonSetter(value = "description", nulls = Nulls.SKIP) - public Builder description(Optional description) { - this.description = description; - return this; - } - - public Builder description(String description) { - this.description = Optional.of(description); - return this; - } - - @JsonSetter(value = "filter", nulls = Nulls.SKIP) - public Builder filter(Optional filter) { - this.filter = filter; - return this; - } - - public Builder filter(Filter filter) { - this.filter = Optional.of(filter); - return this; - } - - public AudienceUpdateParams build() { - return new AudienceUpdateParams(name, description, filter, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/requests/AudiencesListParams.java b/src/main/java/com/courier/api/resources/audiences/requests/AudiencesListParams.java deleted file mode 100644 index 0e5dc643..00000000 --- a/src/main/java/com/courier/api/resources/audiences/requests/AudiencesListParams.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudiencesListParams.Builder.class) -public final class AudiencesListParams { - private final Optional cursor; - - private final Map additionalProperties; - - private AudiencesListParams(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of audiences - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudiencesListParams && equalTo((AudiencesListParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudiencesListParams other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AudiencesListParams other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public AudiencesListParams build() { - return new AudiencesListParams(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/Audience.java b/src/main/java/com/courier/api/resources/audiences/types/Audience.java deleted file mode 100644 index 2daeebea..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/Audience.java +++ /dev/null @@ -1,245 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Audience.Builder.class) -public final class Audience { - private final String id; - - private final String name; - - private final String description; - - private final Filter filter; - - private final String createdAt; - - private final String updatedAt; - - private final Map additionalProperties; - - private Audience( - String id, - String name, - String description, - Filter filter, - String createdAt, - String updatedAt, - Map additionalProperties) { - this.id = id; - this.name = name; - this.description = description; - this.filter = filter; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier representing the audience_id - */ - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * @return The name of the audience - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return A description of the audience - */ - @JsonProperty("description") - public String getDescription() { - return description; - } - - @JsonProperty("filter") - public Filter getFilter() { - return filter; - } - - @JsonProperty("created_at") - public String getCreatedAt() { - return createdAt; - } - - @JsonProperty("updated_at") - public String getUpdatedAt() { - return updatedAt; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Audience && equalTo((Audience) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Audience other) { - return id.equals(other.id) - && name.equals(other.name) - && description.equals(other.description) - && filter.equals(other.filter) - && createdAt.equals(other.createdAt) - && updatedAt.equals(other.updatedAt); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.name, this.description, this.filter, this.createdAt, this.updatedAt); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - NameStage id(String id); - - Builder from(Audience other); - } - - public interface NameStage { - DescriptionStage name(String name); - } - - public interface DescriptionStage { - FilterStage description(String description); - } - - public interface FilterStage { - CreatedAtStage filter(Filter filter); - } - - public interface CreatedAtStage { - UpdatedAtStage createdAt(String createdAt); - } - - public interface UpdatedAtStage { - _FinalStage updatedAt(String updatedAt); - } - - public interface _FinalStage { - Audience build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, NameStage, DescriptionStage, FilterStage, CreatedAtStage, UpdatedAtStage, _FinalStage { - private String id; - - private String name; - - private String description; - - private Filter filter; - - private String createdAt; - - private String updatedAt; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Audience other) { - id(other.getId()); - name(other.getName()); - description(other.getDescription()); - filter(other.getFilter()); - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - return this; - } - - /** - *

A unique identifier representing the audience_id

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(String id) { - this.id = id; - return this; - } - - /** - *

The name of the audience

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public DescriptionStage name(String name) { - this.name = name; - return this; - } - - /** - *

A description of the audience

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("description") - public FilterStage description(String description) { - this.description = description; - return this; - } - - @java.lang.Override - @JsonSetter("filter") - public CreatedAtStage filter(Filter filter) { - this.filter = filter; - return this; - } - - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(String createdAt) { - this.createdAt = createdAt; - return this; - } - - @java.lang.Override - @JsonSetter("updated_at") - public _FinalStage updatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @java.lang.Override - public Audience build() { - return new Audience(id, name, description, filter, createdAt, updatedAt, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/AudienceListResponse.java b/src/main/java/com/courier/api/resources/audiences/types/AudienceListResponse.java deleted file mode 100644 index b59d79b6..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/AudienceListResponse.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceListResponse.Builder.class) -public final class AudienceListResponse { - private final List items; - - private final Paging paging; - - private final Map additionalProperties; - - private AudienceListResponse(List items, Paging paging, Map additionalProperties) { - this.items = items; - this.paging = paging; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public List getItems() { - return items; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceListResponse && equalTo((AudienceListResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceListResponse other) { - return items.equals(other.items) && paging.equals(other.paging); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items, this.paging); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(AudienceListResponse other); - } - - public interface _FinalStage { - AudienceListResponse build(); - - _FinalStage items(List items); - - _FinalStage addItems(Audience items); - - _FinalStage addAllItems(List items); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceListResponse other) { - items(other.getItems()); - paging(other.getPaging()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllItems(List items) { - this.items.addAll(items); - return this; - } - - @java.lang.Override - public _FinalStage addItems(Audience items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - @java.lang.Override - public AudienceListResponse build() { - return new AudienceListResponse(items, paging, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/AudienceMember.java b/src/main/java/com/courier/api/resources/audiences/types/AudienceMember.java deleted file mode 100644 index 7c1acd81..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/AudienceMember.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceMember.Builder.class) -public final class AudienceMember { - private final String addedAt; - - private final String audienceId; - - private final int audienceVersion; - - private final String memberId; - - private final String reason; - - private final Map additionalProperties; - - private AudienceMember( - String addedAt, - String audienceId, - int audienceVersion, - String memberId, - String reason, - Map additionalProperties) { - this.addedAt = addedAt; - this.audienceId = audienceId; - this.audienceVersion = audienceVersion; - this.memberId = memberId; - this.reason = reason; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("added_at") - public String getAddedAt() { - return addedAt; - } - - @JsonProperty("audience_id") - public String getAudienceId() { - return audienceId; - } - - @JsonProperty("audience_version") - public int getAudienceVersion() { - return audienceVersion; - } - - @JsonProperty("member_id") - public String getMemberId() { - return memberId; - } - - @JsonProperty("reason") - public String getReason() { - return reason; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceMember && equalTo((AudienceMember) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceMember other) { - return addedAt.equals(other.addedAt) - && audienceId.equals(other.audienceId) - && audienceVersion == other.audienceVersion - && memberId.equals(other.memberId) - && reason.equals(other.reason); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.addedAt, this.audienceId, this.audienceVersion, this.memberId, this.reason); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AddedAtStage builder() { - return new Builder(); - } - - public interface AddedAtStage { - AudienceIdStage addedAt(String addedAt); - - Builder from(AudienceMember other); - } - - public interface AudienceIdStage { - AudienceVersionStage audienceId(String audienceId); - } - - public interface AudienceVersionStage { - MemberIdStage audienceVersion(int audienceVersion); - } - - public interface MemberIdStage { - ReasonStage memberId(String memberId); - } - - public interface ReasonStage { - _FinalStage reason(String reason); - } - - public interface _FinalStage { - AudienceMember build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements AddedAtStage, AudienceIdStage, AudienceVersionStage, MemberIdStage, ReasonStage, _FinalStage { - private String addedAt; - - private String audienceId; - - private int audienceVersion; - - private String memberId; - - private String reason; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceMember other) { - addedAt(other.getAddedAt()); - audienceId(other.getAudienceId()); - audienceVersion(other.getAudienceVersion()); - memberId(other.getMemberId()); - reason(other.getReason()); - return this; - } - - @java.lang.Override - @JsonSetter("added_at") - public AudienceIdStage addedAt(String addedAt) { - this.addedAt = addedAt; - return this; - } - - @java.lang.Override - @JsonSetter("audience_id") - public AudienceVersionStage audienceId(String audienceId) { - this.audienceId = audienceId; - return this; - } - - @java.lang.Override - @JsonSetter("audience_version") - public MemberIdStage audienceVersion(int audienceVersion) { - this.audienceVersion = audienceVersion; - return this; - } - - @java.lang.Override - @JsonSetter("member_id") - public ReasonStage memberId(String memberId) { - this.memberId = memberId; - return this; - } - - @java.lang.Override - @JsonSetter("reason") - public _FinalStage reason(String reason) { - this.reason = reason; - return this; - } - - @java.lang.Override - public AudienceMember build() { - return new AudienceMember(addedAt, audienceId, audienceVersion, memberId, reason, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/AudienceMemberGetResponse.java b/src/main/java/com/courier/api/resources/audiences/types/AudienceMemberGetResponse.java deleted file mode 100644 index f23af61d..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/AudienceMemberGetResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceMemberGetResponse.Builder.class) -public final class AudienceMemberGetResponse { - private final AudienceMember audienceMember; - - private final Map additionalProperties; - - private AudienceMemberGetResponse(AudienceMember audienceMember, Map additionalProperties) { - this.audienceMember = audienceMember; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("audienceMember") - public AudienceMember getAudienceMember() { - return audienceMember; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceMemberGetResponse && equalTo((AudienceMemberGetResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceMemberGetResponse other) { - return audienceMember.equals(other.audienceMember); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.audienceMember); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AudienceMemberStage builder() { - return new Builder(); - } - - public interface AudienceMemberStage { - _FinalStage audienceMember(AudienceMember audienceMember); - - Builder from(AudienceMemberGetResponse other); - } - - public interface _FinalStage { - AudienceMemberGetResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AudienceMemberStage, _FinalStage { - private AudienceMember audienceMember; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceMemberGetResponse other) { - audienceMember(other.getAudienceMember()); - return this; - } - - @java.lang.Override - @JsonSetter("audienceMember") - public _FinalStage audienceMember(AudienceMember audienceMember) { - this.audienceMember = audienceMember; - return this; - } - - @java.lang.Override - public AudienceMemberGetResponse build() { - return new AudienceMemberGetResponse(audienceMember, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/AudienceMemberListResponse.java b/src/main/java/com/courier/api/resources/audiences/types/AudienceMemberListResponse.java deleted file mode 100644 index 309387e9..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/AudienceMemberListResponse.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceMemberListResponse.Builder.class) -public final class AudienceMemberListResponse { - private final List items; - - private final Paging paging; - - private final Map additionalProperties; - - private AudienceMemberListResponse( - List items, Paging paging, Map additionalProperties) { - this.items = items; - this.paging = paging; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public List getItems() { - return items; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceMemberListResponse && equalTo((AudienceMemberListResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceMemberListResponse other) { - return items.equals(other.items) && paging.equals(other.paging); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items, this.paging); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(AudienceMemberListResponse other); - } - - public interface _FinalStage { - AudienceMemberListResponse build(); - - _FinalStage items(List items); - - _FinalStage addItems(AudienceMember items); - - _FinalStage addAllItems(List items); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceMemberListResponse other) { - items(other.getItems()); - paging(other.getPaging()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllItems(List items) { - this.items.addAll(items); - return this; - } - - @java.lang.Override - public _FinalStage addItems(AudienceMember items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - @java.lang.Override - public AudienceMemberListResponse build() { - return new AudienceMemberListResponse(items, paging, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/AudienceUpdateResponse.java b/src/main/java/com/courier/api/resources/audiences/types/AudienceUpdateResponse.java deleted file mode 100644 index c13d2a77..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/AudienceUpdateResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceUpdateResponse.Builder.class) -public final class AudienceUpdateResponse { - private final Audience audience; - - private final Map additionalProperties; - - private AudienceUpdateResponse(Audience audience, Map additionalProperties) { - this.audience = audience; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("audience") - public Audience getAudience() { - return audience; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceUpdateResponse && equalTo((AudienceUpdateResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceUpdateResponse other) { - return audience.equals(other.audience); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.audience); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AudienceStage builder() { - return new Builder(); - } - - public interface AudienceStage { - _FinalStage audience(Audience audience); - - Builder from(AudienceUpdateResponse other); - } - - public interface _FinalStage { - AudienceUpdateResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AudienceStage, _FinalStage { - private Audience audience; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceUpdateResponse other) { - audience(other.getAudience()); - return this; - } - - @java.lang.Override - @JsonSetter("audience") - public _FinalStage audience(Audience audience) { - this.audience = audience; - return this; - } - - @java.lang.Override - public AudienceUpdateResponse build() { - return new AudienceUpdateResponse(audience, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/BaseFilterConfig.java b/src/main/java/com/courier/api/resources/audiences/types/BaseFilterConfig.java deleted file mode 100644 index 2572c54e..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/BaseFilterConfig.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseFilterConfig.Builder.class) -public final class BaseFilterConfig implements IBaseFilterConfig { - private final Operator operator; - - private final Map additionalProperties; - - private BaseFilterConfig(Operator operator, Map additionalProperties) { - this.operator = operator; - this.additionalProperties = additionalProperties; - } - - /** - * @return The operator to use for filtering - */ - @JsonProperty("operator") - @java.lang.Override - public Operator getOperator() { - return operator; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseFilterConfig && equalTo((BaseFilterConfig) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseFilterConfig other) { - return operator.equals(other.operator); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.operator); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static OperatorStage builder() { - return new Builder(); - } - - public interface OperatorStage { - _FinalStage operator(Operator operator); - - Builder from(BaseFilterConfig other); - } - - public interface _FinalStage { - BaseFilterConfig build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements OperatorStage, _FinalStage { - private Operator operator; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BaseFilterConfig other) { - operator(other.getOperator()); - return this; - } - - /** - *

The operator to use for filtering

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("operator") - public _FinalStage operator(Operator operator) { - this.operator = operator; - return this; - } - - @java.lang.Override - public BaseFilterConfig build() { - return new BaseFilterConfig(operator, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/ComparisonOperator.java b/src/main/java/com/courier/api/resources/audiences/types/ComparisonOperator.java deleted file mode 100644 index d13e5c21..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/ComparisonOperator.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ComparisonOperator { - ENDS_WITH("ENDS_WITH"), - - EQ("EQ"), - - EXISTS("EXISTS"), - - GT("GT"), - - GTE("GTE"), - - INCLUDES("INCLUDES"), - - IS_AFTER("IS_AFTER"), - - IS_BEFORE("IS_BEFORE"), - - LT("LT"), - - LTE("LTE"), - - NEQ("NEQ"), - - OMIT("OMIT"), - - STARTS_WITH("STARTS_WITH"); - - private final String value; - - ComparisonOperator(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/Filter.java b/src/main/java/com/courier/api/resources/audiences/types/Filter.java deleted file mode 100644 index 7218e8de..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/Filter.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Filter.Deserializer.class) -public final class Filter { - private final Object value; - - private final int type; - - private Filter(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SingleFilterConfig) this.value); - } else if (this.type == 1) { - return visitor.visit((NestedFilterConfig) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Filter && equalTo((Filter) other); - } - - private boolean equalTo(Filter other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Filter of(SingleFilterConfig value) { - return new Filter(value, 0); - } - - public static Filter of(NestedFilterConfig value) { - return new Filter(value, 1); - } - - public interface Visitor { - T visit(SingleFilterConfig value); - - T visit(NestedFilterConfig value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Filter.class); - } - - @java.lang.Override - public Filter deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SingleFilterConfig.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, NestedFilterConfig.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/FilterConfig.java b/src/main/java/com/courier/api/resources/audiences/types/FilterConfig.java deleted file mode 100644 index 4a0b7542..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/FilterConfig.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = FilterConfig.Deserializer.class) -public final class FilterConfig { - private final Object value; - - private final int type; - - private FilterConfig(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SingleFilterConfig) this.value); - } else if (this.type == 1) { - return visitor.visit((NestedFilterConfig) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof FilterConfig && equalTo((FilterConfig) other); - } - - private boolean equalTo(FilterConfig other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static FilterConfig of(SingleFilterConfig value) { - return new FilterConfig(value, 0); - } - - public static FilterConfig of(NestedFilterConfig value) { - return new FilterConfig(value, 1); - } - - public interface Visitor { - T visit(SingleFilterConfig value); - - T visit(NestedFilterConfig value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(FilterConfig.class); - } - - @java.lang.Override - public FilterConfig deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SingleFilterConfig.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, NestedFilterConfig.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/IBaseFilterConfig.java b/src/main/java/com/courier/api/resources/audiences/types/IBaseFilterConfig.java deleted file mode 100644 index 5c12753e..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/IBaseFilterConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -public interface IBaseFilterConfig { - Operator getOperator(); -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/LogicalOperator.java b/src/main/java/com/courier/api/resources/audiences/types/LogicalOperator.java deleted file mode 100644 index c718ba09..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/LogicalOperator.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum LogicalOperator { - AND("AND"), - - OR("OR"); - - private final String value; - - LogicalOperator(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/NestedFilterConfig.java b/src/main/java/com/courier/api/resources/audiences/types/NestedFilterConfig.java deleted file mode 100644 index 493bf017..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/NestedFilterConfig.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NestedFilterConfig.Builder.class) -public final class NestedFilterConfig implements IBaseFilterConfig { - private final Operator operator; - - private final List rules; - - private final Map additionalProperties; - - private NestedFilterConfig(Operator operator, List rules, Map additionalProperties) { - this.operator = operator; - this.rules = rules; - this.additionalProperties = additionalProperties; - } - - /** - * @return The operator to use for filtering - */ - @JsonProperty("operator") - @java.lang.Override - public Operator getOperator() { - return operator; - } - - @JsonProperty("rules") - public List getRules() { - return rules; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NestedFilterConfig && equalTo((NestedFilterConfig) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NestedFilterConfig other) { - return operator.equals(other.operator) && rules.equals(other.rules); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.operator, this.rules); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static OperatorStage builder() { - return new Builder(); - } - - public interface OperatorStage { - _FinalStage operator(Operator operator); - - Builder from(NestedFilterConfig other); - } - - public interface _FinalStage { - NestedFilterConfig build(); - - _FinalStage rules(List rules); - - _FinalStage addRules(FilterConfig rules); - - _FinalStage addAllRules(List rules); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements OperatorStage, _FinalStage { - private Operator operator; - - private List rules = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NestedFilterConfig other) { - operator(other.getOperator()); - rules(other.getRules()); - return this; - } - - /** - *

The operator to use for filtering

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("operator") - public _FinalStage operator(Operator operator) { - this.operator = operator; - return this; - } - - @java.lang.Override - public _FinalStage addAllRules(List rules) { - this.rules.addAll(rules); - return this; - } - - @java.lang.Override - public _FinalStage addRules(FilterConfig rules) { - this.rules.add(rules); - return this; - } - - @java.lang.Override - @JsonSetter(value = "rules", nulls = Nulls.SKIP) - public _FinalStage rules(List rules) { - this.rules.clear(); - this.rules.addAll(rules); - return this; - } - - @java.lang.Override - public NestedFilterConfig build() { - return new NestedFilterConfig(operator, rules, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/Operator.java b/src/main/java/com/courier/api/resources/audiences/types/Operator.java deleted file mode 100644 index 3dbeaa34..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/Operator.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Operator.Deserializer.class) -public final class Operator { - private final Object value; - - private final int type; - - private Operator(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ComparisonOperator) this.value); - } else if (this.type == 1) { - return visitor.visit((LogicalOperator) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Operator && equalTo((Operator) other); - } - - private boolean equalTo(Operator other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Operator of(ComparisonOperator value) { - return new Operator(value, 0); - } - - public static Operator of(LogicalOperator value) { - return new Operator(value, 1); - } - - public interface Visitor { - T visit(ComparisonOperator value); - - T visit(LogicalOperator value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Operator.class); - } - - @java.lang.Override - public Operator deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ComparisonOperator.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, LogicalOperator.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/audiences/types/SingleFilterConfig.java b/src/main/java/com/courier/api/resources/audiences/types/SingleFilterConfig.java deleted file mode 100644 index dacc6d0e..00000000 --- a/src/main/java/com/courier/api/resources/audiences/types/SingleFilterConfig.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.audiences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SingleFilterConfig.Builder.class) -public final class SingleFilterConfig implements IBaseFilterConfig { - private final Operator operator; - - private final String value; - - private final String path; - - private final Map additionalProperties; - - private SingleFilterConfig(Operator operator, String value, String path, Map additionalProperties) { - this.operator = operator; - this.value = value; - this.path = path; - this.additionalProperties = additionalProperties; - } - - /** - * @return The operator to use for filtering - */ - @JsonProperty("operator") - @java.lang.Override - public Operator getOperator() { - return operator; - } - - /** - * @return The value to use for filtering - */ - @JsonProperty("value") - public String getValue() { - return value; - } - - /** - * @return The attribe name from profile whose value will be operated against the filter value - */ - @JsonProperty("path") - public String getPath() { - return path; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SingleFilterConfig && equalTo((SingleFilterConfig) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SingleFilterConfig other) { - return operator.equals(other.operator) && value.equals(other.value) && path.equals(other.path); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.operator, this.value, this.path); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static OperatorStage builder() { - return new Builder(); - } - - public interface OperatorStage { - ValueStage operator(Operator operator); - - Builder from(SingleFilterConfig other); - } - - public interface ValueStage { - PathStage value(String value); - } - - public interface PathStage { - _FinalStage path(String path); - } - - public interface _FinalStage { - SingleFilterConfig build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements OperatorStage, ValueStage, PathStage, _FinalStage { - private Operator operator; - - private String value; - - private String path; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SingleFilterConfig other) { - operator(other.getOperator()); - value(other.getValue()); - path(other.getPath()); - return this; - } - - /** - *

The operator to use for filtering

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("operator") - public ValueStage operator(Operator operator) { - this.operator = operator; - return this; - } - - /** - *

The value to use for filtering

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("value") - public PathStage value(String value) { - this.value = value; - return this; - } - - /** - *

The attribe name from profile whose value will be operated against the filter value

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("path") - public _FinalStage path(String path) { - this.path = path; - return this; - } - - @java.lang.Override - public SingleFilterConfig build() { - return new SingleFilterConfig(operator, value, path, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/AuditEventsClient.java b/src/main/java/com/courier/api/resources/auditevents/AuditEventsClient.java deleted file mode 100644 index e67913be..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/AuditEventsClient.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.auditevents.requests.ListAuditEventsRequest; -import com.courier.api.resources.auditevents.types.AuditEvent; -import com.courier.api.resources.auditevents.types.ListAuditEventsResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class AuditEventsClient { - protected final ClientOptions clientOptions; - - public AuditEventsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Fetch the list of audit events - */ - public ListAuditEventsResponse list() { - return list(ListAuditEventsRequest.builder().build()); - } - - /** - * Fetch the list of audit events - */ - public ListAuditEventsResponse list(ListAuditEventsRequest request) { - return list(request, null); - } - - /** - * Fetch the list of audit events - */ - public ListAuditEventsResponse list(ListAuditEventsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audit-events"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListAuditEventsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Fetch a specific audit event by ID. - */ - public AuditEvent get(String auditEventId) { - return get(auditEventId, null); - } - - /** - * Fetch a specific audit event by ID. - */ - public AuditEvent get(String auditEventId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("audit-events") - .addPathSegment(auditEventId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AuditEvent.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/requests/ListAuditEventsRequest.java b/src/main/java/com/courier/api/resources/auditevents/requests/ListAuditEventsRequest.java deleted file mode 100644 index df4384e6..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/requests/ListAuditEventsRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListAuditEventsRequest.Builder.class) -public final class ListAuditEventsRequest { - private final Optional cursor; - - private final Map additionalProperties; - - private ListAuditEventsRequest(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of audit events. - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListAuditEventsRequest && equalTo((ListAuditEventsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListAuditEventsRequest other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListAuditEventsRequest other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListAuditEventsRequest build() { - return new ListAuditEventsRequest(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/types/Actor.java b/src/main/java/com/courier/api/resources/auditevents/types/Actor.java deleted file mode 100644 index 1f714ce8..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/types/Actor.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Actor.Builder.class) -public final class Actor { - private final Optional id; - - private final Optional email; - - private final Map additionalProperties; - - private Actor(Optional id, Optional email, Map additionalProperties) { - this.id = id; - this.email = email; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public Optional getId() { - return id; - } - - @JsonProperty("email") - public Optional getEmail() { - return email; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Actor && equalTo((Actor) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Actor other) { - return id.equals(other.id) && email.equals(other.email); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.email); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional email = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Actor other) { - id(other.getId()); - email(other.getEmail()); - return this; - } - - @JsonSetter(value = "id", nulls = Nulls.SKIP) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter(value = "email", nulls = Nulls.SKIP) - public Builder email(Optional email) { - this.email = email; - return this; - } - - public Builder email(String email) { - this.email = Optional.of(email); - return this; - } - - public Actor build() { - return new Actor(id, email, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/types/AuditEvent.java b/src/main/java/com/courier/api/resources/auditevents/types/AuditEvent.java deleted file mode 100644 index 0bad1164..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/types/AuditEvent.java +++ /dev/null @@ -1,238 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AuditEvent.Builder.class) -public final class AuditEvent { - private final Optional actor; - - private final Optional target; - - private final String auditEventId; - - private final String source; - - private final String timestamp; - - private final String type; - - private final Map additionalProperties; - - private AuditEvent( - Optional actor, - Optional target, - String auditEventId, - String source, - String timestamp, - String type, - Map additionalProperties) { - this.actor = actor; - this.target = target; - this.auditEventId = auditEventId; - this.source = source; - this.timestamp = timestamp; - this.type = type; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("actor") - public Optional getActor() { - return actor; - } - - @JsonProperty("target") - public Optional getTarget() { - return target; - } - - @JsonProperty("auditEventId") - public String getAuditEventId() { - return auditEventId; - } - - @JsonProperty("source") - public String getSource() { - return source; - } - - @JsonProperty("timestamp") - public String getTimestamp() { - return timestamp; - } - - @JsonProperty("type") - public String getType() { - return type; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AuditEvent && equalTo((AuditEvent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AuditEvent other) { - return actor.equals(other.actor) - && target.equals(other.target) - && auditEventId.equals(other.auditEventId) - && source.equals(other.source) - && timestamp.equals(other.timestamp) - && type.equals(other.type); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.actor, this.target, this.auditEventId, this.source, this.timestamp, this.type); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AuditEventIdStage builder() { - return new Builder(); - } - - public interface AuditEventIdStage { - SourceStage auditEventId(String auditEventId); - - Builder from(AuditEvent other); - } - - public interface SourceStage { - TimestampStage source(String source); - } - - public interface TimestampStage { - TypeStage timestamp(String timestamp); - } - - public interface TypeStage { - _FinalStage type(String type); - } - - public interface _FinalStage { - AuditEvent build(); - - _FinalStage actor(Optional actor); - - _FinalStage actor(Actor actor); - - _FinalStage target(Optional target); - - _FinalStage target(Target target); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements AuditEventIdStage, SourceStage, TimestampStage, TypeStage, _FinalStage { - private String auditEventId; - - private String source; - - private String timestamp; - - private String type; - - private Optional target = Optional.empty(); - - private Optional actor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AuditEvent other) { - actor(other.getActor()); - target(other.getTarget()); - auditEventId(other.getAuditEventId()); - source(other.getSource()); - timestamp(other.getTimestamp()); - type(other.getType()); - return this; - } - - @java.lang.Override - @JsonSetter("auditEventId") - public SourceStage auditEventId(String auditEventId) { - this.auditEventId = auditEventId; - return this; - } - - @java.lang.Override - @JsonSetter("source") - public TimestampStage source(String source) { - this.source = source; - return this; - } - - @java.lang.Override - @JsonSetter("timestamp") - public TypeStage timestamp(String timestamp) { - this.timestamp = timestamp; - return this; - } - - @java.lang.Override - @JsonSetter("type") - public _FinalStage type(String type) { - this.type = type; - return this; - } - - @java.lang.Override - public _FinalStage target(Target target) { - this.target = Optional.of(target); - return this; - } - - @java.lang.Override - @JsonSetter(value = "target", nulls = Nulls.SKIP) - public _FinalStage target(Optional target) { - this.target = target; - return this; - } - - @java.lang.Override - public _FinalStage actor(Actor actor) { - this.actor = Optional.of(actor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "actor", nulls = Nulls.SKIP) - public _FinalStage actor(Optional actor) { - this.actor = actor; - return this; - } - - @java.lang.Override - public AuditEvent build() { - return new AuditEvent(actor, target, auditEventId, source, timestamp, type, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/types/GetAuditEventParams.java b/src/main/java/com/courier/api/resources/auditevents/types/GetAuditEventParams.java deleted file mode 100644 index 1f6e4542..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/types/GetAuditEventParams.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetAuditEventParams.Builder.class) -public final class GetAuditEventParams { - private final String auditEventId; - - private final Map additionalProperties; - - private GetAuditEventParams(String auditEventId, Map additionalProperties) { - this.auditEventId = auditEventId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("auditEventId") - public String getAuditEventId() { - return auditEventId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetAuditEventParams && equalTo((GetAuditEventParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetAuditEventParams other) { - return auditEventId.equals(other.auditEventId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.auditEventId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AuditEventIdStage builder() { - return new Builder(); - } - - public interface AuditEventIdStage { - _FinalStage auditEventId(String auditEventId); - - Builder from(GetAuditEventParams other); - } - - public interface _FinalStage { - GetAuditEventParams build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AuditEventIdStage, _FinalStage { - private String auditEventId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetAuditEventParams other) { - auditEventId(other.getAuditEventId()); - return this; - } - - @java.lang.Override - @JsonSetter("auditEventId") - public _FinalStage auditEventId(String auditEventId) { - this.auditEventId = auditEventId; - return this; - } - - @java.lang.Override - public GetAuditEventParams build() { - return new GetAuditEventParams(auditEventId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsParams.java b/src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsParams.java deleted file mode 100644 index 1aa0e7c1..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsParams.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListAuditEventsParams.Builder.class) -public final class ListAuditEventsParams { - private final Optional cursor; - - private final Map additionalProperties; - - private ListAuditEventsParams(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListAuditEventsParams && equalTo((ListAuditEventsParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListAuditEventsParams other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListAuditEventsParams other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListAuditEventsParams build() { - return new ListAuditEventsParams(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsResponse.java b/src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsResponse.java deleted file mode 100644 index bb0ea317..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/types/ListAuditEventsResponse.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListAuditEventsResponse.Builder.class) -public final class ListAuditEventsResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private ListAuditEventsResponse(Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListAuditEventsResponse && equalTo((ListAuditEventsResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListAuditEventsResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(ListAuditEventsResponse other); - } - - public interface _FinalStage { - ListAuditEventsResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(AuditEvent results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListAuditEventsResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - @java.lang.Override - public _FinalStage addResults(AuditEvent results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public ListAuditEventsResponse build() { - return new ListAuditEventsResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/auditevents/types/Target.java b/src/main/java/com/courier/api/resources/auditevents/types/Target.java deleted file mode 100644 index 7e6bd5b4..00000000 --- a/src/main/java/com/courier/api/resources/auditevents/types/Target.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.auditevents.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Target.Builder.class) -public final class Target { - private final Optional id; - - private final Optional email; - - private final Map additionalProperties; - - private Target(Optional id, Optional email, Map additionalProperties) { - this.id = id; - this.email = email; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public Optional getId() { - return id; - } - - @JsonProperty("email") - public Optional getEmail() { - return email; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Target && equalTo((Target) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Target other) { - return id.equals(other.id) && email.equals(other.email); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.email); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional id = Optional.empty(); - - private Optional email = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Target other) { - id(other.getId()); - email(other.getEmail()); - return this; - } - - @JsonSetter(value = "id", nulls = Nulls.SKIP) - public Builder id(Optional id) { - this.id = id; - return this; - } - - public Builder id(String id) { - this.id = Optional.of(id); - return this; - } - - @JsonSetter(value = "email", nulls = Nulls.SKIP) - public Builder email(Optional email) { - this.email = email; - return this; - } - - public Builder email(String email) { - this.email = Optional.of(email); - return this; - } - - public Target build() { - return new Target(id, email, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/authtokens/AuthTokensClient.java b/src/main/java/com/courier/api/resources/authtokens/AuthTokensClient.java deleted file mode 100644 index 38f7895b..00000000 --- a/src/main/java/com/courier/api/resources/authtokens/AuthTokensClient.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.authtokens; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.authtokens.requests.IssueTokenParams; -import com.courier.api.resources.authtokens.types.IssueTokenResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class AuthTokensClient { - protected final ClientOptions clientOptions; - - public AuthTokensClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns a new access token. - */ - public IssueTokenResponse issueToken(IssueTokenParams request) { - return issueToken(request, null); - } - - /** - * Returns a new access token. - */ - public IssueTokenResponse issueToken(IssueTokenParams request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("auth") - .addPathSegments("issue-token") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), IssueTokenResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/authtokens/requests/IssueTokenParams.java b/src/main/java/com/courier/api/resources/authtokens/requests/IssueTokenParams.java deleted file mode 100644 index a225e5d0..00000000 --- a/src/main/java/com/courier/api/resources/authtokens/requests/IssueTokenParams.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.authtokens.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = IssueTokenParams.Builder.class) -public final class IssueTokenParams { - private final String scope; - - private final String expiresIn; - - private final Map additionalProperties; - - private IssueTokenParams(String scope, String expiresIn, Map additionalProperties) { - this.scope = scope; - this.expiresIn = expiresIn; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("scope") - public String getScope() { - return scope; - } - - @JsonProperty("expires_in") - public String getExpiresIn() { - return expiresIn; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueTokenParams && equalTo((IssueTokenParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(IssueTokenParams other) { - return scope.equals(other.scope) && expiresIn.equals(other.expiresIn); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.scope, this.expiresIn); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ScopeStage builder() { - return new Builder(); - } - - public interface ScopeStage { - ExpiresInStage scope(String scope); - - Builder from(IssueTokenParams other); - } - - public interface ExpiresInStage { - _FinalStage expiresIn(String expiresIn); - } - - public interface _FinalStage { - IssueTokenParams build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ScopeStage, ExpiresInStage, _FinalStage { - private String scope; - - private String expiresIn; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(IssueTokenParams other) { - scope(other.getScope()); - expiresIn(other.getExpiresIn()); - return this; - } - - @java.lang.Override - @JsonSetter("scope") - public ExpiresInStage scope(String scope) { - this.scope = scope; - return this; - } - - @java.lang.Override - @JsonSetter("expires_in") - public _FinalStage expiresIn(String expiresIn) { - this.expiresIn = expiresIn; - return this; - } - - @java.lang.Override - public IssueTokenParams build() { - return new IssueTokenParams(scope, expiresIn, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/authtokens/types/IssueTokenResponse.java b/src/main/java/com/courier/api/resources/authtokens/types/IssueTokenResponse.java deleted file mode 100644 index 4720c798..00000000 --- a/src/main/java/com/courier/api/resources/authtokens/types/IssueTokenResponse.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.authtokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = IssueTokenResponse.Builder.class) -public final class IssueTokenResponse { - private final Optional token; - - private final Map additionalProperties; - - private IssueTokenResponse(Optional token, Map additionalProperties) { - this.token = token; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("token") - public Optional getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IssueTokenResponse && equalTo((IssueTokenResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(IssueTokenResponse other) { - return token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional token = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(IssueTokenResponse other) { - token(other.getToken()); - return this; - } - - @JsonSetter(value = "token", nulls = Nulls.SKIP) - public Builder token(Optional token) { - this.token = token; - return this; - } - - public Builder token(String token) { - this.token = Optional.of(token); - return this; - } - - public IssueTokenResponse build() { - return new IssueTokenResponse(token, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/AutomationsClient.java b/src/main/java/com/courier/api/resources/automations/AutomationsClient.java deleted file mode 100644 index b448ebd2..00000000 --- a/src/main/java/com/courier/api/resources/automations/AutomationsClient.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.automations.types.AutomationAdHocInvokeParams; -import com.courier.api.resources.automations.types.AutomationInvokeParams; -import com.courier.api.resources.automations.types.AutomationInvokeResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class AutomationsClient { - protected final ClientOptions clientOptions; - - public AutomationsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Invoke an automation run from an automation template. - */ - public AutomationInvokeResponse invokeAutomationTemplate(String templateId) { - return invokeAutomationTemplate( - templateId, AutomationInvokeParams.builder().build()); - } - - /** - * Invoke an automation run from an automation template. - */ - public AutomationInvokeResponse invokeAutomationTemplate(String templateId, AutomationInvokeParams request) { - return invokeAutomationTemplate(templateId, request, null); - } - - /** - * Invoke an automation run from an automation template. - */ - public AutomationInvokeResponse invokeAutomationTemplate( - String templateId, AutomationInvokeParams request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("automations") - .addPathSegment(templateId) - .addPathSegments("invoke") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AutomationInvokeResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation steps. For information about what steps are available, checkout the ad hoc automation guide here. - */ - public AutomationInvokeResponse invokeAdHocAutomation(AutomationAdHocInvokeParams request) { - return invokeAdHocAutomation(request, null); - } - - /** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation steps. For information about what steps are available, checkout the ad hoc automation guide here. - */ - public AutomationInvokeResponse invokeAdHocAutomation( - AutomationAdHocInvokeParams request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("automations") - .addPathSegments("invoke") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), AutomationInvokeResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AccessorType.java b/src/main/java/com/courier/api/resources/automations/types/AccessorType.java deleted file mode 100644 index 854b0739..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AccessorType.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AccessorType.Builder.class) -public final class AccessorType { - private final String ref; - - private final Map additionalProperties; - - private AccessorType(String ref, Map additionalProperties) { - this.ref = ref; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("$ref") - public String getRef() { - return ref; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AccessorType && equalTo((AccessorType) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AccessorType other) { - return ref.equals(other.ref); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.ref); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RefStage builder() { - return new Builder(); - } - - public interface RefStage { - _FinalStage ref(String ref); - - Builder from(AccessorType other); - } - - public interface _FinalStage { - AccessorType build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RefStage, _FinalStage { - private String ref; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AccessorType other) { - ref(other.getRef()); - return this; - } - - @java.lang.Override - @JsonSetter("$ref") - public _FinalStage ref(String ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public AccessorType build() { - return new AccessorType(ref, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/Automation.java b/src/main/java/com/courier/api/resources/automations/types/Automation.java deleted file mode 100644 index 693c696b..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/Automation.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Automation.Builder.class) -public final class Automation { - private final Optional cancelationToken; - - private final List steps; - - private final Map additionalProperties; - - private Automation( - Optional cancelationToken, - List steps, - Map additionalProperties) { - this.cancelationToken = cancelationToken; - this.steps = steps; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("cancelation_token") - public Optional getCancelationToken() { - return cancelationToken; - } - - @JsonProperty("steps") - public List getSteps() { - return steps; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Automation && equalTo((Automation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Automation other) { - return cancelationToken.equals(other.cancelationToken) && steps.equals(other.steps); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cancelationToken, this.steps); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cancelationToken = Optional.empty(); - - private List steps = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Automation other) { - cancelationToken(other.getCancelationToken()); - steps(other.getSteps()); - return this; - } - - @JsonSetter(value = "cancelation_token", nulls = Nulls.SKIP) - public Builder cancelationToken(Optional cancelationToken) { - this.cancelationToken = cancelationToken; - return this; - } - - public Builder cancelationToken(String cancelationToken) { - this.cancelationToken = Optional.of(cancelationToken); - return this; - } - - @JsonSetter(value = "steps", nulls = Nulls.SKIP) - public Builder steps(List steps) { - this.steps.clear(); - this.steps.addAll(steps); - return this; - } - - public Builder addSteps(AutomationStepOption steps) { - this.steps.add(steps); - return this; - } - - public Builder addAllSteps(List steps) { - this.steps.addAll(steps); - return this; - } - - public Automation build() { - return new Automation(cancelationToken, steps, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAdHocInvokeParams.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAdHocInvokeParams.java deleted file mode 100644 index 6a3499dc..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAdHocInvokeParams.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationAdHocInvokeParams.Builder.class) -public final class AutomationAdHocInvokeParams implements IAutomationInvokeParams { - private final Optional brand; - - private final Optional> data; - - private final Optional profile; - - private final Optional recipient; - - private final Optional template; - - private final Automation automation; - - private final Map additionalProperties; - - private AutomationAdHocInvokeParams( - Optional brand, - Optional> data, - Optional profile, - Optional recipient, - Optional template, - Automation automation, - Map additionalProperties) { - this.brand = brand; - this.data = data; - this.profile = profile; - this.recipient = recipient; - this.template = template; - this.automation = automation; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("brand") - @java.lang.Override - public Optional getBrand() { - return brand; - } - - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("profile") - @java.lang.Override - public Optional getProfile() { - return profile; - } - - @JsonProperty("recipient") - @java.lang.Override - public Optional getRecipient() { - return recipient; - } - - @JsonProperty("template") - @java.lang.Override - public Optional getTemplate() { - return template; - } - - @JsonProperty("automation") - public Automation getAutomation() { - return automation; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationAdHocInvokeParams && equalTo((AutomationAdHocInvokeParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationAdHocInvokeParams other) { - return brand.equals(other.brand) - && data.equals(other.data) - && profile.equals(other.profile) - && recipient.equals(other.recipient) - && template.equals(other.template) - && automation.equals(other.automation); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.brand, this.data, this.profile, this.recipient, this.template, this.automation); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AutomationStage builder() { - return new Builder(); - } - - public interface AutomationStage { - _FinalStage automation(Automation automation); - - Builder from(AutomationAdHocInvokeParams other); - } - - public interface _FinalStage { - AutomationAdHocInvokeParams build(); - - _FinalStage brand(Optional brand); - - _FinalStage brand(String brand); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage profile(Optional profile); - - _FinalStage profile(Object profile); - - _FinalStage recipient(Optional recipient); - - _FinalStage recipient(String recipient); - - _FinalStage template(Optional template); - - _FinalStage template(String template); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AutomationStage, _FinalStage { - private Automation automation; - - private Optional template = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional brand = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationAdHocInvokeParams other) { - brand(other.getBrand()); - data(other.getData()); - profile(other.getProfile()); - recipient(other.getRecipient()); - template(other.getTemplate()); - automation(other.getAutomation()); - return this; - } - - @java.lang.Override - @JsonSetter("automation") - public _FinalStage automation(Automation automation) { - this.automation = automation; - return this; - } - - @java.lang.Override - public _FinalStage template(String template) { - this.template = Optional.of(template); - return this; - } - - @java.lang.Override - @JsonSetter(value = "template", nulls = Nulls.SKIP) - public _FinalStage template(Optional template) { - this.template = template; - return this; - } - - @java.lang.Override - public _FinalStage recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @java.lang.Override - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public _FinalStage recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - @java.lang.Override - public _FinalStage profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public _FinalStage profile(Optional profile) { - this.profile = profile; - return this; - } - - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public _FinalStage brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public _FinalStage brand(Optional brand) { - this.brand = brand; - return this; - } - - @java.lang.Override - public AutomationAdHocInvokeParams build() { - return new AutomationAdHocInvokeParams( - brand, data, profile, recipient, template, automation, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchMaxItemsType.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchMaxItemsType.java deleted file mode 100644 index 7a831bfb..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchMaxItemsType.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AutomationAddToBatchMaxItemsType.Deserializer.class) -public final class AutomationAddToBatchMaxItemsType { - private final Object value; - - private final int type; - - private AutomationAddToBatchMaxItemsType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((int) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationAddToBatchMaxItemsType && equalTo((AutomationAddToBatchMaxItemsType) other); - } - - private boolean equalTo(AutomationAddToBatchMaxItemsType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AutomationAddToBatchMaxItemsType of(String value) { - return new AutomationAddToBatchMaxItemsType(value, 0); - } - - public static AutomationAddToBatchMaxItemsType of(int value) { - return new AutomationAddToBatchMaxItemsType(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(int value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AutomationAddToBatchMaxItemsType.class); - } - - @java.lang.Override - public AutomationAddToBatchMaxItemsType deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - if (value instanceof Integer) { - return of((Integer) value); - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetain.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetain.java deleted file mode 100644 index c33a3617..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetain.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationAddToBatchRetain.Builder.class) -public final class AutomationAddToBatchRetain { - private final AutomationAddToBatchRetainType type; - - private final int count; - - private final Optional sortKey; - - private final Map additionalProperties; - - private AutomationAddToBatchRetain( - AutomationAddToBatchRetainType type, - int count, - Optional sortKey, - Map additionalProperties) { - this.type = type; - this.count = count; - this.sortKey = sortKey; - this.additionalProperties = additionalProperties; - } - - /** - * @return Keep N number of notifications based on the type. First/Last N based on notification received. - * highest/lowest based on a scoring key providing in the data accessed by sort_key - */ - @JsonProperty("type") - public AutomationAddToBatchRetainType getType() { - return type; - } - - /** - * @return The number of records to keep in batch. Default is 10 and only configurable by requesting from support. - * When configurable minimum is 2 and maximum is 100. - */ - @JsonProperty("count") - public int getCount() { - return count; - } - - /** - * @return Defines the data value data[sort_key] that is used to sort the stored items. Required when type is set to highest or lowest. - */ - @JsonProperty("sort_key") - public Optional getSortKey() { - return sortKey; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationAddToBatchRetain && equalTo((AutomationAddToBatchRetain) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationAddToBatchRetain other) { - return type.equals(other.type) && count == other.count && sortKey.equals(other.sortKey); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.count, this.sortKey); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TypeStage builder() { - return new Builder(); - } - - public interface TypeStage { - CountStage type(AutomationAddToBatchRetainType type); - - Builder from(AutomationAddToBatchRetain other); - } - - public interface CountStage { - _FinalStage count(int count); - } - - public interface _FinalStage { - AutomationAddToBatchRetain build(); - - _FinalStage sortKey(Optional sortKey); - - _FinalStage sortKey(String sortKey); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TypeStage, CountStage, _FinalStage { - private AutomationAddToBatchRetainType type; - - private int count; - - private Optional sortKey = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationAddToBatchRetain other) { - type(other.getType()); - count(other.getCount()); - sortKey(other.getSortKey()); - return this; - } - - /** - *

Keep N number of notifications based on the type. First/Last N based on notification received. - * highest/lowest based on a scoring key providing in the data accessed by sort_key

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("type") - public CountStage type(AutomationAddToBatchRetainType type) { - this.type = type; - return this; - } - - /** - *

The number of records to keep in batch. Default is 10 and only configurable by requesting from support. - * When configurable minimum is 2 and maximum is 100.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("count") - public _FinalStage count(int count) { - this.count = count; - return this; - } - - /** - *

Defines the data value data[sort_key] that is used to sort the stored items. Required when type is set to highest or lowest.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage sortKey(String sortKey) { - this.sortKey = Optional.of(sortKey); - return this; - } - - @java.lang.Override - @JsonSetter(value = "sort_key", nulls = Nulls.SKIP) - public _FinalStage sortKey(Optional sortKey) { - this.sortKey = sortKey; - return this; - } - - @java.lang.Override - public AutomationAddToBatchRetain build() { - return new AutomationAddToBatchRetain(type, count, sortKey, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetainType.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetainType.java deleted file mode 100644 index 5858611c..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchRetainType.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AutomationAddToBatchRetainType { - FIRST("first"), - - LAST("last"), - - HIGHEST("highest"), - - LOWEST("lowest"); - - private final String value; - - AutomationAddToBatchRetainType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchScope.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchScope.java deleted file mode 100644 index 4992889e..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchScope.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AutomationAddToBatchScope { - USER("user"), - - GLOBAL("global"), - - DYNAMIC("dynamic"); - - private final String value; - - AutomationAddToBatchScope(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchStep.java deleted file mode 100644 index 78e3d907..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToBatchStep.java +++ /dev/null @@ -1,435 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationAddToBatchStep.Builder.class) -public final class AutomationAddToBatchStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final String waitPeriod; - - private final String maxWaitPeriod; - - private final Optional maxItems; - - private final AutomationAddToBatchRetain retain; - - private final Optional scope; - - private final Optional batchKey; - - private final Optional batchId; - - private final Optional categoryKey; - - private final Map additionalProperties; - - private AutomationAddToBatchStep( - Optional if_, - Optional ref, - String waitPeriod, - String maxWaitPeriod, - Optional maxItems, - AutomationAddToBatchRetain retain, - Optional scope, - Optional batchKey, - Optional batchId, - Optional categoryKey, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.waitPeriod = waitPeriod; - this.maxWaitPeriod = maxWaitPeriod; - this.maxItems = maxItems; - this.retain = retain; - this.scope = scope; - this.batchKey = batchKey; - this.batchId = batchId; - this.categoryKey = categoryKey; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "add-to-batch"; - } - - /** - * @return Defines the period of inactivity before the batch is released. Specified as an ISO 8601 duration - */ - @JsonProperty("wait_period") - public String getWaitPeriod() { - return waitPeriod; - } - - /** - * @return Defines the maximum wait time before the batch should be released. Must be less than wait period. Maximum of 60 days. Specified as an ISO 8601 duration - */ - @JsonProperty("max_wait_period") - public String getMaxWaitPeriod() { - return maxWaitPeriod; - } - - /** - * @return If specified, the batch will release as soon as this number is reached - */ - @JsonProperty("max_items") - public Optional getMaxItems() { - return maxItems; - } - - @JsonProperty("retain") - public AutomationAddToBatchRetain getRetain() { - return retain; - } - - /** - * @return Determine the scope of the batching. If user, chosen in this order: recipient, profile.user_id, data.user_id, data.userId. - * If dynamic, then specify where the batch_key or a reference to the batch_key - */ - @JsonProperty("scope") - public Optional getScope() { - return scope; - } - - /** - * @return If using scope=dynamic, provide the key or a reference (e.g., refs.data.batch_key) - */ - @JsonProperty("batch_key") - public Optional getBatchKey() { - return batchKey; - } - - @JsonProperty("batch_id") - public Optional getBatchId() { - return batchId; - } - - /** - * @return Defines the field of the data object the batch is set to when complete. Defaults to batch - */ - @JsonProperty("category_key") - public Optional getCategoryKey() { - return categoryKey; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationAddToBatchStep && equalTo((AutomationAddToBatchStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationAddToBatchStep other) { - return if_.equals(other.if_) - && ref.equals(other.ref) - && waitPeriod.equals(other.waitPeriod) - && maxWaitPeriod.equals(other.maxWaitPeriod) - && maxItems.equals(other.maxItems) - && retain.equals(other.retain) - && scope.equals(other.scope) - && batchKey.equals(other.batchKey) - && batchId.equals(other.batchId) - && categoryKey.equals(other.categoryKey); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.if_, - this.ref, - this.waitPeriod, - this.maxWaitPeriod, - this.maxItems, - this.retain, - this.scope, - this.batchKey, - this.batchId, - this.categoryKey); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static WaitPeriodStage builder() { - return new Builder(); - } - - public interface WaitPeriodStage { - MaxWaitPeriodStage waitPeriod(String waitPeriod); - - Builder from(AutomationAddToBatchStep other); - } - - public interface MaxWaitPeriodStage { - RetainStage maxWaitPeriod(String maxWaitPeriod); - } - - public interface RetainStage { - _FinalStage retain(AutomationAddToBatchRetain retain); - } - - public interface _FinalStage { - AutomationAddToBatchStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage maxItems(Optional maxItems); - - _FinalStage maxItems(AutomationAddToBatchMaxItemsType maxItems); - - _FinalStage scope(Optional scope); - - _FinalStage scope(AutomationAddToBatchScope scope); - - _FinalStage batchKey(Optional batchKey); - - _FinalStage batchKey(String batchKey); - - _FinalStage batchId(Optional batchId); - - _FinalStage batchId(String batchId); - - _FinalStage categoryKey(Optional categoryKey); - - _FinalStage categoryKey(String categoryKey); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements WaitPeriodStage, MaxWaitPeriodStage, RetainStage, _FinalStage { - private String waitPeriod; - - private String maxWaitPeriod; - - private AutomationAddToBatchRetain retain; - - private Optional categoryKey = Optional.empty(); - - private Optional batchId = Optional.empty(); - - private Optional batchKey = Optional.empty(); - - private Optional scope = Optional.empty(); - - private Optional maxItems = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationAddToBatchStep other) { - if_(other.getIf()); - ref(other.getRef()); - waitPeriod(other.getWaitPeriod()); - maxWaitPeriod(other.getMaxWaitPeriod()); - maxItems(other.getMaxItems()); - retain(other.getRetain()); - scope(other.getScope()); - batchKey(other.getBatchKey()); - batchId(other.getBatchId()); - categoryKey(other.getCategoryKey()); - return this; - } - - /** - *

Defines the period of inactivity before the batch is released. Specified as an ISO 8601 duration

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("wait_period") - public MaxWaitPeriodStage waitPeriod(String waitPeriod) { - this.waitPeriod = waitPeriod; - return this; - } - - /** - *

Defines the maximum wait time before the batch should be released. Must be less than wait period. Maximum of 60 days. Specified as an ISO 8601 duration

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("max_wait_period") - public RetainStage maxWaitPeriod(String maxWaitPeriod) { - this.maxWaitPeriod = maxWaitPeriod; - return this; - } - - @java.lang.Override - @JsonSetter("retain") - public _FinalStage retain(AutomationAddToBatchRetain retain) { - this.retain = retain; - return this; - } - - /** - *

Defines the field of the data object the batch is set to when complete. Defaults to batch

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage categoryKey(String categoryKey) { - this.categoryKey = Optional.of(categoryKey); - return this; - } - - @java.lang.Override - @JsonSetter(value = "category_key", nulls = Nulls.SKIP) - public _FinalStage categoryKey(Optional categoryKey) { - this.categoryKey = categoryKey; - return this; - } - - @java.lang.Override - public _FinalStage batchId(String batchId) { - this.batchId = Optional.of(batchId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "batch_id", nulls = Nulls.SKIP) - public _FinalStage batchId(Optional batchId) { - this.batchId = batchId; - return this; - } - - /** - *

If using scope=dynamic, provide the key or a reference (e.g., refs.data.batch_key)

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage batchKey(String batchKey) { - this.batchKey = Optional.of(batchKey); - return this; - } - - @java.lang.Override - @JsonSetter(value = "batch_key", nulls = Nulls.SKIP) - public _FinalStage batchKey(Optional batchKey) { - this.batchKey = batchKey; - return this; - } - - /** - *

Determine the scope of the batching. If user, chosen in this order: recipient, profile.user_id, data.user_id, data.userId. - * If dynamic, then specify where the batch_key or a reference to the batch_key

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage scope(AutomationAddToBatchScope scope) { - this.scope = Optional.of(scope); - return this; - } - - @java.lang.Override - @JsonSetter(value = "scope", nulls = Nulls.SKIP) - public _FinalStage scope(Optional scope) { - this.scope = scope; - return this; - } - - /** - *

If specified, the batch will release as soon as this number is reached

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage maxItems(AutomationAddToBatchMaxItemsType maxItems) { - this.maxItems = Optional.of(maxItems); - return this; - } - - @java.lang.Override - @JsonSetter(value = "max_items", nulls = Nulls.SKIP) - public _FinalStage maxItems(Optional maxItems) { - this.maxItems = maxItems; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationAddToBatchStep build() { - return new AutomationAddToBatchStep( - if_, - ref, - waitPeriod, - maxWaitPeriod, - maxItems, - retain, - scope, - batchKey, - batchId, - categoryKey, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToDigestStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationAddToDigestStep.java deleted file mode 100644 index 5cc2ed7c..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationAddToDigestStep.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationAddToDigestStep.Builder.class) -public final class AutomationAddToDigestStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final String subscriptionTopicId; - - private final Map additionalProperties; - - private AutomationAddToDigestStep( - Optional if_, - Optional ref, - String subscriptionTopicId, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.subscriptionTopicId = subscriptionTopicId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "add-to-digest"; - } - - /** - * @return The subscription topic that has digests enabled - */ - @JsonProperty("subscription_topic_id") - public String getSubscriptionTopicId() { - return subscriptionTopicId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationAddToDigestStep && equalTo((AutomationAddToDigestStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationAddToDigestStep other) { - return if_.equals(other.if_) && ref.equals(other.ref) && subscriptionTopicId.equals(other.subscriptionTopicId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref, this.subscriptionTopicId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static SubscriptionTopicIdStage builder() { - return new Builder(); - } - - public interface SubscriptionTopicIdStage { - _FinalStage subscriptionTopicId(String subscriptionTopicId); - - Builder from(AutomationAddToDigestStep other); - } - - public interface _FinalStage { - AutomationAddToDigestStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SubscriptionTopicIdStage, _FinalStage { - private String subscriptionTopicId; - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationAddToDigestStep other) { - if_(other.getIf()); - ref(other.getRef()); - subscriptionTopicId(other.getSubscriptionTopicId()); - return this; - } - - /** - *

The subscription topic that has digests enabled

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("subscription_topic_id") - public _FinalStage subscriptionTopicId(String subscriptionTopicId) { - this.subscriptionTopicId = subscriptionTopicId; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationAddToDigestStep build() { - return new AutomationAddToDigestStep(if_, ref, subscriptionTopicId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationCancelStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationCancelStep.java deleted file mode 100644 index 09a6d53c..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationCancelStep.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationCancelStep.Builder.class) -public final class AutomationCancelStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final Optional cancelationToken; - - private final Map additionalProperties; - - private AutomationCancelStep( - Optional if_, - Optional ref, - Optional cancelationToken, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.cancelationToken = cancelationToken; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "cancel"; - } - - @JsonProperty("cancelation_token") - public Optional getCancelationToken() { - return cancelationToken; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationCancelStep && equalTo((AutomationCancelStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationCancelStep other) { - return if_.equals(other.if_) && ref.equals(other.ref) && cancelationToken.equals(other.cancelationToken); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref, this.cancelationToken); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional cancelationToken = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AutomationCancelStep other) { - if_(other.getIf()); - ref(other.getRef()); - cancelationToken(other.getCancelationToken()); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "cancelation_token", nulls = Nulls.SKIP) - public Builder cancelationToken(Optional cancelationToken) { - this.cancelationToken = cancelationToken; - return this; - } - - public Builder cancelationToken(String cancelationToken) { - this.cancelationToken = Optional.of(cancelationToken); - return this; - } - - public AutomationCancelStep build() { - return new AutomationCancelStep(if_, ref, cancelationToken, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationDelayStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationDelayStep.java deleted file mode 100644 index d9122efc..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationDelayStep.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationDelayStep.Builder.class) -public final class AutomationDelayStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final Optional duration; - - private final Optional until; - - private final Map additionalProperties; - - private AutomationDelayStep( - Optional if_, - Optional ref, - Optional duration, - Optional until, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.duration = duration; - this.until = until; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "delay"; - } - - /** - * @return The ISO 8601 duration string for how long to delay for - */ - @JsonProperty("duration") - public Optional getDuration() { - return duration; - } - - /** - * @return The ISO 8601 timestamp for when the delay should end - */ - @JsonProperty("until") - public Optional getUntil() { - return until; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationDelayStep && equalTo((AutomationDelayStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationDelayStep other) { - return if_.equals(other.if_) - && ref.equals(other.ref) - && duration.equals(other.duration) - && until.equals(other.until); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref, this.duration, this.until); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional duration = Optional.empty(); - - private Optional until = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AutomationDelayStep other) { - if_(other.getIf()); - ref(other.getRef()); - duration(other.getDuration()); - until(other.getUntil()); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "duration", nulls = Nulls.SKIP) - public Builder duration(Optional duration) { - this.duration = duration; - return this; - } - - public Builder duration(String duration) { - this.duration = Optional.of(duration); - return this; - } - - @JsonSetter(value = "until", nulls = Nulls.SKIP) - public Builder until(Optional until) { - this.until = until; - return this; - } - - public Builder until(String until) { - this.until = Optional.of(until); - return this; - } - - public AutomationDelayStep build() { - return new AutomationDelayStep(if_, ref, duration, until, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataStep.java deleted file mode 100644 index 68150b82..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataStep.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationFetchDataStep.Builder.class) -public final class AutomationFetchDataStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final AutomationFetchDataWebhook webhook; - - private final MergeAlgorithm mergeStrategy; - - private final Optional idempotencyExpiry; - - private final Optional idempotencyKey; - - private final Map additionalProperties; - - private AutomationFetchDataStep( - Optional if_, - Optional ref, - AutomationFetchDataWebhook webhook, - MergeAlgorithm mergeStrategy, - Optional idempotencyExpiry, - Optional idempotencyKey, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.webhook = webhook; - this.mergeStrategy = mergeStrategy; - this.idempotencyExpiry = idempotencyExpiry; - this.idempotencyKey = idempotencyKey; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "fetch-data"; - } - - @JsonProperty("webhook") - public AutomationFetchDataWebhook getWebhook() { - return webhook; - } - - @JsonProperty("merge_strategy") - public MergeAlgorithm getMergeStrategy() { - return mergeStrategy; - } - - @JsonProperty("idempotency_expiry") - public Optional getIdempotencyExpiry() { - return idempotencyExpiry; - } - - @JsonProperty("idempotency_key") - public Optional getIdempotencyKey() { - return idempotencyKey; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationFetchDataStep && equalTo((AutomationFetchDataStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationFetchDataStep other) { - return if_.equals(other.if_) - && ref.equals(other.ref) - && webhook.equals(other.webhook) - && mergeStrategy.equals(other.mergeStrategy) - && idempotencyExpiry.equals(other.idempotencyExpiry) - && idempotencyKey.equals(other.idempotencyKey); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.if_, this.ref, this.webhook, this.mergeStrategy, this.idempotencyExpiry, this.idempotencyKey); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static WebhookStage builder() { - return new Builder(); - } - - public interface WebhookStage { - MergeStrategyStage webhook(AutomationFetchDataWebhook webhook); - - Builder from(AutomationFetchDataStep other); - } - - public interface MergeStrategyStage { - _FinalStage mergeStrategy(MergeAlgorithm mergeStrategy); - } - - public interface _FinalStage { - AutomationFetchDataStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage idempotencyExpiry(Optional idempotencyExpiry); - - _FinalStage idempotencyExpiry(String idempotencyExpiry); - - _FinalStage idempotencyKey(Optional idempotencyKey); - - _FinalStage idempotencyKey(String idempotencyKey); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements WebhookStage, MergeStrategyStage, _FinalStage { - private AutomationFetchDataWebhook webhook; - - private MergeAlgorithm mergeStrategy; - - private Optional idempotencyKey = Optional.empty(); - - private Optional idempotencyExpiry = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationFetchDataStep other) { - if_(other.getIf()); - ref(other.getRef()); - webhook(other.getWebhook()); - mergeStrategy(other.getMergeStrategy()); - idempotencyExpiry(other.getIdempotencyExpiry()); - idempotencyKey(other.getIdempotencyKey()); - return this; - } - - @java.lang.Override - @JsonSetter("webhook") - public MergeStrategyStage webhook(AutomationFetchDataWebhook webhook) { - this.webhook = webhook; - return this; - } - - @java.lang.Override - @JsonSetter("merge_strategy") - public _FinalStage mergeStrategy(MergeAlgorithm mergeStrategy) { - this.mergeStrategy = mergeStrategy; - return this; - } - - @java.lang.Override - public _FinalStage idempotencyKey(String idempotencyKey) { - this.idempotencyKey = Optional.of(idempotencyKey); - return this; - } - - @java.lang.Override - @JsonSetter(value = "idempotency_key", nulls = Nulls.SKIP) - public _FinalStage idempotencyKey(Optional idempotencyKey) { - this.idempotencyKey = idempotencyKey; - return this; - } - - @java.lang.Override - public _FinalStage idempotencyExpiry(String idempotencyExpiry) { - this.idempotencyExpiry = Optional.of(idempotencyExpiry); - return this; - } - - @java.lang.Override - @JsonSetter(value = "idempotency_expiry", nulls = Nulls.SKIP) - public _FinalStage idempotencyExpiry(Optional idempotencyExpiry) { - this.idempotencyExpiry = idempotencyExpiry; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationFetchDataStep build() { - return new AutomationFetchDataStep( - if_, ref, webhook, mergeStrategy, idempotencyExpiry, idempotencyKey, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhook.java b/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhook.java deleted file mode 100644 index 9f7ea0c1..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhook.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationFetchDataWebhook.Builder.class) -public final class AutomationFetchDataWebhook { - private final Optional> body; - - private final Optional> headers; - - private final Optional> params; - - private final AutomationFetchDataWebhookMethod method; - - private final String url; - - private final Map additionalProperties; - - private AutomationFetchDataWebhook( - Optional> body, - Optional> headers, - Optional> params, - AutomationFetchDataWebhookMethod method, - String url, - Map additionalProperties) { - this.body = body; - this.headers = headers; - this.params = params; - this.method = method; - this.url = url; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("body") - public Optional> getBody() { - return body; - } - - @JsonProperty("headers") - public Optional> getHeaders() { - return headers; - } - - @JsonProperty("params") - public Optional> getParams() { - return params; - } - - @JsonProperty("method") - public AutomationFetchDataWebhookMethod getMethod() { - return method; - } - - @JsonProperty("url") - public String getUrl() { - return url; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationFetchDataWebhook && equalTo((AutomationFetchDataWebhook) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationFetchDataWebhook other) { - return body.equals(other.body) - && headers.equals(other.headers) - && params.equals(other.params) - && method.equals(other.method) - && url.equals(other.url); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.body, this.headers, this.params, this.method, this.url); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MethodStage builder() { - return new Builder(); - } - - public interface MethodStage { - UrlStage method(AutomationFetchDataWebhookMethod method); - - Builder from(AutomationFetchDataWebhook other); - } - - public interface UrlStage { - _FinalStage url(String url); - } - - public interface _FinalStage { - AutomationFetchDataWebhook build(); - - _FinalStage body(Optional> body); - - _FinalStage body(Map body); - - _FinalStage headers(Optional> headers); - - _FinalStage headers(Map headers); - - _FinalStage params(Optional> params); - - _FinalStage params(Map params); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MethodStage, UrlStage, _FinalStage { - private AutomationFetchDataWebhookMethod method; - - private String url; - - private Optional> params = Optional.empty(); - - private Optional> headers = Optional.empty(); - - private Optional> body = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationFetchDataWebhook other) { - body(other.getBody()); - headers(other.getHeaders()); - params(other.getParams()); - method(other.getMethod()); - url(other.getUrl()); - return this; - } - - @java.lang.Override - @JsonSetter("method") - public UrlStage method(AutomationFetchDataWebhookMethod method) { - this.method = method; - return this; - } - - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - @java.lang.Override - public _FinalStage params(Map params) { - this.params = Optional.of(params); - return this; - } - - @java.lang.Override - @JsonSetter(value = "params", nulls = Nulls.SKIP) - public _FinalStage params(Optional> params) { - this.params = params; - return this; - } - - @java.lang.Override - public _FinalStage headers(Map headers) { - this.headers = Optional.of(headers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "headers", nulls = Nulls.SKIP) - public _FinalStage headers(Optional> headers) { - this.headers = headers; - return this; - } - - @java.lang.Override - public _FinalStage body(Map body) { - this.body = Optional.of(body); - return this; - } - - @java.lang.Override - @JsonSetter(value = "body", nulls = Nulls.SKIP) - public _FinalStage body(Optional> body) { - this.body = body; - return this; - } - - @java.lang.Override - public AutomationFetchDataWebhook build() { - return new AutomationFetchDataWebhook(body, headers, params, method, url, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhookMethod.java b/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhookMethod.java deleted file mode 100644 index 4dc21262..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationFetchDataWebhookMethod.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AutomationFetchDataWebhookMethod { - GET("GET"), - - POST("POST"); - - private final String value; - - AutomationFetchDataWebhookMethod(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeParams.java b/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeParams.java deleted file mode 100644 index 779c3613..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeParams.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationInvokeParams.Builder.class) -public final class AutomationInvokeParams implements IAutomationInvokeParams { - private final Optional brand; - - private final Optional> data; - - private final Optional profile; - - private final Optional recipient; - - private final Optional template; - - private final Map additionalProperties; - - private AutomationInvokeParams( - Optional brand, - Optional> data, - Optional profile, - Optional recipient, - Optional template, - Map additionalProperties) { - this.brand = brand; - this.data = data; - this.profile = profile; - this.recipient = recipient; - this.template = template; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("brand") - @java.lang.Override - public Optional getBrand() { - return brand; - } - - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("profile") - @java.lang.Override - public Optional getProfile() { - return profile; - } - - @JsonProperty("recipient") - @java.lang.Override - public Optional getRecipient() { - return recipient; - } - - @JsonProperty("template") - @java.lang.Override - public Optional getTemplate() { - return template; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationInvokeParams && equalTo((AutomationInvokeParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationInvokeParams other) { - return brand.equals(other.brand) - && data.equals(other.data) - && profile.equals(other.profile) - && recipient.equals(other.recipient) - && template.equals(other.template); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.brand, this.data, this.profile, this.recipient, this.template); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional brand = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional template = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AutomationInvokeParams other) { - brand(other.getBrand()); - data(other.getData()); - profile(other.getProfile()); - recipient(other.getRecipient()); - template(other.getTemplate()); - return this; - } - - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public Builder brand(Optional brand) { - this.brand = brand; - return this; - } - - public Builder brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Optional profile) { - this.profile = profile; - return this; - } - - public Builder profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public Builder recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - public Builder recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @JsonSetter(value = "template", nulls = Nulls.SKIP) - public Builder template(Optional template) { - this.template = template; - return this; - } - - public Builder template(String template) { - this.template = Optional.of(template); - return this; - } - - public AutomationInvokeParams build() { - return new AutomationInvokeParams(brand, data, profile, recipient, template, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeResponse.java b/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeResponse.java deleted file mode 100644 index d767e5a2..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationInvokeResponse.Builder.class) -public final class AutomationInvokeResponse { - private final String runId; - - private final Map additionalProperties; - - private AutomationInvokeResponse(String runId, Map additionalProperties) { - this.runId = runId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("runId") - public String getRunId() { - return runId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationInvokeResponse && equalTo((AutomationInvokeResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationInvokeResponse other) { - return runId.equals(other.runId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.runId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RunIdStage builder() { - return new Builder(); - } - - public interface RunIdStage { - _FinalStage runId(String runId); - - Builder from(AutomationInvokeResponse other); - } - - public interface _FinalStage { - AutomationInvokeResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RunIdStage, _FinalStage { - private String runId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationInvokeResponse other) { - runId(other.getRunId()); - return this; - } - - @java.lang.Override - @JsonSetter("runId") - public _FinalStage runId(String runId) { - this.runId = runId; - return this; - } - - @java.lang.Override - public AutomationInvokeResponse build() { - return new AutomationInvokeResponse(runId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeStep.java deleted file mode 100644 index 29a04a20..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeStep.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationInvokeStep.Builder.class) -public final class AutomationInvokeStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final String template; - - private final Map additionalProperties; - - private AutomationInvokeStep( - Optional if_, Optional ref, String template, Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.template = template; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "invoke"; - } - - @JsonProperty("template") - public String getTemplate() { - return template; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationInvokeStep && equalTo((AutomationInvokeStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationInvokeStep other) { - return if_.equals(other.if_) && ref.equals(other.ref) && template.equals(other.template); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref, this.template); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TemplateStage builder() { - return new Builder(); - } - - public interface TemplateStage { - _FinalStage template(String template); - - Builder from(AutomationInvokeStep other); - } - - public interface _FinalStage { - AutomationInvokeStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TemplateStage, _FinalStage { - private String template; - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationInvokeStep other) { - if_(other.getIf()); - ref(other.getRef()); - template(other.getTemplate()); - return this; - } - - @java.lang.Override - @JsonSetter("template") - public _FinalStage template(String template) { - this.template = template; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationInvokeStep build() { - return new AutomationInvokeStep(if_, ref, template, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeTemplateParams.java b/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeTemplateParams.java deleted file mode 100644 index 6497d2ca..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationInvokeTemplateParams.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationInvokeTemplateParams.Builder.class) -public final class AutomationInvokeTemplateParams implements IAutomationInvokeParams { - private final Optional brand; - - private final Optional> data; - - private final Optional profile; - - private final Optional recipient; - - private final Optional template; - - private final String templateId; - - private final Map additionalProperties; - - private AutomationInvokeTemplateParams( - Optional brand, - Optional> data, - Optional profile, - Optional recipient, - Optional template, - String templateId, - Map additionalProperties) { - this.brand = brand; - this.data = data; - this.profile = profile; - this.recipient = recipient; - this.template = template; - this.templateId = templateId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("brand") - @java.lang.Override - public Optional getBrand() { - return brand; - } - - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("profile") - @java.lang.Override - public Optional getProfile() { - return profile; - } - - @JsonProperty("recipient") - @java.lang.Override - public Optional getRecipient() { - return recipient; - } - - @JsonProperty("template") - @java.lang.Override - public Optional getTemplate() { - return template; - } - - @JsonProperty("templateId") - public String getTemplateId() { - return templateId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationInvokeTemplateParams && equalTo((AutomationInvokeTemplateParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationInvokeTemplateParams other) { - return brand.equals(other.brand) - && data.equals(other.data) - && profile.equals(other.profile) - && recipient.equals(other.recipient) - && template.equals(other.template) - && templateId.equals(other.templateId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.brand, this.data, this.profile, this.recipient, this.template, this.templateId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TemplateIdStage builder() { - return new Builder(); - } - - public interface TemplateIdStage { - _FinalStage templateId(String templateId); - - Builder from(AutomationInvokeTemplateParams other); - } - - public interface _FinalStage { - AutomationInvokeTemplateParams build(); - - _FinalStage brand(Optional brand); - - _FinalStage brand(String brand); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage profile(Optional profile); - - _FinalStage profile(Object profile); - - _FinalStage recipient(Optional recipient); - - _FinalStage recipient(String recipient); - - _FinalStage template(Optional template); - - _FinalStage template(String template); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TemplateIdStage, _FinalStage { - private String templateId; - - private Optional template = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional brand = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationInvokeTemplateParams other) { - brand(other.getBrand()); - data(other.getData()); - profile(other.getProfile()); - recipient(other.getRecipient()); - template(other.getTemplate()); - templateId(other.getTemplateId()); - return this; - } - - @java.lang.Override - @JsonSetter("templateId") - public _FinalStage templateId(String templateId) { - this.templateId = templateId; - return this; - } - - @java.lang.Override - public _FinalStage template(String template) { - this.template = Optional.of(template); - return this; - } - - @java.lang.Override - @JsonSetter(value = "template", nulls = Nulls.SKIP) - public _FinalStage template(Optional template) { - this.template = template; - return this; - } - - @java.lang.Override - public _FinalStage recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @java.lang.Override - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public _FinalStage recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - @java.lang.Override - public _FinalStage profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public _FinalStage profile(Optional profile) { - this.profile = profile; - return this; - } - - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public _FinalStage brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public _FinalStage brand(Optional brand) { - this.brand = brand; - return this; - } - - @java.lang.Override - public AutomationInvokeTemplateParams build() { - return new AutomationInvokeTemplateParams( - brand, data, profile, recipient, template, templateId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationRunContext.java b/src/main/java/com/courier/api/resources/automations/types/AutomationRunContext.java deleted file mode 100644 index e09711c7..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationRunContext.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationRunContext.Builder.class) -public final class AutomationRunContext { - private final Optional brand; - - private final Optional data; - - private final Optional profile; - - private final Optional template; - - private final Optional recipient; - - private final Map additionalProperties; - - private AutomationRunContext( - Optional brand, - Optional data, - Optional profile, - Optional template, - Optional recipient, - Map additionalProperties) { - this.brand = brand; - this.data = data; - this.profile = profile; - this.template = template; - this.recipient = recipient; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("brand") - public Optional getBrand() { - return brand; - } - - @JsonProperty("data") - public Optional getData() { - return data; - } - - @JsonProperty("profile") - public Optional getProfile() { - return profile; - } - - @JsonProperty("template") - public Optional getTemplate() { - return template; - } - - @JsonProperty("recipient") - public Optional getRecipient() { - return recipient; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationRunContext && equalTo((AutomationRunContext) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationRunContext other) { - return brand.equals(other.brand) - && data.equals(other.data) - && profile.equals(other.profile) - && template.equals(other.template) - && recipient.equals(other.recipient); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.brand, this.data, this.profile, this.template, this.recipient); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional brand = Optional.empty(); - - private Optional data = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional template = Optional.empty(); - - private Optional recipient = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AutomationRunContext other) { - brand(other.getBrand()); - data(other.getData()); - profile(other.getProfile()); - template(other.getTemplate()); - recipient(other.getRecipient()); - return this; - } - - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public Builder brand(Optional brand) { - this.brand = brand; - return this; - } - - public Builder brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional data) { - this.data = data; - return this; - } - - public Builder data(Object data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Optional profile) { - this.profile = profile; - return this; - } - - public Builder profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @JsonSetter(value = "template", nulls = Nulls.SKIP) - public Builder template(Optional template) { - this.template = template; - return this; - } - - public Builder template(String template) { - this.template = Optional.of(template); - return this; - } - - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public Builder recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - public Builder recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - public AutomationRunContext build() { - return new AutomationRunContext(brand, data, profile, template, recipient, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationSendListStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationSendListStep.java deleted file mode 100644 index 1938de03..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationSendListStep.java +++ /dev/null @@ -1,292 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationSendListStep.Builder.class) -public final class AutomationSendListStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final Optional brand; - - private final Optional> data; - - private final String list; - - private final Optional> override; - - private final Optional template; - - private final Map additionalProperties; - - private AutomationSendListStep( - Optional if_, - Optional ref, - Optional brand, - Optional> data, - String list, - Optional> override, - Optional template, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.brand = brand; - this.data = data; - this.list = list; - this.override = override; - this.template = template; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "send-list"; - } - - @JsonProperty("brand") - public Optional getBrand() { - return brand; - } - - @JsonProperty("data") - public Optional> getData() { - return data; - } - - @JsonProperty("list") - public String getList() { - return list; - } - - @JsonProperty("override") - public Optional> getOverride() { - return override; - } - - @JsonProperty("template") - public Optional getTemplate() { - return template; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationSendListStep && equalTo((AutomationSendListStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationSendListStep other) { - return if_.equals(other.if_) - && ref.equals(other.ref) - && brand.equals(other.brand) - && data.equals(other.data) - && list.equals(other.list) - && override.equals(other.override) - && template.equals(other.template); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref, this.brand, this.data, this.list, this.override, this.template); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ListStage builder() { - return new Builder(); - } - - public interface ListStage { - _FinalStage list(String list); - - Builder from(AutomationSendListStep other); - } - - public interface _FinalStage { - AutomationSendListStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage brand(Optional brand); - - _FinalStage brand(String brand); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage override(Optional> override); - - _FinalStage override(Map override); - - _FinalStage template(Optional template); - - _FinalStage template(String template); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ListStage, _FinalStage { - private String list; - - private Optional template = Optional.empty(); - - private Optional> override = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional brand = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationSendListStep other) { - if_(other.getIf()); - ref(other.getRef()); - brand(other.getBrand()); - data(other.getData()); - list(other.getList()); - override(other.getOverride()); - template(other.getTemplate()); - return this; - } - - @java.lang.Override - @JsonSetter("list") - public _FinalStage list(String list) { - this.list = list; - return this; - } - - @java.lang.Override - public _FinalStage template(String template) { - this.template = Optional.of(template); - return this; - } - - @java.lang.Override - @JsonSetter(value = "template", nulls = Nulls.SKIP) - public _FinalStage template(Optional template) { - this.template = template; - return this; - } - - @java.lang.Override - public _FinalStage override(Map override) { - this.override = Optional.of(override); - return this; - } - - @java.lang.Override - @JsonSetter(value = "override", nulls = Nulls.SKIP) - public _FinalStage override(Optional> override) { - this.override = override; - return this; - } - - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public _FinalStage brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public _FinalStage brand(Optional brand) { - this.brand = brand; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationSendListStep build() { - return new AutomationSendListStep(if_, ref, brand, data, list, override, template, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationSendStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationSendStep.java deleted file mode 100644 index 0e99281e..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationSendStep.java +++ /dev/null @@ -1,274 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationSendStep.Builder.class) -public final class AutomationSendStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final Optional brand; - - private final Optional> data; - - private final Optional> override; - - private final Optional profile; - - private final Optional recipient; - - private final Optional template; - - private final Map additionalProperties; - - private AutomationSendStep( - Optional if_, - Optional ref, - Optional brand, - Optional> data, - Optional> override, - Optional profile, - Optional recipient, - Optional template, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.brand = brand; - this.data = data; - this.override = override; - this.profile = profile; - this.recipient = recipient; - this.template = template; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "send"; - } - - @JsonProperty("brand") - public Optional getBrand() { - return brand; - } - - @JsonProperty("data") - public Optional> getData() { - return data; - } - - @JsonProperty("override") - public Optional> getOverride() { - return override; - } - - @JsonProperty("profile") - public Optional getProfile() { - return profile; - } - - @JsonProperty("recipient") - public Optional getRecipient() { - return recipient; - } - - @JsonProperty("template") - public Optional getTemplate() { - return template; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationSendStep && equalTo((AutomationSendStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationSendStep other) { - return if_.equals(other.if_) - && ref.equals(other.ref) - && brand.equals(other.brand) - && data.equals(other.data) - && override.equals(other.override) - && profile.equals(other.profile) - && recipient.equals(other.recipient) - && template.equals(other.template); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.if_, this.ref, this.brand, this.data, this.override, this.profile, this.recipient, this.template); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional brand = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional> override = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional template = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AutomationSendStep other) { - if_(other.getIf()); - ref(other.getRef()); - brand(other.getBrand()); - data(other.getData()); - override(other.getOverride()); - profile(other.getProfile()); - recipient(other.getRecipient()); - template(other.getTemplate()); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public Builder brand(Optional brand) { - this.brand = brand; - return this; - } - - public Builder brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "override", nulls = Nulls.SKIP) - public Builder override(Optional> override) { - this.override = override; - return this; - } - - public Builder override(Map override) { - this.override = Optional.of(override); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Optional profile) { - this.profile = profile; - return this; - } - - public Builder profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public Builder recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - public Builder recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @JsonSetter(value = "template", nulls = Nulls.SKIP) - public Builder template(Optional template) { - this.template = template; - return this; - } - - public Builder template(String template) { - this.template = Optional.of(template); - return this; - } - - public AutomationSendStep build() { - return new AutomationSendStep( - if_, ref, brand, data, override, profile, recipient, template, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationStep.java deleted file mode 100644 index 5718b573..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationStep.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationStep.Builder.class) -public final class AutomationStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final Map additionalProperties; - - private AutomationStep(Optional if_, Optional ref, Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationStep && equalTo((AutomationStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationStep other) { - return if_.equals(other.if_) && ref.equals(other.ref); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AutomationStep other) { - if_(other.getIf()); - ref(other.getRef()); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - public AutomationStep build() { - return new AutomationStep(if_, ref, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationStepOption.java b/src/main/java/com/courier/api/resources/automations/types/AutomationStepOption.java deleted file mode 100644 index 44d8327d..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationStepOption.java +++ /dev/null @@ -1,202 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = AutomationStepOption.Deserializer.class) -public final class AutomationStepOption { - private final Object value; - - private final int type; - - private AutomationStepOption(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AutomationAddToDigestStep) this.value); - } else if (this.type == 1) { - return visitor.visit((AutomationAddToBatchStep) this.value); - } else if (this.type == 2) { - return visitor.visit((AutomationThrottleStep) this.value); - } else if (this.type == 3) { - return visitor.visit((AutomationCancelStep) this.value); - } else if (this.type == 4) { - return visitor.visit((AutomationDelayStep) this.value); - } else if (this.type == 5) { - return visitor.visit((AutomationFetchDataStep) this.value); - } else if (this.type == 6) { - return visitor.visit((AutomationInvokeStep) this.value); - } else if (this.type == 7) { - return visitor.visit((AutomationSendStep) this.value); - } else if (this.type == 8) { - return visitor.visit((AutomationV2SendStep) this.value); - } else if (this.type == 9) { - return visitor.visit((AutomationSendListStep) this.value); - } else if (this.type == 10) { - return visitor.visit((AutomationUpdateProfileStep) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationStepOption && equalTo((AutomationStepOption) other); - } - - private boolean equalTo(AutomationStepOption other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static AutomationStepOption of(AutomationAddToDigestStep value) { - return new AutomationStepOption(value, 0); - } - - public static AutomationStepOption of(AutomationAddToBatchStep value) { - return new AutomationStepOption(value, 1); - } - - public static AutomationStepOption of(AutomationThrottleStep value) { - return new AutomationStepOption(value, 2); - } - - public static AutomationStepOption of(AutomationCancelStep value) { - return new AutomationStepOption(value, 3); - } - - public static AutomationStepOption of(AutomationDelayStep value) { - return new AutomationStepOption(value, 4); - } - - public static AutomationStepOption of(AutomationFetchDataStep value) { - return new AutomationStepOption(value, 5); - } - - public static AutomationStepOption of(AutomationInvokeStep value) { - return new AutomationStepOption(value, 6); - } - - public static AutomationStepOption of(AutomationSendStep value) { - return new AutomationStepOption(value, 7); - } - - public static AutomationStepOption of(AutomationV2SendStep value) { - return new AutomationStepOption(value, 8); - } - - public static AutomationStepOption of(AutomationSendListStep value) { - return new AutomationStepOption(value, 9); - } - - public static AutomationStepOption of(AutomationUpdateProfileStep value) { - return new AutomationStepOption(value, 10); - } - - public interface Visitor { - T visit(AutomationAddToDigestStep value); - - T visit(AutomationAddToBatchStep value); - - T visit(AutomationThrottleStep value); - - T visit(AutomationCancelStep value); - - T visit(AutomationDelayStep value); - - T visit(AutomationFetchDataStep value); - - T visit(AutomationInvokeStep value); - - T visit(AutomationSendStep value); - - T visit(AutomationV2SendStep value); - - T visit(AutomationSendListStep value); - - T visit(AutomationUpdateProfileStep value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(AutomationStepOption.class); - } - - @java.lang.Override - public AutomationStepOption deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationAddToDigestStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationAddToBatchStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationThrottleStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationCancelStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationDelayStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationFetchDataStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationInvokeStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationSendStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationV2SendStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationSendListStep.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AutomationUpdateProfileStep.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleOnThrottle.java b/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleOnThrottle.java deleted file mode 100644 index 97ffc342..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleOnThrottle.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationThrottleOnThrottle.Builder.class) -public final class AutomationThrottleOnThrottle { - private final String nodeId; - - private final Map additionalProperties; - - private AutomationThrottleOnThrottle(String nodeId, Map additionalProperties) { - this.nodeId = nodeId; - this.additionalProperties = additionalProperties; - } - - /** - * @return The node to go to if the request is throttled - */ - @JsonProperty("$node_id") - public String getNodeId() { - return nodeId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationThrottleOnThrottle && equalTo((AutomationThrottleOnThrottle) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationThrottleOnThrottle other) { - return nodeId.equals(other.nodeId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.nodeId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NodeIdStage builder() { - return new Builder(); - } - - public interface NodeIdStage { - _FinalStage nodeId(String nodeId); - - Builder from(AutomationThrottleOnThrottle other); - } - - public interface _FinalStage { - AutomationThrottleOnThrottle build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NodeIdStage, _FinalStage { - private String nodeId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationThrottleOnThrottle other) { - nodeId(other.getNodeId()); - return this; - } - - /** - *

The node to go to if the request is throttled

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("$node_id") - public _FinalStage nodeId(String nodeId) { - this.nodeId = nodeId; - return this; - } - - @java.lang.Override - public AutomationThrottleOnThrottle build() { - return new AutomationThrottleOnThrottle(nodeId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleScope.java b/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleScope.java deleted file mode 100644 index 7ac404ba..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleScope.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum AutomationThrottleScope { - USER("user"), - - GLOBAL("global"), - - DYNAMIC("dynamic"); - - private final String value; - - AutomationThrottleScope(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleStep.java deleted file mode 100644 index 30639e70..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationThrottleStep.java +++ /dev/null @@ -1,306 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationThrottleStep.Builder.class) -public final class AutomationThrottleStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final int maxAllowed; - - private final String period; - - private final AutomationThrottleScope scope; - - private final Optional throttleKey; - - private final AutomationThrottleOnThrottle onThrottle; - - private final Map additionalProperties; - - private AutomationThrottleStep( - Optional if_, - Optional ref, - int maxAllowed, - String period, - AutomationThrottleScope scope, - Optional throttleKey, - AutomationThrottleOnThrottle onThrottle, - Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.maxAllowed = maxAllowed; - this.period = period; - this.scope = scope; - this.throttleKey = throttleKey; - this.onThrottle = onThrottle; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "throttle"; - } - - /** - * @return Maximum number of allowed notifications in that timeframe - */ - @JsonProperty("max_allowed") - public int getMaxAllowed() { - return maxAllowed; - } - - /** - * @return Defines the throttle period which corresponds to the max_allowed. Specified as an ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations - */ - @JsonProperty("period") - public String getPeriod() { - return period; - } - - @JsonProperty("scope") - public AutomationThrottleScope getScope() { - return scope; - } - - /** - * @return If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) to the how the throttle should be identified - */ - @JsonProperty("throttle_key") - public Optional getThrottleKey() { - return throttleKey; - } - - /** - * @return Value must be true - */ - @JsonProperty("should_alert") - public Boolean getShouldAlert() { - return false; - } - - @JsonProperty("on_throttle") - public AutomationThrottleOnThrottle getOnThrottle() { - return onThrottle; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationThrottleStep && equalTo((AutomationThrottleStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationThrottleStep other) { - return if_.equals(other.if_) - && ref.equals(other.ref) - && maxAllowed == other.maxAllowed - && period.equals(other.period) - && scope.equals(other.scope) - && throttleKey.equals(other.throttleKey) - && onThrottle.equals(other.onThrottle); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.if_, this.ref, this.maxAllowed, this.period, this.scope, this.throttleKey, this.onThrottle); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MaxAllowedStage builder() { - return new Builder(); - } - - public interface MaxAllowedStage { - PeriodStage maxAllowed(int maxAllowed); - - Builder from(AutomationThrottleStep other); - } - - public interface PeriodStage { - ScopeStage period(String period); - } - - public interface ScopeStage { - OnThrottleStage scope(AutomationThrottleScope scope); - } - - public interface OnThrottleStage { - _FinalStage onThrottle(AutomationThrottleOnThrottle onThrottle); - } - - public interface _FinalStage { - AutomationThrottleStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage throttleKey(Optional throttleKey); - - _FinalStage throttleKey(String throttleKey); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements MaxAllowedStage, PeriodStage, ScopeStage, OnThrottleStage, _FinalStage { - private int maxAllowed; - - private String period; - - private AutomationThrottleScope scope; - - private AutomationThrottleOnThrottle onThrottle; - - private Optional throttleKey = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationThrottleStep other) { - if_(other.getIf()); - ref(other.getRef()); - maxAllowed(other.getMaxAllowed()); - period(other.getPeriod()); - scope(other.getScope()); - throttleKey(other.getThrottleKey()); - onThrottle(other.getOnThrottle()); - return this; - } - - /** - *

Maximum number of allowed notifications in that timeframe

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("max_allowed") - public PeriodStage maxAllowed(int maxAllowed) { - this.maxAllowed = maxAllowed; - return this; - } - - /** - *

Defines the throttle period which corresponds to the max_allowed. Specified as an ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("period") - public ScopeStage period(String period) { - this.period = period; - return this; - } - - @java.lang.Override - @JsonSetter("scope") - public OnThrottleStage scope(AutomationThrottleScope scope) { - this.scope = scope; - return this; - } - - @java.lang.Override - @JsonSetter("on_throttle") - public _FinalStage onThrottle(AutomationThrottleOnThrottle onThrottle) { - this.onThrottle = onThrottle; - return this; - } - - /** - *

If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) to the how the throttle should be identified

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage throttleKey(String throttleKey) { - this.throttleKey = Optional.of(throttleKey); - return this; - } - - @java.lang.Override - @JsonSetter(value = "throttle_key", nulls = Nulls.SKIP) - public _FinalStage throttleKey(Optional throttleKey) { - this.throttleKey = throttleKey; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationThrottleStep build() { - return new AutomationThrottleStep( - if_, ref, maxAllowed, period, scope, throttleKey, onThrottle, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationUpdateProfileStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationUpdateProfileStep.java deleted file mode 100644 index 22c23e48..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationUpdateProfileStep.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationUpdateProfileStep.Builder.class) -public final class AutomationUpdateProfileStep { - private final String recipientId; - - private final Object profile; - - private final MergeAlgorithm merge; - - private final Map additionalProperties; - - private AutomationUpdateProfileStep( - String recipientId, Object profile, MergeAlgorithm merge, Map additionalProperties) { - this.recipientId = recipientId; - this.profile = profile; - this.merge = merge; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("action") - public String getAction() { - return "update-profile"; - } - - @JsonProperty("recipient_id") - public String getRecipientId() { - return recipientId; - } - - @JsonProperty("profile") - public Object getProfile() { - return profile; - } - - @JsonProperty("merge") - public MergeAlgorithm getMerge() { - return merge; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationUpdateProfileStep && equalTo((AutomationUpdateProfileStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationUpdateProfileStep other) { - return recipientId.equals(other.recipientId) && profile.equals(other.profile) && merge.equals(other.merge); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recipientId, this.profile, this.merge); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RecipientIdStage builder() { - return new Builder(); - } - - public interface RecipientIdStage { - ProfileStage recipientId(String recipientId); - - Builder from(AutomationUpdateProfileStep other); - } - - public interface ProfileStage { - MergeStage profile(Object profile); - } - - public interface MergeStage { - _FinalStage merge(MergeAlgorithm merge); - } - - public interface _FinalStage { - AutomationUpdateProfileStep build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RecipientIdStage, ProfileStage, MergeStage, _FinalStage { - private String recipientId; - - private Object profile; - - private MergeAlgorithm merge; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationUpdateProfileStep other) { - recipientId(other.getRecipientId()); - profile(other.getProfile()); - merge(other.getMerge()); - return this; - } - - @java.lang.Override - @JsonSetter("recipient_id") - public ProfileStage recipientId(String recipientId) { - this.recipientId = recipientId; - return this; - } - - @java.lang.Override - @JsonSetter("profile") - public MergeStage profile(Object profile) { - this.profile = profile; - return this; - } - - @java.lang.Override - @JsonSetter("merge") - public _FinalStage merge(MergeAlgorithm merge) { - this.merge = merge; - return this; - } - - @java.lang.Override - public AutomationUpdateProfileStep build() { - return new AutomationUpdateProfileStep(recipientId, profile, merge, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/AutomationV2SendStep.java b/src/main/java/com/courier/api/resources/automations/types/AutomationV2SendStep.java deleted file mode 100644 index e89bfb6c..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/AutomationV2SendStep.java +++ /dev/null @@ -1,168 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.send.types.Message; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AutomationV2SendStep.Builder.class) -public final class AutomationV2SendStep implements IAutomationStep { - private final Optional if_; - - private final Optional ref; - - private final Message message; - - private final Map additionalProperties; - - private AutomationV2SendStep( - Optional if_, Optional ref, Message message, Map additionalProperties) { - this.if_ = if_; - this.ref = ref; - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("action") - public String getAction() { - return "send"; - } - - @JsonProperty("message") - public Message getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AutomationV2SendStep && equalTo((AutomationV2SendStep) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AutomationV2SendStep other) { - return if_.equals(other.if_) && ref.equals(other.ref) && message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.if_, this.ref, this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(Message message); - - Builder from(AutomationV2SendStep other); - } - - public interface _FinalStage { - AutomationV2SendStep build(); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private Message message; - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AutomationV2SendStep other) { - if_(other.getIf()); - ref(other.getRef()); - message(other.getMessage()); - return this; - } - - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(Message message) { - this.message = message; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public AutomationV2SendStep build() { - return new AutomationV2SendStep(if_, ref, message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/automations/types/IAutomationInvokeParams.java b/src/main/java/com/courier/api/resources/automations/types/IAutomationInvokeParams.java deleted file mode 100644 index c3562af6..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/IAutomationInvokeParams.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import java.util.Map; -import java.util.Optional; - -public interface IAutomationInvokeParams { - Optional getBrand(); - - Optional> getData(); - - Optional getProfile(); - - Optional getRecipient(); - - Optional getTemplate(); -} diff --git a/src/main/java/com/courier/api/resources/automations/types/IAutomationStep.java b/src/main/java/com/courier/api/resources/automations/types/IAutomationStep.java deleted file mode 100644 index 0b922a58..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/IAutomationStep.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import java.util.Optional; - -public interface IAutomationStep { - Optional getIf(); - - Optional getRef(); -} diff --git a/src/main/java/com/courier/api/resources/automations/types/MergeAlgorithm.java b/src/main/java/com/courier/api/resources/automations/types/MergeAlgorithm.java deleted file mode 100644 index 16985024..00000000 --- a/src/main/java/com/courier/api/resources/automations/types/MergeAlgorithm.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.automations.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum MergeAlgorithm { - REPLACE("replace"), - - NONE("none"), - - OVERWRITE("overwrite"), - - SOFT_MERGE("soft-merge"); - - private final String value; - - MergeAlgorithm(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/brands/BrandsClient.java b/src/main/java/com/courier/api/resources/brands/BrandsClient.java deleted file mode 100644 index 98394e48..00000000 --- a/src/main/java/com/courier/api/resources/brands/BrandsClient.java +++ /dev/null @@ -1,284 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.brands.requests.BrandUpdateParameters; -import com.courier.api.resources.brands.requests.ListBrandsRequest; -import com.courier.api.resources.brands.types.Brand; -import com.courier.api.resources.brands.types.BrandParameters; -import com.courier.api.resources.brands.types.BrandsResponse; -import com.courier.api.resources.commons.errors.CourierApiAlreadyExistsError; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.errors.CourierApiConflictError; -import com.courier.api.resources.commons.errors.CourierApiPaymentRequiredError; -import com.courier.api.resources.commons.types.AlreadyExists; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.commons.types.Conflict; -import com.courier.api.resources.commons.types.PaymentRequired; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class BrandsClient { - protected final ClientOptions clientOptions; - - public BrandsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public Brand create(BrandParameters request) { - return create(request, null); - } - - public Brand create(BrandParameters request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("brands") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Brand.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - case 402: - throw new CourierApiPaymentRequiredError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, PaymentRequired.class)); - case 409: - throw new CourierApiAlreadyExistsError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, AlreadyExists.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Fetch a specific brand by brand ID. - */ - public Brand get(String brandId) { - return get(brandId, null); - } - - /** - * Fetch a specific brand by brand ID. - */ - public Brand get(String brandId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("brands") - .addPathSegment(brandId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Brand.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get the list of brands. - */ - public BrandsResponse list() { - return list(ListBrandsRequest.builder().build()); - } - - /** - * Get the list of brands. - */ - public BrandsResponse list(ListBrandsRequest request) { - return list(request, null); - } - - /** - * Get the list of brands. - */ - public BrandsResponse list(ListBrandsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("brands"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BrandsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Delete a brand by brand ID. - */ - public void delete(String brandId) { - delete(brandId, null); - } - - /** - * Delete a brand by brand ID. - */ - public void delete(String brandId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("brands") - .addPathSegment(brandId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 409) { - throw new CourierApiConflictError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conflict.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Replace an existing brand with the supplied values. - */ - public Brand replace(String brandId, BrandUpdateParameters request) { - return replace(brandId, request, null); - } - - /** - * Replace an existing brand with the supplied values. - */ - public Brand replace(String brandId, BrandUpdateParameters request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("brands") - .addPathSegment(brandId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Brand.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/requests/BrandUpdateParameters.java b/src/main/java/com/courier/api/resources/brands/requests/BrandUpdateParameters.java deleted file mode 100644 index f7c12971..00000000 --- a/src/main/java/com/courier/api/resources/brands/requests/BrandUpdateParameters.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.brands.types.BrandSettings; -import com.courier.api.resources.brands.types.BrandSnippets; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandUpdateParameters.Builder.class) -public final class BrandUpdateParameters { - private final String name; - - private final Optional settings; - - private final Optional snippets; - - private final Map additionalProperties; - - private BrandUpdateParameters( - String name, - Optional settings, - Optional snippets, - Map additionalProperties) { - this.name = name; - this.settings = settings; - this.snippets = snippets; - this.additionalProperties = additionalProperties; - } - - /** - * @return The name of the brand. - */ - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("settings") - public Optional getSettings() { - return settings; - } - - @JsonProperty("snippets") - public Optional getSnippets() { - return snippets; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandUpdateParameters && equalTo((BrandUpdateParameters) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandUpdateParameters other) { - return name.equals(other.name) && settings.equals(other.settings) && snippets.equals(other.snippets); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.name, this.settings, this.snippets); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - _FinalStage name(String name); - - Builder from(BrandUpdateParameters other); - } - - public interface _FinalStage { - BrandUpdateParameters build(); - - _FinalStage settings(Optional settings); - - _FinalStage settings(BrandSettings settings); - - _FinalStage snippets(Optional snippets); - - _FinalStage snippets(BrandSnippets snippets); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NameStage, _FinalStage { - private String name; - - private Optional snippets = Optional.empty(); - - private Optional settings = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandUpdateParameters other) { - name(other.getName()); - settings(other.getSettings()); - snippets(other.getSnippets()); - return this; - } - - /** - *

The name of the brand.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - public _FinalStage snippets(BrandSnippets snippets) { - this.snippets = Optional.of(snippets); - return this; - } - - @java.lang.Override - @JsonSetter(value = "snippets", nulls = Nulls.SKIP) - public _FinalStage snippets(Optional snippets) { - this.snippets = snippets; - return this; - } - - @java.lang.Override - public _FinalStage settings(BrandSettings settings) { - this.settings = Optional.of(settings); - return this; - } - - @java.lang.Override - @JsonSetter(value = "settings", nulls = Nulls.SKIP) - public _FinalStage settings(Optional settings) { - this.settings = settings; - return this; - } - - @java.lang.Override - public BrandUpdateParameters build() { - return new BrandUpdateParameters(name, settings, snippets, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/requests/ListBrandsRequest.java b/src/main/java/com/courier/api/resources/brands/requests/ListBrandsRequest.java deleted file mode 100644 index e36bef4b..00000000 --- a/src/main/java/com/courier/api/resources/brands/requests/ListBrandsRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListBrandsRequest.Builder.class) -public final class ListBrandsRequest { - private final Optional cursor; - - private final Map additionalProperties; - - private ListBrandsRequest(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of brands. - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListBrandsRequest && equalTo((ListBrandsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListBrandsRequest other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListBrandsRequest other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListBrandsRequest build() { - return new ListBrandsRequest(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/Brand.java b/src/main/java/com/courier/api/resources/brands/types/Brand.java deleted file mode 100644 index c379f033..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/Brand.java +++ /dev/null @@ -1,336 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Brand.Builder.class) -public final class Brand { - private final int created; - - private final Optional id; - - private final String name; - - private final int published; - - private final BrandSettings settings; - - private final int updated; - - private final Optional snippets; - - private final String version; - - private final Map additionalProperties; - - private Brand( - int created, - Optional id, - String name, - int published, - BrandSettings settings, - int updated, - Optional snippets, - String version, - Map additionalProperties) { - this.created = created; - this.id = id; - this.name = name; - this.published = published; - this.settings = settings; - this.updated = updated; - this.snippets = snippets; - this.version = version; - this.additionalProperties = additionalProperties; - } - - /** - * @return The date/time of when the brand was created. Represented in milliseconds since Unix epoch. - */ - @JsonProperty("created") - public int getCreated() { - return created; - } - - /** - * @return Brand Identifier - */ - @JsonProperty("id") - public Optional getId() { - return id; - } - - /** - * @return Brand name - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return The date/time of when the brand was published. Represented in milliseconds since Unix epoch. - */ - @JsonProperty("published") - public int getPublished() { - return published; - } - - @JsonProperty("settings") - public BrandSettings getSettings() { - return settings; - } - - /** - * @return The date/time of when the brand was updated. Represented in milliseconds since Unix epoch. - */ - @JsonProperty("updated") - public int getUpdated() { - return updated; - } - - @JsonProperty("snippets") - public Optional getSnippets() { - return snippets; - } - - /** - * @return The version identifier for the brand - */ - @JsonProperty("version") - public String getVersion() { - return version; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Brand && equalTo((Brand) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Brand other) { - return created == other.created - && id.equals(other.id) - && name.equals(other.name) - && published == other.published - && settings.equals(other.settings) - && updated == other.updated - && snippets.equals(other.snippets) - && version.equals(other.version); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.created, - this.id, - this.name, - this.published, - this.settings, - this.updated, - this.snippets, - this.version); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static CreatedStage builder() { - return new Builder(); - } - - public interface CreatedStage { - NameStage created(int created); - - Builder from(Brand other); - } - - public interface NameStage { - PublishedStage name(String name); - } - - public interface PublishedStage { - SettingsStage published(int published); - } - - public interface SettingsStage { - UpdatedStage settings(BrandSettings settings); - } - - public interface UpdatedStage { - VersionStage updated(int updated); - } - - public interface VersionStage { - _FinalStage version(String version); - } - - public interface _FinalStage { - Brand build(); - - _FinalStage id(Optional id); - - _FinalStage id(String id); - - _FinalStage snippets(Optional snippets); - - _FinalStage snippets(BrandSnippets snippets); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements CreatedStage, NameStage, PublishedStage, SettingsStage, UpdatedStage, VersionStage, _FinalStage { - private int created; - - private String name; - - private int published; - - private BrandSettings settings; - - private int updated; - - private String version; - - private Optional snippets = Optional.empty(); - - private Optional id = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Brand other) { - created(other.getCreated()); - id(other.getId()); - name(other.getName()); - published(other.getPublished()); - settings(other.getSettings()); - updated(other.getUpdated()); - snippets(other.getSnippets()); - version(other.getVersion()); - return this; - } - - /** - *

The date/time of when the brand was created. Represented in milliseconds since Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created") - public NameStage created(int created) { - this.created = created; - return this; - } - - /** - *

Brand name

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public PublishedStage name(String name) { - this.name = name; - return this; - } - - /** - *

The date/time of when the brand was published. Represented in milliseconds since Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("published") - public SettingsStage published(int published) { - this.published = published; - return this; - } - - @java.lang.Override - @JsonSetter("settings") - public UpdatedStage settings(BrandSettings settings) { - this.settings = settings; - return this; - } - - /** - *

The date/time of when the brand was updated. Represented in milliseconds since Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated") - public VersionStage updated(int updated) { - this.updated = updated; - return this; - } - - /** - *

The version identifier for the brand

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("version") - public _FinalStage version(String version) { - this.version = version; - return this; - } - - @java.lang.Override - public _FinalStage snippets(BrandSnippets snippets) { - this.snippets = Optional.of(snippets); - return this; - } - - @java.lang.Override - @JsonSetter(value = "snippets", nulls = Nulls.SKIP) - public _FinalStage snippets(Optional snippets) { - this.snippets = snippets; - return this; - } - - /** - *

Brand Identifier

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage id(String id) { - this.id = Optional.of(id); - return this; - } - - @java.lang.Override - @JsonSetter(value = "id", nulls = Nulls.SKIP) - public _FinalStage id(Optional id) { - this.id = id; - return this; - } - - @java.lang.Override - public Brand build() { - return new Brand(created, id, name, published, settings, updated, snippets, version, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandColors.java b/src/main/java/com/courier/api/resources/brands/types/BrandColors.java deleted file mode 100644 index a20cb535..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandColors.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandColors.Builder.class) -public final class BrandColors { - private final Optional primary; - - private final Optional secondary; - - private final Optional tertiary; - - private final Map additionalProperties; - - private BrandColors( - Optional primary, - Optional secondary, - Optional tertiary, - Map additionalProperties) { - this.primary = primary; - this.secondary = secondary; - this.tertiary = tertiary; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("primary") - public Optional getPrimary() { - return primary; - } - - @JsonProperty("secondary") - public Optional getSecondary() { - return secondary; - } - - @JsonProperty("tertiary") - public Optional getTertiary() { - return tertiary; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandColors && equalTo((BrandColors) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandColors other) { - return primary.equals(other.primary) && secondary.equals(other.secondary) && tertiary.equals(other.tertiary); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.primary, this.secondary, this.tertiary); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional primary = Optional.empty(); - - private Optional secondary = Optional.empty(); - - private Optional tertiary = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BrandColors other) { - primary(other.getPrimary()); - secondary(other.getSecondary()); - tertiary(other.getTertiary()); - return this; - } - - @JsonSetter(value = "primary", nulls = Nulls.SKIP) - public Builder primary(Optional primary) { - this.primary = primary; - return this; - } - - public Builder primary(String primary) { - this.primary = Optional.of(primary); - return this; - } - - @JsonSetter(value = "secondary", nulls = Nulls.SKIP) - public Builder secondary(Optional secondary) { - this.secondary = secondary; - return this; - } - - public Builder secondary(String secondary) { - this.secondary = Optional.of(secondary); - return this; - } - - @JsonSetter(value = "tertiary", nulls = Nulls.SKIP) - public Builder tertiary(Optional tertiary) { - this.tertiary = tertiary; - return this; - } - - public Builder tertiary(String tertiary) { - this.tertiary = Optional.of(tertiary); - return this; - } - - public BrandColors build() { - return new BrandColors(primary, secondary, tertiary, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandGetAllResponse.java b/src/main/java/com/courier/api/resources/brands/types/BrandGetAllResponse.java deleted file mode 100644 index 797f81e3..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandGetAllResponse.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandGetAllResponse.Builder.class) -public final class BrandGetAllResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private BrandGetAllResponse(Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandGetAllResponse && equalTo((BrandGetAllResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandGetAllResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(BrandGetAllResponse other); - } - - public interface _FinalStage { - BrandGetAllResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(Brand results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandGetAllResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - @java.lang.Override - public _FinalStage addResults(Brand results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public BrandGetAllResponse build() { - return new BrandGetAllResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandParameters.java b/src/main/java/com/courier/api/resources/brands/types/BrandParameters.java deleted file mode 100644 index 56385b08..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandParameters.java +++ /dev/null @@ -1,196 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandParameters.Builder.class) -public final class BrandParameters { - private final Optional id; - - private final String name; - - private final BrandSettings settings; - - private final Optional snippets; - - private final Map additionalProperties; - - private BrandParameters( - Optional id, - String name, - BrandSettings settings, - Optional snippets, - Map additionalProperties) { - this.id = id; - this.name = name; - this.settings = settings; - this.snippets = snippets; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public Optional getId() { - return id; - } - - /** - * @return The name of the brand. - */ - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("settings") - public BrandSettings getSettings() { - return settings; - } - - @JsonProperty("snippets") - public Optional getSnippets() { - return snippets; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandParameters && equalTo((BrandParameters) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandParameters other) { - return id.equals(other.id) - && name.equals(other.name) - && settings.equals(other.settings) - && snippets.equals(other.snippets); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.name, this.settings, this.snippets); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - SettingsStage name(String name); - - Builder from(BrandParameters other); - } - - public interface SettingsStage { - _FinalStage settings(BrandSettings settings); - } - - public interface _FinalStage { - BrandParameters build(); - - _FinalStage id(Optional id); - - _FinalStage id(String id); - - _FinalStage snippets(Optional snippets); - - _FinalStage snippets(BrandSnippets snippets); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NameStage, SettingsStage, _FinalStage { - private String name; - - private BrandSettings settings; - - private Optional snippets = Optional.empty(); - - private Optional id = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandParameters other) { - id(other.getId()); - name(other.getName()); - settings(other.getSettings()); - snippets(other.getSnippets()); - return this; - } - - /** - *

The name of the brand.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public SettingsStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - @JsonSetter("settings") - public _FinalStage settings(BrandSettings settings) { - this.settings = settings; - return this; - } - - @java.lang.Override - public _FinalStage snippets(BrandSnippets snippets) { - this.snippets = Optional.of(snippets); - return this; - } - - @java.lang.Override - @JsonSetter(value = "snippets", nulls = Nulls.SKIP) - public _FinalStage snippets(Optional snippets) { - this.snippets = snippets; - return this; - } - - @java.lang.Override - public _FinalStage id(String id) { - this.id = Optional.of(id); - return this; - } - - @java.lang.Override - @JsonSetter(value = "id", nulls = Nulls.SKIP) - public _FinalStage id(Optional id) { - this.id = id; - return this; - } - - @java.lang.Override - public BrandParameters build() { - return new BrandParameters(id, name, settings, snippets, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandSettings.java b/src/main/java/com/courier/api/resources/brands/types/BrandSettings.java deleted file mode 100644 index 5f927c88..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandSettings.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Email; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandSettings.Builder.class) -public final class BrandSettings { - private final Optional colors; - - private final Optional inapp; - - private final Optional email; - - private final Map additionalProperties; - - private BrandSettings( - Optional colors, - Optional inapp, - Optional email, - Map additionalProperties) { - this.colors = colors; - this.inapp = inapp; - this.email = email; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("colors") - public Optional getColors() { - return colors; - } - - @JsonProperty("inapp") - public Optional getInapp() { - return inapp; - } - - @JsonProperty("email") - public Optional getEmail() { - return email; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandSettings && equalTo((BrandSettings) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandSettings other) { - return colors.equals(other.colors) && inapp.equals(other.inapp) && email.equals(other.email); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.colors, this.inapp, this.email); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional colors = Optional.empty(); - - private Optional inapp = Optional.empty(); - - private Optional email = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BrandSettings other) { - colors(other.getColors()); - inapp(other.getInapp()); - email(other.getEmail()); - return this; - } - - @JsonSetter(value = "colors", nulls = Nulls.SKIP) - public Builder colors(Optional colors) { - this.colors = colors; - return this; - } - - public Builder colors(BrandColors colors) { - this.colors = Optional.of(colors); - return this; - } - - @JsonSetter(value = "inapp", nulls = Nulls.SKIP) - public Builder inapp(Optional inapp) { - this.inapp = inapp; - return this; - } - - public Builder inapp(Object inapp) { - this.inapp = Optional.of(inapp); - return this; - } - - @JsonSetter(value = "email", nulls = Nulls.SKIP) - public Builder email(Optional email) { - this.email = email; - return this; - } - - public Builder email(Email email) { - this.email = Optional.of(email); - return this; - } - - public BrandSettings build() { - return new BrandSettings(colors, inapp, email, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandSnippet.java b/src/main/java/com/courier/api/resources/brands/types/BrandSnippet.java deleted file mode 100644 index 0d9b9ad3..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandSnippet.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandSnippet.Builder.class) -public final class BrandSnippet { - private final String name; - - private final String value; - - private final Map additionalProperties; - - private BrandSnippet(String name, String value, Map additionalProperties) { - this.name = name; - this.value = value; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("format") - public String getFormat() { - return "handlebars"; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandSnippet && equalTo((BrandSnippet) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandSnippet other) { - return name.equals(other.name) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.name, this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - ValueStage name(String name); - - Builder from(BrandSnippet other); - } - - public interface ValueStage { - _FinalStage value(String value); - } - - public interface _FinalStage { - BrandSnippet build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NameStage, ValueStage, _FinalStage { - private String name; - - private String value; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandSnippet other) { - name(other.getName()); - value(other.getValue()); - return this; - } - - @java.lang.Override - @JsonSetter("name") - public ValueStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(String value) { - this.value = value; - return this; - } - - @java.lang.Override - public BrandSnippet build() { - return new BrandSnippet(name, value, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandSnippets.java b/src/main/java/com/courier/api/resources/brands/types/BrandSnippets.java deleted file mode 100644 index 865b4c9c..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandSnippets.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandSnippets.Builder.class) -public final class BrandSnippets { - private final List items; - - private final Map additionalProperties; - - private BrandSnippets(List items, Map additionalProperties) { - this.items = items; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public List getItems() { - return items; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandSnippets && equalTo((BrandSnippets) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandSnippets other) { - return items.equals(other.items); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BrandSnippets other) { - items(other.getItems()); - return this; - } - - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public Builder items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - public Builder addItems(BrandSnippet items) { - this.items.add(items); - return this; - } - - public Builder addAllItems(List items) { - this.items.addAll(items); - return this; - } - - public BrandSnippets build() { - return new BrandSnippets(items, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/brands/types/BrandsResponse.java b/src/main/java/com/courier/api/resources/brands/types/BrandsResponse.java deleted file mode 100644 index b8e56a32..00000000 --- a/src/main/java/com/courier/api/resources/brands/types/BrandsResponse.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.brands.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandsResponse.Builder.class) -public final class BrandsResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private BrandsResponse(Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandsResponse && equalTo((BrandsResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandsResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(BrandsResponse other); - } - - public interface _FinalStage { - BrandsResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(Brand results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandsResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - @java.lang.Override - public _FinalStage addResults(Brand results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public BrandsResponse build() { - return new BrandsResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/BulkClient.java b/src/main/java/com/courier/api/resources/bulk/BulkClient.java deleted file mode 100644 index 87e8f904..00000000 --- a/src/main/java/com/courier/api/resources/bulk/BulkClient.java +++ /dev/null @@ -1,291 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.bulk.requests.BulkCreateJobParams; -import com.courier.api.resources.bulk.requests.BulkGetUsersParams; -import com.courier.api.resources.bulk.types.BulkCreateJobResponse; -import com.courier.api.resources.bulk.types.BulkGetJobResponse; -import com.courier.api.resources.bulk.types.BulkGetJobUsersResponse; -import com.courier.api.resources.bulk.types.BulkIngestUsersParams; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.types.BadRequest; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class BulkClient { - protected final ClientOptions clientOptions; - - public BulkClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public BulkCreateJobResponse createJob(BulkCreateJobParams request) { - return createJob(request, null); - } - - public BulkCreateJobResponse createJob(BulkCreateJobParams request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("bulk") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BulkCreateJobResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Ingest user data into a Bulk Job - */ - public void ingestUsers(String jobId, BulkIngestUsersParams request) { - ingestUsers(jobId, request, null); - } - - /** - * Ingest user data into a Bulk Job - */ - public void ingestUsers(String jobId, BulkIngestUsersParams request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("bulk") - .addPathSegment(jobId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Run a bulk job - */ - public void runJob(String jobId) { - runJob(jobId, null); - } - - /** - * Run a bulk job - */ - public void runJob(String jobId, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("bulk") - .addPathSegment(jobId) - .addPathSegments("run") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get a bulk job - */ - public BulkGetJobResponse getJob(String jobId) { - return getJob(jobId, null); - } - - /** - * Get a bulk job - */ - public BulkGetJobResponse getJob(String jobId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("bulk") - .addPathSegment(jobId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BulkGetJobResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get Bulk Job Users - */ - public BulkGetJobUsersResponse getUsers(String jobId) { - return getUsers(jobId, BulkGetUsersParams.builder().build()); - } - - /** - * Get Bulk Job Users - */ - public BulkGetJobUsersResponse getUsers(String jobId, BulkGetUsersParams request) { - return getUsers(jobId, request, null); - } - - /** - * Get Bulk Job Users - */ - public BulkGetJobUsersResponse getUsers(String jobId, BulkGetUsersParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("bulk") - .addPathSegment(jobId) - .addPathSegments("users"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), BulkGetJobUsersResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/requests/BulkCreateJobParams.java b/src/main/java/com/courier/api/resources/bulk/requests/BulkCreateJobParams.java deleted file mode 100644 index 5e33bccd..00000000 --- a/src/main/java/com/courier/api/resources/bulk/requests/BulkCreateJobParams.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.bulk.types.InboundBulkMessage; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkCreateJobParams.Builder.class) -public final class BulkCreateJobParams { - private final InboundBulkMessage message; - - private final Map additionalProperties; - - private BulkCreateJobParams(InboundBulkMessage message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("message") - public InboundBulkMessage getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkCreateJobParams && equalTo((BulkCreateJobParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkCreateJobParams other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(InboundBulkMessage message); - - Builder from(BulkCreateJobParams other); - } - - public interface _FinalStage { - BulkCreateJobParams build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private InboundBulkMessage message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkCreateJobParams other) { - message(other.getMessage()); - return this; - } - - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(InboundBulkMessage message) { - this.message = message; - return this; - } - - @java.lang.Override - public BulkCreateJobParams build() { - return new BulkCreateJobParams(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/requests/BulkGetUsersParams.java b/src/main/java/com/courier/api/resources/bulk/requests/BulkGetUsersParams.java deleted file mode 100644 index ca6bee3c..00000000 --- a/src/main/java/com/courier/api/resources/bulk/requests/BulkGetUsersParams.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkGetUsersParams.Builder.class) -public final class BulkGetUsersParams { - private final Optional cursor; - - private final Map additionalProperties; - - private BulkGetUsersParams(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of users added to the bulk job - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkGetUsersParams && equalTo((BulkGetUsersParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkGetUsersParams other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BulkGetUsersParams other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public BulkGetUsersParams build() { - return new BulkGetUsersParams(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkCreateJobResponse.java b/src/main/java/com/courier/api/resources/bulk/types/BulkCreateJobResponse.java deleted file mode 100644 index 81b9177a..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkCreateJobResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkCreateJobResponse.Builder.class) -public final class BulkCreateJobResponse { - private final String jobId; - - private final Map additionalProperties; - - private BulkCreateJobResponse(String jobId, Map additionalProperties) { - this.jobId = jobId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("jobId") - public String getJobId() { - return jobId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkCreateJobResponse && equalTo((BulkCreateJobResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkCreateJobResponse other) { - return jobId.equals(other.jobId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.jobId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static JobIdStage builder() { - return new Builder(); - } - - public interface JobIdStage { - _FinalStage jobId(String jobId); - - Builder from(BulkCreateJobResponse other); - } - - public interface _FinalStage { - BulkCreateJobResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements JobIdStage, _FinalStage { - private String jobId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkCreateJobResponse other) { - jobId(other.getJobId()); - return this; - } - - @java.lang.Override - @JsonSetter("jobId") - public _FinalStage jobId(String jobId) { - this.jobId = jobId; - return this; - } - - @java.lang.Override - public BulkCreateJobResponse build() { - return new BulkCreateJobResponse(jobId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobParams.java b/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobParams.java deleted file mode 100644 index 2914a70d..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobParams.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkGetJobParams.Builder.class) -public final class BulkGetJobParams { - private final String jobId; - - private final Map additionalProperties; - - private BulkGetJobParams(String jobId, Map additionalProperties) { - this.jobId = jobId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("jobId") - public String getJobId() { - return jobId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkGetJobParams && equalTo((BulkGetJobParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkGetJobParams other) { - return jobId.equals(other.jobId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.jobId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static JobIdStage builder() { - return new Builder(); - } - - public interface JobIdStage { - _FinalStage jobId(String jobId); - - Builder from(BulkGetJobParams other); - } - - public interface _FinalStage { - BulkGetJobParams build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements JobIdStage, _FinalStage { - private String jobId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkGetJobParams other) { - jobId(other.getJobId()); - return this; - } - - @java.lang.Override - @JsonSetter("jobId") - public _FinalStage jobId(String jobId) { - this.jobId = jobId; - return this; - } - - @java.lang.Override - public BulkGetJobParams build() { - return new BulkGetJobParams(jobId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobResponse.java b/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobResponse.java deleted file mode 100644 index 01389305..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkGetJobResponse.Builder.class) -public final class BulkGetJobResponse { - private final JobDetails job; - - private final Map additionalProperties; - - private BulkGetJobResponse(JobDetails job, Map additionalProperties) { - this.job = job; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("job") - public JobDetails getJob() { - return job; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkGetJobResponse && equalTo((BulkGetJobResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkGetJobResponse other) { - return job.equals(other.job); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.job); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static JobStage builder() { - return new Builder(); - } - - public interface JobStage { - _FinalStage job(JobDetails job); - - Builder from(BulkGetJobResponse other); - } - - public interface _FinalStage { - BulkGetJobResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements JobStage, _FinalStage { - private JobDetails job; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkGetJobResponse other) { - job(other.getJob()); - return this; - } - - @java.lang.Override - @JsonSetter("job") - public _FinalStage job(JobDetails job) { - this.job = job; - return this; - } - - @java.lang.Override - public BulkGetJobResponse build() { - return new BulkGetJobResponse(job, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersParams.java b/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersParams.java deleted file mode 100644 index eb94b585..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersParams.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkGetJobUsersParams.Builder.class) -public final class BulkGetJobUsersParams { - private final String jobId; - - private final Optional cursor; - - private final Map additionalProperties; - - private BulkGetJobUsersParams(String jobId, Optional cursor, Map additionalProperties) { - this.jobId = jobId; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("jobId") - public String getJobId() { - return jobId; - } - - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkGetJobUsersParams && equalTo((BulkGetJobUsersParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkGetJobUsersParams other) { - return jobId.equals(other.jobId) && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.jobId, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static JobIdStage builder() { - return new Builder(); - } - - public interface JobIdStage { - _FinalStage jobId(String jobId); - - Builder from(BulkGetJobUsersParams other); - } - - public interface _FinalStage { - BulkGetJobUsersParams build(); - - _FinalStage cursor(Optional cursor); - - _FinalStage cursor(String cursor); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements JobIdStage, _FinalStage { - private String jobId; - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkGetJobUsersParams other) { - jobId(other.getJobId()); - cursor(other.getCursor()); - return this; - } - - @java.lang.Override - @JsonSetter("jobId") - public _FinalStage jobId(String jobId) { - this.jobId = jobId; - return this; - } - - @java.lang.Override - public _FinalStage cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public _FinalStage cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - @java.lang.Override - public BulkGetJobUsersParams build() { - return new BulkGetJobUsersParams(jobId, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersResponse.java b/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersResponse.java deleted file mode 100644 index 9e41d59c..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkGetJobUsersResponse.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkGetJobUsersResponse.Builder.class) -public final class BulkGetJobUsersResponse { - private final List items; - - private final Paging paging; - - private final Map additionalProperties; - - private BulkGetJobUsersResponse( - List items, Paging paging, Map additionalProperties) { - this.items = items; - this.paging = paging; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public List getItems() { - return items; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkGetJobUsersResponse && equalTo((BulkGetJobUsersResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkGetJobUsersResponse other) { - return items.equals(other.items) && paging.equals(other.paging); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items, this.paging); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(BulkGetJobUsersResponse other); - } - - public interface _FinalStage { - BulkGetJobUsersResponse build(); - - _FinalStage items(List items); - - _FinalStage addItems(BulkMessageUserResponse items); - - _FinalStage addAllItems(List items); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkGetJobUsersResponse other) { - items(other.getItems()); - paging(other.getPaging()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllItems(List items) { - this.items.addAll(items); - return this; - } - - @java.lang.Override - public _FinalStage addItems(BulkMessageUserResponse items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - @java.lang.Override - public BulkGetJobUsersResponse build() { - return new BulkGetJobUsersResponse(items, paging, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkIngestError.java b/src/main/java/com/courier/api/resources/bulk/types/BulkIngestError.java deleted file mode 100644 index 501435b2..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkIngestError.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkIngestError.Builder.class) -public final class BulkIngestError { - private final Object user; - - private final Object error; - - private final Map additionalProperties; - - private BulkIngestError(Object user, Object error, Map additionalProperties) { - this.user = user; - this.error = error; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user") - public Object getUser() { - return user; - } - - @JsonProperty("error") - public Object getError() { - return error; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkIngestError && equalTo((BulkIngestError) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkIngestError other) { - return user.equals(other.user) && error.equals(other.error); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.user, this.error); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserStage builder() { - return new Builder(); - } - - public interface UserStage { - ErrorStage user(Object user); - - Builder from(BulkIngestError other); - } - - public interface ErrorStage { - _FinalStage error(Object error); - } - - public interface _FinalStage { - BulkIngestError build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserStage, ErrorStage, _FinalStage { - private Object user; - - private Object error; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkIngestError other) { - user(other.getUser()); - error(other.getError()); - return this; - } - - @java.lang.Override - @JsonSetter("user") - public ErrorStage user(Object user) { - this.user = user; - return this; - } - - @java.lang.Override - @JsonSetter("error") - public _FinalStage error(Object error) { - this.error = error; - return this; - } - - @java.lang.Override - public BulkIngestError build() { - return new BulkIngestError(user, error, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersParams.java b/src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersParams.java deleted file mode 100644 index f4214ef6..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersParams.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkIngestUsersParams.Builder.class) -public final class BulkIngestUsersParams { - private final List users; - - private final Map additionalProperties; - - private BulkIngestUsersParams(List users, Map additionalProperties) { - this.users = users; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("users") - public List getUsers() { - return users; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkIngestUsersParams && equalTo((BulkIngestUsersParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkIngestUsersParams other) { - return users.equals(other.users); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.users); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List users = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BulkIngestUsersParams other) { - users(other.getUsers()); - return this; - } - - @JsonSetter(value = "users", nulls = Nulls.SKIP) - public Builder users(List users) { - this.users.clear(); - this.users.addAll(users); - return this; - } - - public Builder addUsers(InboundBulkMessageUser users) { - this.users.add(users); - return this; - } - - public Builder addAllUsers(List users) { - this.users.addAll(users); - return this; - } - - public BulkIngestUsersParams build() { - return new BulkIngestUsersParams(users, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersResponse.java b/src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersResponse.java deleted file mode 100644 index 2eb975dc..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkIngestUsersResponse.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkIngestUsersResponse.Builder.class) -public final class BulkIngestUsersResponse { - private final int total; - - private final Optional> errors; - - private final Map additionalProperties; - - private BulkIngestUsersResponse( - int total, Optional> errors, Map additionalProperties) { - this.total = total; - this.errors = errors; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("total") - public int getTotal() { - return total; - } - - @JsonProperty("errors") - public Optional> getErrors() { - return errors; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkIngestUsersResponse && equalTo((BulkIngestUsersResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkIngestUsersResponse other) { - return total == other.total && errors.equals(other.errors); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.total, this.errors); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TotalStage builder() { - return new Builder(); - } - - public interface TotalStage { - _FinalStage total(int total); - - Builder from(BulkIngestUsersResponse other); - } - - public interface _FinalStage { - BulkIngestUsersResponse build(); - - _FinalStage errors(Optional> errors); - - _FinalStage errors(List errors); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TotalStage, _FinalStage { - private int total; - - private Optional> errors = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkIngestUsersResponse other) { - total(other.getTotal()); - errors(other.getErrors()); - return this; - } - - @java.lang.Override - @JsonSetter("total") - public _FinalStage total(int total) { - this.total = total; - return this; - } - - @java.lang.Override - public _FinalStage errors(List errors) { - this.errors = Optional.of(errors); - return this; - } - - @java.lang.Override - @JsonSetter(value = "errors", nulls = Nulls.SKIP) - public _FinalStage errors(Optional> errors) { - this.errors = errors; - return this; - } - - @java.lang.Override - public BulkIngestUsersResponse build() { - return new BulkIngestUsersResponse(total, errors, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkJobStatus.java b/src/main/java/com/courier/api/resources/bulk/types/BulkJobStatus.java deleted file mode 100644 index 62c24998..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkJobStatus.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum BulkJobStatus { - CREATED("CREATED"), - - PROCESSING("PROCESSING"), - - COMPLETED("COMPLETED"), - - ERROR("ERROR"); - - private final String value; - - BulkJobStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkJobUserStatus.java b/src/main/java/com/courier/api/resources/bulk/types/BulkJobUserStatus.java deleted file mode 100644 index de787d32..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkJobUserStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum BulkJobUserStatus { - PENDING("PENDING"), - - ENQUEUED("ENQUEUED"), - - ERROR("ERROR"); - - private final String value; - - BulkJobUserStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/BulkMessageUserResponse.java b/src/main/java/com/courier/api/resources/bulk/types/BulkMessageUserResponse.java deleted file mode 100644 index b2aaa8c7..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/BulkMessageUserResponse.java +++ /dev/null @@ -1,294 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.courier.api.resources.send.types.UserRecipient; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BulkMessageUserResponse.Builder.class) -public final class BulkMessageUserResponse implements IInboundBulkMessageUser { - private final Optional preferences; - - private final Optional profile; - - private final Optional recipient; - - private final Optional data; - - private final Optional to; - - private final BulkJobUserStatus status; - - private final Optional messageId; - - private final Map additionalProperties; - - private BulkMessageUserResponse( - Optional preferences, - Optional profile, - Optional recipient, - Optional data, - Optional to, - BulkJobUserStatus status, - Optional messageId, - Map additionalProperties) { - this.preferences = preferences; - this.profile = profile; - this.recipient = recipient; - this.data = data; - this.to = to; - this.status = status; - this.messageId = messageId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - @JsonProperty("profile") - @java.lang.Override - public Optional getProfile() { - return profile; - } - - @JsonProperty("recipient") - @java.lang.Override - public Optional getRecipient() { - return recipient; - } - - @JsonProperty("data") - @java.lang.Override - public Optional getData() { - return data; - } - - @JsonProperty("to") - @java.lang.Override - public Optional getTo() { - return to; - } - - @JsonProperty("status") - public BulkJobUserStatus getStatus() { - return status; - } - - @JsonProperty("messageId") - public Optional getMessageId() { - return messageId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BulkMessageUserResponse && equalTo((BulkMessageUserResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BulkMessageUserResponse other) { - return preferences.equals(other.preferences) - && profile.equals(other.profile) - && recipient.equals(other.recipient) - && data.equals(other.data) - && to.equals(other.to) - && status.equals(other.status) - && messageId.equals(other.messageId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.preferences, this.profile, this.recipient, this.data, this.to, this.status, this.messageId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - _FinalStage status(BulkJobUserStatus status); - - Builder from(BulkMessageUserResponse other); - } - - public interface _FinalStage { - BulkMessageUserResponse build(); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(RecipientPreferences preferences); - - _FinalStage profile(Optional profile); - - _FinalStage profile(Object profile); - - _FinalStage recipient(Optional recipient); - - _FinalStage recipient(String recipient); - - _FinalStage data(Optional data); - - _FinalStage data(Object data); - - _FinalStage to(Optional to); - - _FinalStage to(UserRecipient to); - - _FinalStage messageId(Optional messageId); - - _FinalStage messageId(String messageId); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, _FinalStage { - private BulkJobUserStatus status; - - private Optional messageId = Optional.empty(); - - private Optional to = Optional.empty(); - - private Optional data = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BulkMessageUserResponse other) { - preferences(other.getPreferences()); - profile(other.getProfile()); - recipient(other.getRecipient()); - data(other.getData()); - to(other.getTo()); - status(other.getStatus()); - messageId(other.getMessageId()); - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(BulkJobUserStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - public _FinalStage messageId(String messageId) { - this.messageId = Optional.of(messageId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "messageId", nulls = Nulls.SKIP) - public _FinalStage messageId(Optional messageId) { - this.messageId = messageId; - return this; - } - - @java.lang.Override - public _FinalStage to(UserRecipient to) { - this.to = Optional.of(to); - return this; - } - - @java.lang.Override - @JsonSetter(value = "to", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { - this.to = to; - return this; - } - - @java.lang.Override - public _FinalStage data(Object data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional data) { - this.data = data; - return this; - } - - @java.lang.Override - public _FinalStage recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @java.lang.Override - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public _FinalStage recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - @java.lang.Override - public _FinalStage profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public _FinalStage profile(Optional profile) { - this.profile = profile; - return this; - } - - @java.lang.Override - public _FinalStage preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public BulkMessageUserResponse build() { - return new BulkMessageUserResponse( - preferences, profile, recipient, data, to, status, messageId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageUser.java b/src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageUser.java deleted file mode 100644 index ccc37591..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageUser.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.courier.api.resources.send.types.UserRecipient; -import java.util.Optional; - -public interface IInboundBulkMessageUser { - Optional getPreferences(); - - Optional getProfile(); - - Optional getRecipient(); - - Optional getData(); - - Optional getTo(); -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageV1.java b/src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageV1.java deleted file mode 100644 index b1132845..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/IInboundBulkMessageV1.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import java.util.Map; -import java.util.Optional; - -public interface IInboundBulkMessageV1 { - Optional getBrand(); - - Optional> getData(); - - Optional getEvent(); - - Optional> getLocale(); - - Optional getOverride(); -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkContentMessage.java b/src/main/java/com/courier/api/resources/bulk/types/InboundBulkContentMessage.java deleted file mode 100644 index dfca3301..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkContentMessage.java +++ /dev/null @@ -1,551 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.send.types.Channel; -import com.courier.api.resources.send.types.Content; -import com.courier.api.resources.send.types.Delay; -import com.courier.api.resources.send.types.Expiry; -import com.courier.api.resources.send.types.IBaseMessage; -import com.courier.api.resources.send.types.MessageContext; -import com.courier.api.resources.send.types.MessageMetadata; -import com.courier.api.resources.send.types.MessagePreferences; -import com.courier.api.resources.send.types.MessageProvidersType; -import com.courier.api.resources.send.types.Routing; -import com.courier.api.resources.send.types.Timeout; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InboundBulkContentMessage.Builder.class) -public final class InboundBulkContentMessage implements IBaseMessage { - private final Optional> data; - - private final Optional brandId; - - private final Optional> channels; - - private final Optional context; - - private final Optional metadata; - - private final Optional preferences; - - private final Optional> providers; - - private final Optional routing; - - private final Optional timeout; - - private final Optional delay; - - private final Optional expiry; - - private final Content content; - - private final Map additionalProperties; - - private InboundBulkContentMessage( - Optional> data, - Optional brandId, - Optional> channels, - Optional context, - Optional metadata, - Optional preferences, - Optional> providers, - Optional routing, - Optional timeout, - Optional delay, - Optional expiry, - Content content, - Map additionalProperties) { - this.data = data; - this.brandId = brandId; - this.channels = channels; - this.context = context; - this.metadata = metadata; - this.preferences = preferences; - this.providers = providers; - this.routing = routing; - this.timeout = timeout; - this.delay = delay; - this.expiry = expiry; - this.content = content; - this.additionalProperties = additionalProperties; - } - - /** - * @return An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("brand_id") - @java.lang.Override - public Optional getBrandId() { - return brandId; - } - - /** - * @return "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - /** - * @return Context to load with this recipient. Will override any context set on message.context. - */ - @JsonProperty("context") - @java.lang.Override - public Optional getContext() { - return context; - } - - /** - * @return Metadata such as utm tracking attached with the notification through this channel. - */ - @JsonProperty("metadata") - @java.lang.Override - public Optional getMetadata() { - return metadata; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - /** - * @return An object whose keys are valid provider identifiers which map to an object. - */ - @JsonProperty("providers") - @java.lang.Override - public Optional> getProviders() { - return providers; - } - - @JsonProperty("routing") - @java.lang.Override - public Optional getRouting() { - return routing; - } - - /** - * @return Time in ms to attempt the channel before failing over to the next available channel. - */ - @JsonProperty("timeout") - @java.lang.Override - public Optional getTimeout() { - return timeout; - } - - /** - * @return Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm') - */ - @JsonProperty("delay") - @java.lang.Override - public Optional getDelay() { - return delay; - } - - /** - * @return "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - @JsonProperty("expiry") - @java.lang.Override - public Optional getExpiry() { - return expiry; - } - - /** - * @return Describes the content of the message in a way that will work for email, push, - * chat, or any channel. Either this or template must be specified. - */ - @JsonProperty("content") - public Content getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundBulkContentMessage && equalTo((InboundBulkContentMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InboundBulkContentMessage other) { - return data.equals(other.data) - && brandId.equals(other.brandId) - && channels.equals(other.channels) - && context.equals(other.context) - && metadata.equals(other.metadata) - && preferences.equals(other.preferences) - && providers.equals(other.providers) - && routing.equals(other.routing) - && timeout.equals(other.timeout) - && delay.equals(other.delay) - && expiry.equals(other.expiry) - && content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.data, - this.brandId, - this.channels, - this.context, - this.metadata, - this.preferences, - this.providers, - this.routing, - this.timeout, - this.delay, - this.expiry, - this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ContentStage builder() { - return new Builder(); - } - - public interface ContentStage { - _FinalStage content(Content content); - - Builder from(InboundBulkContentMessage other); - } - - public interface _FinalStage { - InboundBulkContentMessage build(); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage brandId(Optional brandId); - - _FinalStage brandId(String brandId); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(Map channels); - - _FinalStage context(Optional context); - - _FinalStage context(MessageContext context); - - _FinalStage metadata(Optional metadata); - - _FinalStage metadata(MessageMetadata metadata); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(MessagePreferences preferences); - - _FinalStage providers(Optional> providers); - - _FinalStage providers(Map providers); - - _FinalStage routing(Optional routing); - - _FinalStage routing(Routing routing); - - _FinalStage timeout(Optional timeout); - - _FinalStage timeout(Timeout timeout); - - _FinalStage delay(Optional delay); - - _FinalStage delay(Delay delay); - - _FinalStage expiry(Optional expiry); - - _FinalStage expiry(Expiry expiry); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ContentStage, _FinalStage { - private Content content; - - private Optional expiry = Optional.empty(); - - private Optional delay = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private Optional routing = Optional.empty(); - - private Optional> providers = Optional.empty(); - - private Optional preferences = Optional.empty(); - - private Optional metadata = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional> channels = Optional.empty(); - - private Optional brandId = Optional.empty(); - - private Optional> data = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(InboundBulkContentMessage other) { - data(other.getData()); - brandId(other.getBrandId()); - channels(other.getChannels()); - context(other.getContext()); - metadata(other.getMetadata()); - preferences(other.getPreferences()); - providers(other.getProviders()); - routing(other.getRouting()); - timeout(other.getTimeout()); - delay(other.getDelay()); - expiry(other.getExpiry()); - content(other.getContent()); - return this; - } - - /** - *

Describes the content of the message in a way that will work for email, push, - * chat, or any channel. Either this or template must be specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(Content content) { - this.content = content; - return this; - } - - /** - *

"Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiry(Expiry expiry) { - this.expiry = Optional.of(expiry); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expiry", nulls = Nulls.SKIP) - public _FinalStage expiry(Optional expiry) { - this.expiry = expiry; - return this; - } - - /** - *

Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm')

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage delay(Delay delay) { - this.delay = Optional.of(delay); - return this; - } - - @java.lang.Override - @JsonSetter(value = "delay", nulls = Nulls.SKIP) - public _FinalStage delay(Optional delay) { - this.delay = delay; - return this; - } - - /** - *

Time in ms to attempt the channel before failing over to the next available channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage timeout(Timeout timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - @java.lang.Override - @JsonSetter(value = "timeout", nulls = Nulls.SKIP) - public _FinalStage timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - @java.lang.Override - public _FinalStage routing(Routing routing) { - this.routing = Optional.of(routing); - return this; - } - - @java.lang.Override - @JsonSetter(value = "routing", nulls = Nulls.SKIP) - public _FinalStage routing(Optional routing) { - this.routing = routing; - return this; - } - - /** - *

An object whose keys are valid provider identifiers which map to an object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage providers(Map providers) { - this.providers = Optional.of(providers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public _FinalStage providers(Optional> providers) { - this.providers = providers; - return this; - } - - @java.lang.Override - public _FinalStage preferences(MessagePreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - /** - *

Metadata such as utm tracking attached with the notification through this channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage metadata(MessageMetadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - @java.lang.Override - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public _FinalStage metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - /** - *

Context to load with this recipient. Will override any context set on message.context.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage context(MessageContext context) { - this.context = Optional.of(context); - return this; - } - - @java.lang.Override - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public _FinalStage context(Optional context) { - this.context = context; - return this; - } - - /** - *

"Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage channels(Map channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public _FinalStage brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public _FinalStage brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - /** - *

An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public InboundBulkContentMessage build() { - return new InboundBulkContentMessage( - data, - brandId, - channels, - context, - metadata, - preferences, - providers, - routing, - timeout, - delay, - expiry, - content, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessage.java b/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessage.java deleted file mode 100644 index 1f1762c1..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessage.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InboundBulkMessage.Builder.class) -public final class InboundBulkMessage implements IInboundBulkMessageV1 { - private final Optional brand; - - private final Optional> data; - - private final Optional event; - - private final Optional> locale; - - private final Optional override; - - private final Optional message; - - private final Map additionalProperties; - - private InboundBulkMessage( - Optional brand, - Optional> data, - Optional event, - Optional> locale, - Optional override, - Optional message, - Map additionalProperties) { - this.brand = brand; - this.data = data; - this.event = event; - this.locale = locale; - this.override = override; - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that represents the brand that should be used - * for rendering the notification. - */ - @JsonProperty("brand") - @java.lang.Override - public Optional getBrand() { - return brand; - } - - /** - * @return JSON that includes any data you want to pass to a message template. - * The data will populate the corresponding template variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("event") - @java.lang.Override - public Optional getEvent() { - return event; - } - - @JsonProperty("locale") - @java.lang.Override - public Optional> getLocale() { - return locale; - } - - /** - * @return JSON that is merged into the request sent by Courier to the provider - * to override properties or to gain access to features in the provider - * API that are not natively supported by Courier. - */ - @JsonProperty("override") - @java.lang.Override - public Optional getOverride() { - return override; - } - - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundBulkMessage && equalTo((InboundBulkMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InboundBulkMessage other) { - return brand.equals(other.brand) - && data.equals(other.data) - && event.equals(other.event) - && locale.equals(other.locale) - && override.equals(other.override) - && message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.brand, this.data, this.event, this.locale, this.override, this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional brand = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional event = Optional.empty(); - - private Optional> locale = Optional.empty(); - - private Optional override = Optional.empty(); - - private Optional message = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(InboundBulkMessage other) { - brand(other.getBrand()); - data(other.getData()); - event(other.getEvent()); - locale(other.getLocale()); - override(other.getOverride()); - message(other.getMessage()); - return this; - } - - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public Builder brand(Optional brand) { - this.brand = brand; - return this; - } - - public Builder brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "event", nulls = Nulls.SKIP) - public Builder event(Optional event) { - this.event = event; - return this; - } - - public Builder event(String event) { - this.event = Optional.of(event); - return this; - } - - @JsonSetter(value = "locale", nulls = Nulls.SKIP) - public Builder locale(Optional> locale) { - this.locale = locale; - return this; - } - - public Builder locale(Map locale) { - this.locale = Optional.of(locale); - return this; - } - - @JsonSetter(value = "override", nulls = Nulls.SKIP) - public Builder override(Optional override) { - this.override = override; - return this; - } - - public Builder override(Object override) { - this.override = Optional.of(override); - return this; - } - - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public Builder message(Optional message) { - this.message = message; - return this; - } - - public Builder message(InboundBulkMessageV2 message) { - this.message = Optional.of(message); - return this; - } - - public InboundBulkMessage build() { - return new InboundBulkMessage(brand, data, event, locale, override, message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageUser.java b/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageUser.java deleted file mode 100644 index 271c98be..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageUser.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.courier.api.resources.send.types.UserRecipient; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InboundBulkMessageUser.Builder.class) -public final class InboundBulkMessageUser implements IInboundBulkMessageUser { - private final Optional preferences; - - private final Optional profile; - - private final Optional recipient; - - private final Optional data; - - private final Optional to; - - private final Map additionalProperties; - - private InboundBulkMessageUser( - Optional preferences, - Optional profile, - Optional recipient, - Optional data, - Optional to, - Map additionalProperties) { - this.preferences = preferences; - this.profile = profile; - this.recipient = recipient; - this.data = data; - this.to = to; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - @JsonProperty("profile") - @java.lang.Override - public Optional getProfile() { - return profile; - } - - @JsonProperty("recipient") - @java.lang.Override - public Optional getRecipient() { - return recipient; - } - - @JsonProperty("data") - @java.lang.Override - public Optional getData() { - return data; - } - - @JsonProperty("to") - @java.lang.Override - public Optional getTo() { - return to; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundBulkMessageUser && equalTo((InboundBulkMessageUser) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InboundBulkMessageUser other) { - return preferences.equals(other.preferences) - && profile.equals(other.profile) - && recipient.equals(other.recipient) - && data.equals(other.data) - && to.equals(other.to); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.preferences, this.profile, this.recipient, this.data, this.to); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional preferences = Optional.empty(); - - private Optional profile = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional data = Optional.empty(); - - private Optional to = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(InboundBulkMessageUser other) { - preferences(other.getPreferences()); - profile(other.getProfile()); - recipient(other.getRecipient()); - data(other.getData()); - to(other.getTo()); - return this; - } - - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public Builder preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - public Builder preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Optional profile) { - this.profile = profile; - return this; - } - - public Builder profile(Object profile) { - this.profile = Optional.of(profile); - return this; - } - - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public Builder recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - public Builder recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional data) { - this.data = data; - return this; - } - - public Builder data(Object data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "to", nulls = Nulls.SKIP) - public Builder to(Optional to) { - this.to = to; - return this; - } - - public Builder to(UserRecipient to) { - this.to = Optional.of(to); - return this; - } - - public InboundBulkMessageUser build() { - return new InboundBulkMessageUser(preferences, profile, recipient, data, to, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV1.java b/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV1.java deleted file mode 100644 index 0b84aad6..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV1.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InboundBulkMessageV1.Builder.class) -public final class InboundBulkMessageV1 implements IInboundBulkMessageV1 { - private final Optional brand; - - private final Optional> data; - - private final Optional event; - - private final Optional> locale; - - private final Optional override; - - private final Map additionalProperties; - - private InboundBulkMessageV1( - Optional brand, - Optional> data, - Optional event, - Optional> locale, - Optional override, - Map additionalProperties) { - this.brand = brand; - this.data = data; - this.event = event; - this.locale = locale; - this.override = override; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that represents the brand that should be used - * for rendering the notification. - */ - @JsonProperty("brand") - @java.lang.Override - public Optional getBrand() { - return brand; - } - - /** - * @return JSON that includes any data you want to pass to a message template. - * The data will populate the corresponding template variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("event") - @java.lang.Override - public Optional getEvent() { - return event; - } - - @JsonProperty("locale") - @java.lang.Override - public Optional> getLocale() { - return locale; - } - - /** - * @return JSON that is merged into the request sent by Courier to the provider - * to override properties or to gain access to features in the provider - * API that are not natively supported by Courier. - */ - @JsonProperty("override") - @java.lang.Override - public Optional getOverride() { - return override; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundBulkMessageV1 && equalTo((InboundBulkMessageV1) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InboundBulkMessageV1 other) { - return brand.equals(other.brand) - && data.equals(other.data) - && event.equals(other.event) - && locale.equals(other.locale) - && override.equals(other.override); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.brand, this.data, this.event, this.locale, this.override); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional brand = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional event = Optional.empty(); - - private Optional> locale = Optional.empty(); - - private Optional override = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(InboundBulkMessageV1 other) { - brand(other.getBrand()); - data(other.getData()); - event(other.getEvent()); - locale(other.getLocale()); - override(other.getOverride()); - return this; - } - - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public Builder brand(Optional brand) { - this.brand = brand; - return this; - } - - public Builder brand(String brand) { - this.brand = Optional.of(brand); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "event", nulls = Nulls.SKIP) - public Builder event(Optional event) { - this.event = event; - return this; - } - - public Builder event(String event) { - this.event = Optional.of(event); - return this; - } - - @JsonSetter(value = "locale", nulls = Nulls.SKIP) - public Builder locale(Optional> locale) { - this.locale = locale; - return this; - } - - public Builder locale(Map locale) { - this.locale = Optional.of(locale); - return this; - } - - @JsonSetter(value = "override", nulls = Nulls.SKIP) - public Builder override(Optional override) { - this.override = override; - return this; - } - - public Builder override(Object override) { - this.override = Optional.of(override); - return this; - } - - public InboundBulkMessageV1 build() { - return new InboundBulkMessageV1(brand, data, event, locale, override, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV2.java b/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV2.java deleted file mode 100644 index eb85abb4..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkMessageV2.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = InboundBulkMessageV2.Deserializer.class) -public final class InboundBulkMessageV2 { - private final Object value; - - private final int type; - - private InboundBulkMessageV2(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((InboundBulkTemplateMessage) this.value); - } else if (this.type == 1) { - return visitor.visit((InboundBulkContentMessage) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundBulkMessageV2 && equalTo((InboundBulkMessageV2) other); - } - - private boolean equalTo(InboundBulkMessageV2 other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static InboundBulkMessageV2 of(InboundBulkTemplateMessage value) { - return new InboundBulkMessageV2(value, 0); - } - - public static InboundBulkMessageV2 of(InboundBulkContentMessage value) { - return new InboundBulkMessageV2(value, 1); - } - - public interface Visitor { - T visit(InboundBulkTemplateMessage value); - - T visit(InboundBulkContentMessage value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(InboundBulkMessageV2.class); - } - - @java.lang.Override - public InboundBulkMessageV2 deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, InboundBulkTemplateMessage.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, InboundBulkContentMessage.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkTemplateMessage.java b/src/main/java/com/courier/api/resources/bulk/types/InboundBulkTemplateMessage.java deleted file mode 100644 index fc519277..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/InboundBulkTemplateMessage.java +++ /dev/null @@ -1,550 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.send.types.Channel; -import com.courier.api.resources.send.types.Delay; -import com.courier.api.resources.send.types.Expiry; -import com.courier.api.resources.send.types.IBaseMessage; -import com.courier.api.resources.send.types.MessageContext; -import com.courier.api.resources.send.types.MessageMetadata; -import com.courier.api.resources.send.types.MessagePreferences; -import com.courier.api.resources.send.types.MessageProvidersType; -import com.courier.api.resources.send.types.Routing; -import com.courier.api.resources.send.types.Timeout; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InboundBulkTemplateMessage.Builder.class) -public final class InboundBulkTemplateMessage implements IBaseMessage { - private final Optional> data; - - private final Optional brandId; - - private final Optional> channels; - - private final Optional context; - - private final Optional metadata; - - private final Optional preferences; - - private final Optional> providers; - - private final Optional routing; - - private final Optional timeout; - - private final Optional delay; - - private final Optional expiry; - - private final String template; - - private final Map additionalProperties; - - private InboundBulkTemplateMessage( - Optional> data, - Optional brandId, - Optional> channels, - Optional context, - Optional metadata, - Optional preferences, - Optional> providers, - Optional routing, - Optional timeout, - Optional delay, - Optional expiry, - String template, - Map additionalProperties) { - this.data = data; - this.brandId = brandId; - this.channels = channels; - this.context = context; - this.metadata = metadata; - this.preferences = preferences; - this.providers = providers; - this.routing = routing; - this.timeout = timeout; - this.delay = delay; - this.expiry = expiry; - this.template = template; - this.additionalProperties = additionalProperties; - } - - /** - * @return An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("brand_id") - @java.lang.Override - public Optional getBrandId() { - return brandId; - } - - /** - * @return "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - /** - * @return Context to load with this recipient. Will override any context set on message.context. - */ - @JsonProperty("context") - @java.lang.Override - public Optional getContext() { - return context; - } - - /** - * @return Metadata such as utm tracking attached with the notification through this channel. - */ - @JsonProperty("metadata") - @java.lang.Override - public Optional getMetadata() { - return metadata; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - /** - * @return An object whose keys are valid provider identifiers which map to an object. - */ - @JsonProperty("providers") - @java.lang.Override - public Optional> getProviders() { - return providers; - } - - @JsonProperty("routing") - @java.lang.Override - public Optional getRouting() { - return routing; - } - - /** - * @return Time in ms to attempt the channel before failing over to the next available channel. - */ - @JsonProperty("timeout") - @java.lang.Override - public Optional getTimeout() { - return timeout; - } - - /** - * @return Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm') - */ - @JsonProperty("delay") - @java.lang.Override - public Optional getDelay() { - return delay; - } - - /** - * @return "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - @JsonProperty("expiry") - @java.lang.Override - public Optional getExpiry() { - return expiry; - } - - /** - * @return The id of the notification template to be rendered and sent to the recipient(s). - * This field or the content field must be supplied. - */ - @JsonProperty("template") - public String getTemplate() { - return template; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundBulkTemplateMessage && equalTo((InboundBulkTemplateMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InboundBulkTemplateMessage other) { - return data.equals(other.data) - && brandId.equals(other.brandId) - && channels.equals(other.channels) - && context.equals(other.context) - && metadata.equals(other.metadata) - && preferences.equals(other.preferences) - && providers.equals(other.providers) - && routing.equals(other.routing) - && timeout.equals(other.timeout) - && delay.equals(other.delay) - && expiry.equals(other.expiry) - && template.equals(other.template); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.data, - this.brandId, - this.channels, - this.context, - this.metadata, - this.preferences, - this.providers, - this.routing, - this.timeout, - this.delay, - this.expiry, - this.template); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TemplateStage builder() { - return new Builder(); - } - - public interface TemplateStage { - _FinalStage template(String template); - - Builder from(InboundBulkTemplateMessage other); - } - - public interface _FinalStage { - InboundBulkTemplateMessage build(); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage brandId(Optional brandId); - - _FinalStage brandId(String brandId); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(Map channels); - - _FinalStage context(Optional context); - - _FinalStage context(MessageContext context); - - _FinalStage metadata(Optional metadata); - - _FinalStage metadata(MessageMetadata metadata); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(MessagePreferences preferences); - - _FinalStage providers(Optional> providers); - - _FinalStage providers(Map providers); - - _FinalStage routing(Optional routing); - - _FinalStage routing(Routing routing); - - _FinalStage timeout(Optional timeout); - - _FinalStage timeout(Timeout timeout); - - _FinalStage delay(Optional delay); - - _FinalStage delay(Delay delay); - - _FinalStage expiry(Optional expiry); - - _FinalStage expiry(Expiry expiry); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TemplateStage, _FinalStage { - private String template; - - private Optional expiry = Optional.empty(); - - private Optional delay = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private Optional routing = Optional.empty(); - - private Optional> providers = Optional.empty(); - - private Optional preferences = Optional.empty(); - - private Optional metadata = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional> channels = Optional.empty(); - - private Optional brandId = Optional.empty(); - - private Optional> data = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(InboundBulkTemplateMessage other) { - data(other.getData()); - brandId(other.getBrandId()); - channels(other.getChannels()); - context(other.getContext()); - metadata(other.getMetadata()); - preferences(other.getPreferences()); - providers(other.getProviders()); - routing(other.getRouting()); - timeout(other.getTimeout()); - delay(other.getDelay()); - expiry(other.getExpiry()); - template(other.getTemplate()); - return this; - } - - /** - *

The id of the notification template to be rendered and sent to the recipient(s). - * This field or the content field must be supplied.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("template") - public _FinalStage template(String template) { - this.template = template; - return this; - } - - /** - *

"Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiry(Expiry expiry) { - this.expiry = Optional.of(expiry); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expiry", nulls = Nulls.SKIP) - public _FinalStage expiry(Optional expiry) { - this.expiry = expiry; - return this; - } - - /** - *

Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm')

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage delay(Delay delay) { - this.delay = Optional.of(delay); - return this; - } - - @java.lang.Override - @JsonSetter(value = "delay", nulls = Nulls.SKIP) - public _FinalStage delay(Optional delay) { - this.delay = delay; - return this; - } - - /** - *

Time in ms to attempt the channel before failing over to the next available channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage timeout(Timeout timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - @java.lang.Override - @JsonSetter(value = "timeout", nulls = Nulls.SKIP) - public _FinalStage timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - @java.lang.Override - public _FinalStage routing(Routing routing) { - this.routing = Optional.of(routing); - return this; - } - - @java.lang.Override - @JsonSetter(value = "routing", nulls = Nulls.SKIP) - public _FinalStage routing(Optional routing) { - this.routing = routing; - return this; - } - - /** - *

An object whose keys are valid provider identifiers which map to an object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage providers(Map providers) { - this.providers = Optional.of(providers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public _FinalStage providers(Optional> providers) { - this.providers = providers; - return this; - } - - @java.lang.Override - public _FinalStage preferences(MessagePreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - /** - *

Metadata such as utm tracking attached with the notification through this channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage metadata(MessageMetadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - @java.lang.Override - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public _FinalStage metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - /** - *

Context to load with this recipient. Will override any context set on message.context.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage context(MessageContext context) { - this.context = Optional.of(context); - return this; - } - - @java.lang.Override - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public _FinalStage context(Optional context) { - this.context = context; - return this; - } - - /** - *

"Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage channels(Map channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public _FinalStage brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public _FinalStage brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - /** - *

An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public InboundBulkTemplateMessage build() { - return new InboundBulkTemplateMessage( - data, - brandId, - channels, - context, - metadata, - preferences, - providers, - routing, - timeout, - delay, - expiry, - template, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/bulk/types/JobDetails.java b/src/main/java/com/courier/api/resources/bulk/types/JobDetails.java deleted file mode 100644 index 9a9c9e30..00000000 --- a/src/main/java/com/courier/api/resources/bulk/types/JobDetails.java +++ /dev/null @@ -1,200 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.bulk.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = JobDetails.Builder.class) -public final class JobDetails { - private final InboundBulkMessage definition; - - private final int enqueued; - - private final int failures; - - private final int received; - - private final BulkJobStatus status; - - private final Map additionalProperties; - - private JobDetails( - InboundBulkMessage definition, - int enqueued, - int failures, - int received, - BulkJobStatus status, - Map additionalProperties) { - this.definition = definition; - this.enqueued = enqueued; - this.failures = failures; - this.received = received; - this.status = status; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("definition") - public InboundBulkMessage getDefinition() { - return definition; - } - - @JsonProperty("enqueued") - public int getEnqueued() { - return enqueued; - } - - @JsonProperty("failures") - public int getFailures() { - return failures; - } - - @JsonProperty("received") - public int getReceived() { - return received; - } - - @JsonProperty("status") - public BulkJobStatus getStatus() { - return status; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof JobDetails && equalTo((JobDetails) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(JobDetails other) { - return definition.equals(other.definition) - && enqueued == other.enqueued - && failures == other.failures - && received == other.received - && status.equals(other.status); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.definition, this.enqueued, this.failures, this.received, this.status); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static DefinitionStage builder() { - return new Builder(); - } - - public interface DefinitionStage { - EnqueuedStage definition(InboundBulkMessage definition); - - Builder from(JobDetails other); - } - - public interface EnqueuedStage { - FailuresStage enqueued(int enqueued); - } - - public interface FailuresStage { - ReceivedStage failures(int failures); - } - - public interface ReceivedStage { - StatusStage received(int received); - } - - public interface StatusStage { - _FinalStage status(BulkJobStatus status); - } - - public interface _FinalStage { - JobDetails build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements DefinitionStage, EnqueuedStage, FailuresStage, ReceivedStage, StatusStage, _FinalStage { - private InboundBulkMessage definition; - - private int enqueued; - - private int failures; - - private int received; - - private BulkJobStatus status; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(JobDetails other) { - definition(other.getDefinition()); - enqueued(other.getEnqueued()); - failures(other.getFailures()); - received(other.getReceived()); - status(other.getStatus()); - return this; - } - - @java.lang.Override - @JsonSetter("definition") - public EnqueuedStage definition(InboundBulkMessage definition) { - this.definition = definition; - return this; - } - - @java.lang.Override - @JsonSetter("enqueued") - public FailuresStage enqueued(int enqueued) { - this.enqueued = enqueued; - return this; - } - - @java.lang.Override - @JsonSetter("failures") - public ReceivedStage failures(int failures) { - this.failures = failures; - return this; - } - - @java.lang.Override - @JsonSetter("received") - public StatusStage received(int received) { - this.received = received; - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(BulkJobStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - public JobDetails build() { - return new JobDetails(definition, enqueued, failures, received, status, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/errors/CourierApiAlreadyExistsError.java b/src/main/java/com/courier/api/resources/commons/errors/CourierApiAlreadyExistsError.java deleted file mode 100644 index bd0bb834..00000000 --- a/src/main/java/com/courier/api/resources/commons/errors/CourierApiAlreadyExistsError.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.errors; - -import com.courier.api.core.CourierApiApiError; -import com.courier.api.resources.commons.types.AlreadyExists; - -public final class CourierApiAlreadyExistsError extends CourierApiApiError { - /** - * The body of the response that triggered the exception. - */ - private final AlreadyExists body; - - public CourierApiAlreadyExistsError(AlreadyExists body) { - super("AlreadyExistsError", 409, body); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public AlreadyExists body() { - return this.body; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/errors/CourierApiBadRequestError.java b/src/main/java/com/courier/api/resources/commons/errors/CourierApiBadRequestError.java deleted file mode 100644 index a68a441b..00000000 --- a/src/main/java/com/courier/api/resources/commons/errors/CourierApiBadRequestError.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.errors; - -import com.courier.api.core.CourierApiApiError; -import com.courier.api.resources.commons.types.BadRequest; - -public final class CourierApiBadRequestError extends CourierApiApiError { - /** - * The body of the response that triggered the exception. - */ - private final BadRequest body; - - public CourierApiBadRequestError(BadRequest body) { - super("BadRequestError", 400, body); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public BadRequest body() { - return this.body; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/errors/CourierApiConflictError.java b/src/main/java/com/courier/api/resources/commons/errors/CourierApiConflictError.java deleted file mode 100644 index bcbdb10e..00000000 --- a/src/main/java/com/courier/api/resources/commons/errors/CourierApiConflictError.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.errors; - -import com.courier.api.core.CourierApiApiError; -import com.courier.api.resources.commons.types.Conflict; - -public final class CourierApiConflictError extends CourierApiApiError { - /** - * The body of the response that triggered the exception. - */ - private final Conflict body; - - public CourierApiConflictError(Conflict body) { - super("ConflictError", 409, body); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public Conflict body() { - return this.body; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/errors/CourierApiMessageNotFoundError.java b/src/main/java/com/courier/api/resources/commons/errors/CourierApiMessageNotFoundError.java deleted file mode 100644 index fe406907..00000000 --- a/src/main/java/com/courier/api/resources/commons/errors/CourierApiMessageNotFoundError.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.errors; - -import com.courier.api.core.CourierApiApiError; -import com.courier.api.resources.commons.types.MessageNotFound; - -public final class CourierApiMessageNotFoundError extends CourierApiApiError { - /** - * The body of the response that triggered the exception. - */ - private final MessageNotFound body; - - public CourierApiMessageNotFoundError(MessageNotFound body) { - super("MessageNotFoundError", 404, body); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public MessageNotFound body() { - return this.body; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/errors/CourierApiNotFoundError.java b/src/main/java/com/courier/api/resources/commons/errors/CourierApiNotFoundError.java deleted file mode 100644 index 7b60bad6..00000000 --- a/src/main/java/com/courier/api/resources/commons/errors/CourierApiNotFoundError.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.errors; - -import com.courier.api.core.CourierApiApiError; -import com.courier.api.resources.commons.types.NotFound; - -public final class CourierApiNotFoundError extends CourierApiApiError { - /** - * The body of the response that triggered the exception. - */ - private final NotFound body; - - public CourierApiNotFoundError(NotFound body) { - super("NotFoundError", 404, body); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public NotFound body() { - return this.body; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/errors/CourierApiPaymentRequiredError.java b/src/main/java/com/courier/api/resources/commons/errors/CourierApiPaymentRequiredError.java deleted file mode 100644 index 915fc0d1..00000000 --- a/src/main/java/com/courier/api/resources/commons/errors/CourierApiPaymentRequiredError.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.errors; - -import com.courier.api.core.CourierApiApiError; -import com.courier.api.resources.commons.types.PaymentRequired; - -public final class CourierApiPaymentRequiredError extends CourierApiApiError { - /** - * The body of the response that triggered the exception. - */ - private final PaymentRequired body; - - public CourierApiPaymentRequiredError(PaymentRequired body) { - super("PaymentRequiredError", 402, body); - this.body = body; - } - - /** - * @return the body - */ - @java.lang.Override - public PaymentRequired body() { - return this.body; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/AlreadyExists.java b/src/main/java/com/courier/api/resources/commons/types/AlreadyExists.java deleted file mode 100644 index 988a9b63..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/AlreadyExists.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AlreadyExists.Builder.class) -public final class AlreadyExists implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private AlreadyExists(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @JsonProperty("type") - public String getType() { - return "invalid_request_error"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AlreadyExists && equalTo((AlreadyExists) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AlreadyExists other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(AlreadyExists other); - } - - public interface _FinalStage { - AlreadyExists build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AlreadyExists other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public AlreadyExists build() { - return new AlreadyExists(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/BadRequest.java b/src/main/java/com/courier/api/resources/commons/types/BadRequest.java deleted file mode 100644 index 07734932..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/BadRequest.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BadRequest.Builder.class) -public final class BadRequest implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private BadRequest(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @JsonProperty("type") - public String getType() { - return "invalid_request_error"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BadRequest && equalTo((BadRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BadRequest other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(BadRequest other); - } - - public interface _FinalStage { - BadRequest build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BadRequest other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public BadRequest build() { - return new BadRequest(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/BaseError.java b/src/main/java/com/courier/api/resources/commons/types/BaseError.java deleted file mode 100644 index 1deb6040..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/BaseError.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseError.Builder.class) -public final class BaseError implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private BaseError(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseError && equalTo((BaseError) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseError other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(BaseError other); - } - - public interface _FinalStage { - BaseError build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BaseError other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public BaseError build() { - return new BaseError(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/BaseTemplateTenantAssociation.java b/src/main/java/com/courier/api/resources/commons/types/BaseTemplateTenantAssociation.java deleted file mode 100644 index 65d2de40..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/BaseTemplateTenantAssociation.java +++ /dev/null @@ -1,241 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseTemplateTenantAssociation.Builder.class) -public final class BaseTemplateTenantAssociation implements IBaseTemplateTenantAssociation { - private final String id; - - private final String createdAt; - - private final String updatedAt; - - private final String publishedAt; - - private final String version; - - private final Map additionalProperties; - - private BaseTemplateTenantAssociation( - String id, - String createdAt, - String updatedAt, - String publishedAt, - String version, - Map additionalProperties) { - this.id = id; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.publishedAt = publishedAt; - this.version = version; - this.additionalProperties = additionalProperties; - } - - /** - * @return The template's id - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The timestamp at which the template was created - */ - @JsonProperty("created_at") - @java.lang.Override - public String getCreatedAt() { - return createdAt; - } - - /** - * @return The timestamp at which the template was last updated - */ - @JsonProperty("updated_at") - @java.lang.Override - public String getUpdatedAt() { - return updatedAt; - } - - /** - * @return The timestamp at which the template was published - */ - @JsonProperty("published_at") - @java.lang.Override - public String getPublishedAt() { - return publishedAt; - } - - /** - * @return The version of the template - */ - @JsonProperty("version") - @java.lang.Override - public String getVersion() { - return version; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseTemplateTenantAssociation && equalTo((BaseTemplateTenantAssociation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseTemplateTenantAssociation other) { - return id.equals(other.id) - && createdAt.equals(other.createdAt) - && updatedAt.equals(other.updatedAt) - && publishedAt.equals(other.publishedAt) - && version.equals(other.version); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.createdAt, this.updatedAt, this.publishedAt, this.version); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - CreatedAtStage id(String id); - - Builder from(BaseTemplateTenantAssociation other); - } - - public interface CreatedAtStage { - UpdatedAtStage createdAt(String createdAt); - } - - public interface UpdatedAtStage { - PublishedAtStage updatedAt(String updatedAt); - } - - public interface PublishedAtStage { - VersionStage publishedAt(String publishedAt); - } - - public interface VersionStage { - _FinalStage version(String version); - } - - public interface _FinalStage { - BaseTemplateTenantAssociation build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, CreatedAtStage, UpdatedAtStage, PublishedAtStage, VersionStage, _FinalStage { - private String id; - - private String createdAt; - - private String updatedAt; - - private String publishedAt; - - private String version; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BaseTemplateTenantAssociation other) { - id(other.getId()); - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - publishedAt(other.getPublishedAt()); - version(other.getVersion()); - return this; - } - - /** - *

The template's id

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(String id) { - this.id = id; - return this; - } - - /** - *

The timestamp at which the template was created

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(String createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - *

The timestamp at which the template was last updated

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated_at") - public PublishedAtStage updatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - /** - *

The timestamp at which the template was published

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("published_at") - public VersionStage publishedAt(String publishedAt) { - this.publishedAt = publishedAt; - return this; - } - - /** - *

The version of the template

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("version") - public _FinalStage version(String version) { - this.version = version; - return this; - } - - @java.lang.Override - public BaseTemplateTenantAssociation build() { - return new BaseTemplateTenantAssociation( - id, createdAt, updatedAt, publishedAt, version, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/ChannelClassification.java b/src/main/java/com/courier/api/resources/commons/types/ChannelClassification.java deleted file mode 100644 index af91cfd4..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/ChannelClassification.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ChannelClassification { - DIRECT_MESSAGE("direct_message"), - - EMAIL("email"), - - PUSH("push"), - - SMS("sms"), - - WEBHOOK("webhook"), - - INBOX("inbox"); - - private final String value; - - ChannelClassification(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/ChannelPreference.java b/src/main/java/com/courier/api/resources/commons/types/ChannelPreference.java deleted file mode 100644 index 69d32b36..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/ChannelPreference.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ChannelPreference.Builder.class) -public final class ChannelPreference { - private final ChannelClassification channel; - - private final Map additionalProperties; - - private ChannelPreference(ChannelClassification channel, Map additionalProperties) { - this.channel = channel; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channel") - public ChannelClassification getChannel() { - return channel; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChannelPreference && equalTo((ChannelPreference) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ChannelPreference other) { - return channel.equals(other.channel); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channel); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ChannelStage builder() { - return new Builder(); - } - - public interface ChannelStage { - _FinalStage channel(ChannelClassification channel); - - Builder from(ChannelPreference other); - } - - public interface _FinalStage { - ChannelPreference build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ChannelStage, _FinalStage { - private ChannelClassification channel; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ChannelPreference other) { - channel(other.getChannel()); - return this; - } - - @java.lang.Override - @JsonSetter("channel") - public _FinalStage channel(ChannelClassification channel) { - this.channel = channel; - return this; - } - - @java.lang.Override - public ChannelPreference build() { - return new ChannelPreference(channel, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/Conflict.java b/src/main/java/com/courier/api/resources/commons/types/Conflict.java deleted file mode 100644 index bb1b92c7..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/Conflict.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Conflict.Builder.class) -public final class Conflict implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private Conflict(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @JsonProperty("type") - public String getType() { - return "invalid_request_error"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Conflict && equalTo((Conflict) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Conflict other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(Conflict other); - } - - public interface _FinalStage { - Conflict build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Conflict other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public Conflict build() { - return new Conflict(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/Email.java b/src/main/java/com/courier/api/resources/commons/types/Email.java deleted file mode 100644 index a57eee31..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/Email.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Email.Builder.class) -public final class Email { - private final Object footer; - - private final Object header; - - private final Map additionalProperties; - - private Email(Object footer, Object header, Map additionalProperties) { - this.footer = footer; - this.header = header; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("footer") - public Object getFooter() { - return footer; - } - - @JsonProperty("header") - public Object getHeader() { - return header; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Email && equalTo((Email) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Email other) { - return footer.equals(other.footer) && header.equals(other.header); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.footer, this.header); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static FooterStage builder() { - return new Builder(); - } - - public interface FooterStage { - HeaderStage footer(Object footer); - - Builder from(Email other); - } - - public interface HeaderStage { - _FinalStage header(Object header); - } - - public interface _FinalStage { - Email build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements FooterStage, HeaderStage, _FinalStage { - private Object footer; - - private Object header; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Email other) { - footer(other.getFooter()); - header(other.getHeader()); - return this; - } - - @java.lang.Override - @JsonSetter("footer") - public HeaderStage footer(Object footer) { - this.footer = footer; - return this; - } - - @java.lang.Override - @JsonSetter("header") - public _FinalStage header(Object header) { - this.header = header; - return this; - } - - @java.lang.Override - public Email build() { - return new Email(footer, header, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/IBaseError.java b/src/main/java/com/courier/api/resources/commons/types/IBaseError.java deleted file mode 100644 index 6c4f7d11..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/IBaseError.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -public interface IBaseError { - String getMessage(); -} diff --git a/src/main/java/com/courier/api/resources/commons/types/IBaseTemplateTenantAssociation.java b/src/main/java/com/courier/api/resources/commons/types/IBaseTemplateTenantAssociation.java deleted file mode 100644 index e4157f0f..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/IBaseTemplateTenantAssociation.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -public interface IBaseTemplateTenantAssociation { - String getId(); - - String getCreatedAt(); - - String getUpdatedAt(); - - String getPublishedAt(); - - String getVersion(); -} diff --git a/src/main/java/com/courier/api/resources/commons/types/ISingleTemplateTenantAssociation.java b/src/main/java/com/courier/api/resources/commons/types/ISingleTemplateTenantAssociation.java deleted file mode 100644 index 59260b21..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/ISingleTemplateTenantAssociation.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -public interface ISingleTemplateTenantAssociation extends IBaseTemplateTenantAssociation { - TenantTemplateData getData(); -} diff --git a/src/main/java/com/courier/api/resources/commons/types/ListTemplateTenantAssociation.java b/src/main/java/com/courier/api/resources/commons/types/ListTemplateTenantAssociation.java deleted file mode 100644 index 21407af1..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/ListTemplateTenantAssociation.java +++ /dev/null @@ -1,265 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTemplateTenantAssociation.Builder.class) -public final class ListTemplateTenantAssociation implements IBaseTemplateTenantAssociation { - private final String id; - - private final String createdAt; - - private final String updatedAt; - - private final String publishedAt; - - private final String version; - - private final TenantTemplateDataNoContent data; - - private final Map additionalProperties; - - private ListTemplateTenantAssociation( - String id, - String createdAt, - String updatedAt, - String publishedAt, - String version, - TenantTemplateDataNoContent data, - Map additionalProperties) { - this.id = id; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.publishedAt = publishedAt; - this.version = version; - this.data = data; - this.additionalProperties = additionalProperties; - } - - /** - * @return The template's id - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The timestamp at which the template was created - */ - @JsonProperty("created_at") - @java.lang.Override - public String getCreatedAt() { - return createdAt; - } - - /** - * @return The timestamp at which the template was last updated - */ - @JsonProperty("updated_at") - @java.lang.Override - public String getUpdatedAt() { - return updatedAt; - } - - /** - * @return The timestamp at which the template was published - */ - @JsonProperty("published_at") - @java.lang.Override - public String getPublishedAt() { - return publishedAt; - } - - /** - * @return The version of the template - */ - @JsonProperty("version") - @java.lang.Override - public String getVersion() { - return version; - } - - @JsonProperty("data") - public TenantTemplateDataNoContent getData() { - return data; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTemplateTenantAssociation && equalTo((ListTemplateTenantAssociation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTemplateTenantAssociation other) { - return id.equals(other.id) - && createdAt.equals(other.createdAt) - && updatedAt.equals(other.updatedAt) - && publishedAt.equals(other.publishedAt) - && version.equals(other.version) - && data.equals(other.data); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.createdAt, this.updatedAt, this.publishedAt, this.version, this.data); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - CreatedAtStage id(String id); - - Builder from(ListTemplateTenantAssociation other); - } - - public interface CreatedAtStage { - UpdatedAtStage createdAt(String createdAt); - } - - public interface UpdatedAtStage { - PublishedAtStage updatedAt(String updatedAt); - } - - public interface PublishedAtStage { - VersionStage publishedAt(String publishedAt); - } - - public interface VersionStage { - DataStage version(String version); - } - - public interface DataStage { - _FinalStage data(TenantTemplateDataNoContent data); - } - - public interface _FinalStage { - ListTemplateTenantAssociation build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, CreatedAtStage, UpdatedAtStage, PublishedAtStage, VersionStage, DataStage, _FinalStage { - private String id; - - private String createdAt; - - private String updatedAt; - - private String publishedAt; - - private String version; - - private TenantTemplateDataNoContent data; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListTemplateTenantAssociation other) { - id(other.getId()); - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - publishedAt(other.getPublishedAt()); - version(other.getVersion()); - data(other.getData()); - return this; - } - - /** - *

The template's id

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(String id) { - this.id = id; - return this; - } - - /** - *

The timestamp at which the template was created

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(String createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - *

The timestamp at which the template was last updated

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated_at") - public PublishedAtStage updatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - /** - *

The timestamp at which the template was published

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("published_at") - public VersionStage publishedAt(String publishedAt) { - this.publishedAt = publishedAt; - return this; - } - - /** - *

The version of the template

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("version") - public DataStage version(String version) { - this.version = version; - return this; - } - - @java.lang.Override - @JsonSetter("data") - public _FinalStage data(TenantTemplateDataNoContent data) { - this.data = data; - return this; - } - - @java.lang.Override - public ListTemplateTenantAssociation build() { - return new ListTemplateTenantAssociation( - id, createdAt, updatedAt, publishedAt, version, data, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/MessageNotFound.java b/src/main/java/com/courier/api/resources/commons/types/MessageNotFound.java deleted file mode 100644 index ed4b7413..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/MessageNotFound.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageNotFound.Builder.class) -public final class MessageNotFound implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private MessageNotFound(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @JsonProperty("type") - public String getType() { - return "invalid_request_error"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageNotFound && equalTo((MessageNotFound) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageNotFound other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(MessageNotFound other); - } - - public interface _FinalStage { - MessageNotFound build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MessageNotFound other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public MessageNotFound build() { - return new MessageNotFound(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/NotFound.java b/src/main/java/com/courier/api/resources/commons/types/NotFound.java deleted file mode 100644 index efcc080f..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/NotFound.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotFound.Builder.class) -public final class NotFound implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private NotFound(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @JsonProperty("type") - public String getType() { - return "invalid_request_error"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotFound && equalTo((NotFound) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotFound other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(NotFound other); - } - - public interface _FinalStage { - NotFound build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotFound other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public NotFound build() { - return new NotFound(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/NotificationPreferenceDetails.java b/src/main/java/com/courier/api/resources/commons/types/NotificationPreferenceDetails.java deleted file mode 100644 index ec2956d0..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/NotificationPreferenceDetails.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationPreferenceDetails.Builder.class) -public final class NotificationPreferenceDetails { - private final PreferenceStatus status; - - private final Optional> rules; - - private final Optional> channelPreferences; - - private final Map additionalProperties; - - private NotificationPreferenceDetails( - PreferenceStatus status, - Optional> rules, - Optional> channelPreferences, - Map additionalProperties) { - this.status = status; - this.rules = rules; - this.channelPreferences = channelPreferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public PreferenceStatus getStatus() { - return status; - } - - @JsonProperty("rules") - public Optional> getRules() { - return rules; - } - - @JsonProperty("channel_preferences") - public Optional> getChannelPreferences() { - return channelPreferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationPreferenceDetails && equalTo((NotificationPreferenceDetails) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationPreferenceDetails other) { - return status.equals(other.status) - && rules.equals(other.rules) - && channelPreferences.equals(other.channelPreferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.status, this.rules, this.channelPreferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - _FinalStage status(PreferenceStatus status); - - Builder from(NotificationPreferenceDetails other); - } - - public interface _FinalStage { - NotificationPreferenceDetails build(); - - _FinalStage rules(Optional> rules); - - _FinalStage rules(List rules); - - _FinalStage channelPreferences(Optional> channelPreferences); - - _FinalStage channelPreferences(List channelPreferences); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, _FinalStage { - private PreferenceStatus status; - - private Optional> channelPreferences = Optional.empty(); - - private Optional> rules = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotificationPreferenceDetails other) { - status(other.getStatus()); - rules(other.getRules()); - channelPreferences(other.getChannelPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(PreferenceStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - public _FinalStage channelPreferences(List channelPreferences) { - this.channelPreferences = Optional.of(channelPreferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channel_preferences", nulls = Nulls.SKIP) - public _FinalStage channelPreferences(Optional> channelPreferences) { - this.channelPreferences = channelPreferences; - return this; - } - - @java.lang.Override - public _FinalStage rules(List rules) { - this.rules = Optional.of(rules); - return this; - } - - @java.lang.Override - @JsonSetter(value = "rules", nulls = Nulls.SKIP) - public _FinalStage rules(Optional> rules) { - this.rules = rules; - return this; - } - - @java.lang.Override - public NotificationPreferenceDetails build() { - return new NotificationPreferenceDetails(status, rules, channelPreferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/Paging.java b/src/main/java/com/courier/api/resources/commons/types/Paging.java deleted file mode 100644 index 01ed4fcb..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/Paging.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Paging.Builder.class) -public final class Paging { - private final Optional cursor; - - private final boolean more; - - private final Map additionalProperties; - - private Paging(Optional cursor, boolean more, Map additionalProperties) { - this.cursor = cursor; - this.more = more; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @JsonProperty("more") - public boolean getMore() { - return more; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Paging && equalTo((Paging) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Paging other) { - return cursor.equals(other.cursor) && more == other.more; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor, this.more); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MoreStage builder() { - return new Builder(); - } - - public interface MoreStage { - _FinalStage more(boolean more); - - Builder from(Paging other); - } - - public interface _FinalStage { - Paging build(); - - _FinalStage cursor(Optional cursor); - - _FinalStage cursor(String cursor); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MoreStage, _FinalStage { - private boolean more; - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Paging other) { - cursor(other.getCursor()); - more(other.getMore()); - return this; - } - - @java.lang.Override - @JsonSetter("more") - public _FinalStage more(boolean more) { - this.more = more; - return this; - } - - @java.lang.Override - public _FinalStage cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public _FinalStage cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - @java.lang.Override - public Paging build() { - return new Paging(cursor, more, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/PaymentRequired.java b/src/main/java/com/courier/api/resources/commons/types/PaymentRequired.java deleted file mode 100644 index 7453c836..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/PaymentRequired.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PaymentRequired.Builder.class) -public final class PaymentRequired implements IBaseError { - private final String message; - - private final Map additionalProperties; - - private PaymentRequired(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("message") - @java.lang.Override - public String getMessage() { - return message; - } - - @JsonProperty("type") - public String getType() { - return "authorization_error"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PaymentRequired && equalTo((PaymentRequired) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PaymentRequired other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(PaymentRequired other); - } - - public interface _FinalStage { - PaymentRequired build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PaymentRequired other) { - message(other.getMessage()); - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public PaymentRequired build() { - return new PaymentRequired(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/PreferenceStatus.java b/src/main/java/com/courier/api/resources/commons/types/PreferenceStatus.java deleted file mode 100644 index 97069817..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/PreferenceStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PreferenceStatus { - OPTED_IN("OPTED_IN"), - - OPTED_OUT("OPTED_OUT"), - - REQUIRED("REQUIRED"); - - private final String value; - - PreferenceStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/RecipientPreferences.java b/src/main/java/com/courier/api/resources/commons/types/RecipientPreferences.java deleted file mode 100644 index 42420919..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/RecipientPreferences.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RecipientPreferences.Builder.class) -public final class RecipientPreferences { - private final Optional> categories; - - private final Optional> notifications; - - private final Map additionalProperties; - - private RecipientPreferences( - Optional> categories, - Optional> notifications, - Map additionalProperties) { - this.categories = categories; - this.notifications = notifications; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("categories") - public Optional> getCategories() { - return categories; - } - - @JsonProperty("notifications") - public Optional> getNotifications() { - return notifications; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RecipientPreferences && equalTo((RecipientPreferences) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RecipientPreferences other) { - return categories.equals(other.categories) && notifications.equals(other.notifications); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.categories, this.notifications); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> categories = Optional.empty(); - - private Optional> notifications = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RecipientPreferences other) { - categories(other.getCategories()); - notifications(other.getNotifications()); - return this; - } - - @JsonSetter(value = "categories", nulls = Nulls.SKIP) - public Builder categories(Optional> categories) { - this.categories = categories; - return this; - } - - public Builder categories(Map categories) { - this.categories = Optional.of(categories); - return this; - } - - @JsonSetter(value = "notifications", nulls = Nulls.SKIP) - public Builder notifications(Optional> notifications) { - this.notifications = notifications; - return this; - } - - public Builder notifications(Map notifications) { - this.notifications = Optional.of(notifications); - return this; - } - - public RecipientPreferences build() { - return new RecipientPreferences(categories, notifications, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/Rule.java b/src/main/java/com/courier/api/resources/commons/types/Rule.java deleted file mode 100644 index f754057d..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/Rule.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Rule.Builder.class) -public final class Rule { - private final Optional start; - - private final String until; - - private final Map additionalProperties; - - private Rule(Optional start, String until, Map additionalProperties) { - this.start = start; - this.until = until; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("start") - public Optional getStart() { - return start; - } - - @JsonProperty("until") - public String getUntil() { - return until; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Rule && equalTo((Rule) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Rule other) { - return start.equals(other.start) && until.equals(other.until); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.start, this.until); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UntilStage builder() { - return new Builder(); - } - - public interface UntilStage { - _FinalStage until(String until); - - Builder from(Rule other); - } - - public interface _FinalStage { - Rule build(); - - _FinalStage start(Optional start); - - _FinalStage start(String start); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UntilStage, _FinalStage { - private String until; - - private Optional start = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Rule other) { - start(other.getStart()); - until(other.getUntil()); - return this; - } - - @java.lang.Override - @JsonSetter("until") - public _FinalStage until(String until) { - this.until = until; - return this; - } - - @java.lang.Override - public _FinalStage start(String start) { - this.start = Optional.of(start); - return this; - } - - @java.lang.Override - @JsonSetter(value = "start", nulls = Nulls.SKIP) - public _FinalStage start(Optional start) { - this.start = start; - return this; - } - - @java.lang.Override - public Rule build() { - return new Rule(start, until, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/SingleTemplateTenantAssociation.java b/src/main/java/com/courier/api/resources/commons/types/SingleTemplateTenantAssociation.java deleted file mode 100644 index 69d884df..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/SingleTemplateTenantAssociation.java +++ /dev/null @@ -1,267 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SingleTemplateTenantAssociation.Builder.class) -public final class SingleTemplateTenantAssociation - implements ISingleTemplateTenantAssociation, IBaseTemplateTenantAssociation { - private final TenantTemplateData data; - - private final String id; - - private final String createdAt; - - private final String updatedAt; - - private final String publishedAt; - - private final String version; - - private final Map additionalProperties; - - private SingleTemplateTenantAssociation( - TenantTemplateData data, - String id, - String createdAt, - String updatedAt, - String publishedAt, - String version, - Map additionalProperties) { - this.data = data; - this.id = id; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.publishedAt = publishedAt; - this.version = version; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("data") - @java.lang.Override - public TenantTemplateData getData() { - return data; - } - - /** - * @return The template's id - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The timestamp at which the template was created - */ - @JsonProperty("created_at") - @java.lang.Override - public String getCreatedAt() { - return createdAt; - } - - /** - * @return The timestamp at which the template was last updated - */ - @JsonProperty("updated_at") - @java.lang.Override - public String getUpdatedAt() { - return updatedAt; - } - - /** - * @return The timestamp at which the template was published - */ - @JsonProperty("published_at") - @java.lang.Override - public String getPublishedAt() { - return publishedAt; - } - - /** - * @return The version of the template - */ - @JsonProperty("version") - @java.lang.Override - public String getVersion() { - return version; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SingleTemplateTenantAssociation && equalTo((SingleTemplateTenantAssociation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SingleTemplateTenantAssociation other) { - return data.equals(other.data) - && id.equals(other.id) - && createdAt.equals(other.createdAt) - && updatedAt.equals(other.updatedAt) - && publishedAt.equals(other.publishedAt) - && version.equals(other.version); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.data, this.id, this.createdAt, this.updatedAt, this.publishedAt, this.version); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static DataStage builder() { - return new Builder(); - } - - public interface DataStage { - IdStage data(TenantTemplateData data); - - Builder from(SingleTemplateTenantAssociation other); - } - - public interface IdStage { - CreatedAtStage id(String id); - } - - public interface CreatedAtStage { - UpdatedAtStage createdAt(String createdAt); - } - - public interface UpdatedAtStage { - PublishedAtStage updatedAt(String updatedAt); - } - - public interface PublishedAtStage { - VersionStage publishedAt(String publishedAt); - } - - public interface VersionStage { - _FinalStage version(String version); - } - - public interface _FinalStage { - SingleTemplateTenantAssociation build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements DataStage, IdStage, CreatedAtStage, UpdatedAtStage, PublishedAtStage, VersionStage, _FinalStage { - private TenantTemplateData data; - - private String id; - - private String createdAt; - - private String updatedAt; - - private String publishedAt; - - private String version; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SingleTemplateTenantAssociation other) { - data(other.getData()); - id(other.getId()); - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - publishedAt(other.getPublishedAt()); - version(other.getVersion()); - return this; - } - - @java.lang.Override - @JsonSetter("data") - public IdStage data(TenantTemplateData data) { - this.data = data; - return this; - } - - /** - *

The template's id

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(String id) { - this.id = id; - return this; - } - - /** - *

The timestamp at which the template was created

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(String createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - *

The timestamp at which the template was last updated

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated_at") - public PublishedAtStage updatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - /** - *

The timestamp at which the template was published

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("published_at") - public VersionStage publishedAt(String publishedAt) { - this.publishedAt = publishedAt; - return this; - } - - /** - *

The version of the template

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("version") - public _FinalStage version(String version) { - this.version = version; - return this; - } - - @java.lang.Override - public SingleTemplateTenantAssociation build() { - return new SingleTemplateTenantAssociation( - data, id, createdAt, updatedAt, publishedAt, version, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/TenantTemplateData.java b/src/main/java/com/courier/api/resources/commons/types/TenantTemplateData.java deleted file mode 100644 index efbc2a88..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/TenantTemplateData.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.notifications.types.MessageRouting; -import com.courier.api.resources.send.types.ElementalContent; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TenantTemplateData.Builder.class) -public final class TenantTemplateData { - private final MessageRouting routing; - - private final ElementalContent content; - - private final Map additionalProperties; - - private TenantTemplateData( - MessageRouting routing, ElementalContent content, Map additionalProperties) { - this.routing = routing; - this.content = content; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("routing") - public MessageRouting getRouting() { - return routing; - } - - @JsonProperty("content") - public ElementalContent getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TenantTemplateData && equalTo((TenantTemplateData) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TenantTemplateData other) { - return routing.equals(other.routing) && content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.routing, this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RoutingStage builder() { - return new Builder(); - } - - public interface RoutingStage { - ContentStage routing(MessageRouting routing); - - Builder from(TenantTemplateData other); - } - - public interface ContentStage { - _FinalStage content(ElementalContent content); - } - - public interface _FinalStage { - TenantTemplateData build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RoutingStage, ContentStage, _FinalStage { - private MessageRouting routing; - - private ElementalContent content; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TenantTemplateData other) { - routing(other.getRouting()); - content(other.getContent()); - return this; - } - - @java.lang.Override - @JsonSetter("routing") - public ContentStage routing(MessageRouting routing) { - this.routing = routing; - return this; - } - - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(ElementalContent content) { - this.content = content; - return this; - } - - @java.lang.Override - public TenantTemplateData build() { - return new TenantTemplateData(routing, content, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/TenantTemplateDataNoContent.java b/src/main/java/com/courier/api/resources/commons/types/TenantTemplateDataNoContent.java deleted file mode 100644 index 59417322..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/TenantTemplateDataNoContent.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.notifications.types.MessageRouting; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TenantTemplateDataNoContent.Builder.class) -public final class TenantTemplateDataNoContent { - private final MessageRouting routing; - - private final Map additionalProperties; - - private TenantTemplateDataNoContent(MessageRouting routing, Map additionalProperties) { - this.routing = routing; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("routing") - public MessageRouting getRouting() { - return routing; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TenantTemplateDataNoContent && equalTo((TenantTemplateDataNoContent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TenantTemplateDataNoContent other) { - return routing.equals(other.routing); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.routing); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RoutingStage builder() { - return new Builder(); - } - - public interface RoutingStage { - _FinalStage routing(MessageRouting routing); - - Builder from(TenantTemplateDataNoContent other); - } - - public interface _FinalStage { - TenantTemplateDataNoContent build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RoutingStage, _FinalStage { - private MessageRouting routing; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TenantTemplateDataNoContent other) { - routing(other.getRouting()); - return this; - } - - @java.lang.Override - @JsonSetter("routing") - public _FinalStage routing(MessageRouting routing) { - this.routing = routing; - return this; - } - - @java.lang.Override - public TenantTemplateDataNoContent build() { - return new TenantTemplateDataNoContent(routing, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/commons/types/UserTenantAssociation.java b/src/main/java/com/courier/api/resources/commons/types/UserTenantAssociation.java deleted file mode 100644 index 843363e5..00000000 --- a/src/main/java/com/courier/api/resources/commons/types/UserTenantAssociation.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.commons.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserTenantAssociation.Builder.class) -public final class UserTenantAssociation { - private final Optional userId; - - private final Optional type; - - private final String tenantId; - - private final Optional> profile; - - private final Map additionalProperties; - - private UserTenantAssociation( - Optional userId, - Optional type, - String tenantId, - Optional> profile, - Map additionalProperties) { - this.userId = userId; - this.type = type; - this.tenantId = tenantId; - this.profile = profile; - this.additionalProperties = additionalProperties; - } - - /** - * @return User ID for the assocation between tenant and user - */ - @JsonProperty("user_id") - public Optional getUserId() { - return userId; - } - - @JsonProperty("type") - public Optional getType() { - return type; - } - - /** - * @return Tenant ID for the assocation between tenant and user - */ - @JsonProperty("tenant_id") - public String getTenantId() { - return tenantId; - } - - /** - * @return Additional metadata to be applied to a user profile when used in a tenant context - */ - @JsonProperty("profile") - public Optional> getProfile() { - return profile; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserTenantAssociation && equalTo((UserTenantAssociation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserTenantAssociation other) { - return userId.equals(other.userId) - && type.equals(other.type) - && tenantId.equals(other.tenantId) - && profile.equals(other.profile); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.type, this.tenantId, this.profile); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - _FinalStage tenantId(String tenantId); - - Builder from(UserTenantAssociation other); - } - - public interface _FinalStage { - UserTenantAssociation build(); - - _FinalStage userId(Optional userId); - - _FinalStage userId(String userId); - - _FinalStage type(Optional type); - - _FinalStage type(String type); - - _FinalStage profile(Optional> profile); - - _FinalStage profile(Map profile); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TenantIdStage, _FinalStage { - private String tenantId; - - private Optional> profile = Optional.empty(); - - private Optional type = Optional.empty(); - - private Optional userId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserTenantAssociation other) { - userId(other.getUserId()); - type(other.getType()); - tenantId(other.getTenantId()); - profile(other.getProfile()); - return this; - } - - /** - *

Tenant ID for the assocation between tenant and user

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("tenant_id") - public _FinalStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - /** - *

Additional metadata to be applied to a user profile when used in a tenant context

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage profile(Map profile) { - this.profile = Optional.of(profile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public _FinalStage profile(Optional> profile) { - this.profile = profile; - return this; - } - - @java.lang.Override - public _FinalStage type(String type) { - this.type = Optional.of(type); - return this; - } - - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; - return this; - } - - /** - *

User ID for the assocation between tenant and user

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage userId(String userId) { - this.userId = Optional.of(userId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "user_id", nulls = Nulls.SKIP) - public _FinalStage userId(Optional userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public UserTenantAssociation build() { - return new UserTenantAssociation(userId, type, tenantId, profile, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/inbound/InboundClient.java b/src/main/java/com/courier/api/resources/inbound/InboundClient.java deleted file mode 100644 index f01131c4..00000000 --- a/src/main/java/com/courier/api/resources/inbound/InboundClient.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.inbound; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.errors.CourierApiConflictError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.commons.types.Conflict; -import com.courier.api.resources.inbound.types.InboundTrackEvent; -import com.courier.api.resources.inbound.types.TrackAcceptedResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class InboundClient { - protected final ClientOptions clientOptions; - - public InboundClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public TrackAcceptedResponse track(InboundTrackEvent request) { - return track(request, null); - } - - public TrackAcceptedResponse track(InboundTrackEvent request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("inbound") - .addPathSegments("courier") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TrackAcceptedResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - case 409: - throw new CourierApiConflictError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Conflict.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/inbound/types/InboundTrackEvent.java b/src/main/java/com/courier/api/resources/inbound/types/InboundTrackEvent.java deleted file mode 100644 index d689785a..00000000 --- a/src/main/java/com/courier/api/resources/inbound/types/InboundTrackEvent.java +++ /dev/null @@ -1,225 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.inbound.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InboundTrackEvent.Builder.class) -public final class InboundTrackEvent { - private final String event; - - private final String messageId; - - private final Map properties; - - private final Optional userId; - - private final Map additionalProperties; - - private InboundTrackEvent( - String event, - String messageId, - Map properties, - Optional userId, - Map additionalProperties) { - this.event = event; - this.messageId = messageId; - this.properties = properties; - this.userId = userId; - this.additionalProperties = additionalProperties; - } - - /** - * @return A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node. - */ - @JsonProperty("event") - public String getEvent() { - return event; - } - - /** - * @return A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status - */ - @JsonProperty("messageId") - public String getMessageId() { - return messageId; - } - - @JsonProperty("properties") - public Map getProperties() { - return properties; - } - - @JsonProperty("type") - public String getType() { - return "track"; - } - - /** - * @return The user id assocatiated with the track - */ - @JsonProperty("userId") - public Optional getUserId() { - return userId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InboundTrackEvent && equalTo((InboundTrackEvent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InboundTrackEvent other) { - return event.equals(other.event) - && messageId.equals(other.messageId) - && properties.equals(other.properties) - && userId.equals(other.userId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.event, this.messageId, this.properties, this.userId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static EventStage builder() { - return new Builder(); - } - - public interface EventStage { - MessageIdStage event(String event); - - Builder from(InboundTrackEvent other); - } - - public interface MessageIdStage { - _FinalStage messageId(String messageId); - } - - public interface _FinalStage { - InboundTrackEvent build(); - - _FinalStage properties(Map properties); - - _FinalStage putAllProperties(Map properties); - - _FinalStage properties(String key, Object value); - - _FinalStage userId(Optional userId); - - _FinalStage userId(String userId); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements EventStage, MessageIdStage, _FinalStage { - private String event; - - private String messageId; - - private Optional userId = Optional.empty(); - - private Map properties = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(InboundTrackEvent other) { - event(other.getEvent()); - messageId(other.getMessageId()); - properties(other.getProperties()); - userId(other.getUserId()); - return this; - } - - /** - *

A descriptive name of the event. This name will appear as a trigger in the Courier Automation Trigger node.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("event") - public MessageIdStage event(String event) { - this.event = event; - return this; - } - - /** - *

A required unique identifier that will be used to de-duplicate requests. If not unique, will respond with 409 Conflict status

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("messageId") - public _FinalStage messageId(String messageId) { - this.messageId = messageId; - return this; - } - - /** - *

The user id assocatiated with the track

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage userId(String userId) { - this.userId = Optional.of(userId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "userId", nulls = Nulls.SKIP) - public _FinalStage userId(Optional userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public _FinalStage properties(String key, Object value) { - this.properties.put(key, value); - return this; - } - - @java.lang.Override - public _FinalStage putAllProperties(Map properties) { - this.properties.putAll(properties); - return this; - } - - @java.lang.Override - @JsonSetter(value = "properties", nulls = Nulls.SKIP) - public _FinalStage properties(Map properties) { - this.properties.clear(); - this.properties.putAll(properties); - return this; - } - - @java.lang.Override - public InboundTrackEvent build() { - return new InboundTrackEvent(event, messageId, properties, userId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/inbound/types/TrackAcceptedResponse.java b/src/main/java/com/courier/api/resources/inbound/types/TrackAcceptedResponse.java deleted file mode 100644 index 239d3e83..00000000 --- a/src/main/java/com/courier/api/resources/inbound/types/TrackAcceptedResponse.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.inbound.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TrackAcceptedResponse.Builder.class) -public final class TrackAcceptedResponse { - private final String messageId; - - private final Map additionalProperties; - - private TrackAcceptedResponse(String messageId, Map additionalProperties) { - this.messageId = messageId; - this.additionalProperties = additionalProperties; - } - - /** - * @return A successful call returns a 202 status code along with a requestId in the response body. - */ - @JsonProperty("messageId") - public String getMessageId() { - return messageId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TrackAcceptedResponse && equalTo((TrackAcceptedResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TrackAcceptedResponse other) { - return messageId.equals(other.messageId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.messageId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageIdStage builder() { - return new Builder(); - } - - public interface MessageIdStage { - _FinalStage messageId(String messageId); - - Builder from(TrackAcceptedResponse other); - } - - public interface _FinalStage { - TrackAcceptedResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageIdStage, _FinalStage { - private String messageId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TrackAcceptedResponse other) { - messageId(other.getMessageId()); - return this; - } - - /** - *

A successful call returns a 202 status code along with a requestId in the response body.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("messageId") - public _FinalStage messageId(String messageId) { - this.messageId = messageId; - return this; - } - - @java.lang.Override - public TrackAcceptedResponse build() { - return new TrackAcceptedResponse(messageId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/ListsClient.java b/src/main/java/com/courier/api/resources/lists/ListsClient.java deleted file mode 100644 index f6d74870..00000000 --- a/src/main/java/com/courier/api/resources/lists/ListsClient.java +++ /dev/null @@ -1,578 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.errors.CourierApiNotFoundError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.commons.types.NotFound; -import com.courier.api.resources.lists.requests.AddSubscribersToList; -import com.courier.api.resources.lists.requests.GetAllListsRequest; -import com.courier.api.resources.lists.requests.GetSubscriptionForListRequest; -import com.courier.api.resources.lists.requests.RestoreListRequest; -import com.courier.api.resources.lists.requests.SubscribeUserToListRequest; -import com.courier.api.resources.lists.requests.SubscribeUsersToListRequest; -import com.courier.api.resources.lists.types.List; -import com.courier.api.resources.lists.types.ListGetAllResponse; -import com.courier.api.resources.lists.types.ListGetSubscriptionsResponse; -import com.courier.api.resources.lists.types.ListPutParams; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class ListsClient { - protected final ClientOptions clientOptions; - - public ListsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns all of the lists, with the ability to filter based on a pattern. - */ - public ListGetAllResponse list() { - return list(GetAllListsRequest.builder().build()); - } - - /** - * Returns all of the lists, with the ability to filter based on a pattern. - */ - public ListGetAllResponse list(GetAllListsRequest request) { - return list(request, null); - } - - /** - * Returns all of the lists, with the ability to filter based on a pattern. - */ - public ListGetAllResponse list(GetAllListsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getPattern().isPresent()) { - httpUrl.addQueryParameter("pattern", request.getPattern().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListGetAllResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Returns a list based on the list ID provided. - */ - public List get(String listId) { - return get(listId, null); - } - - /** - * Returns a list based on the list ID provided. - */ - public List get(String listId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), List.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new CourierApiNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Create or replace an existing list with the supplied values. - */ - public void update(String listId, ListPutParams request) { - update(listId, request, null); - } - - /** - * Create or replace an existing list with the supplied values. - */ - public void update(String listId, ListPutParams request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Delete a list by list ID. - */ - public void delete(String listId) { - delete(listId, null); - } - - /** - * Delete a list by list ID. - */ - public void delete(String listId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Restore a previously deleted list. - */ - public void restore(String listId) { - restore(listId, RestoreListRequest.builder().build()); - } - - /** - * Restore a previously deleted list. - */ - public void restore(String listId, RestoreListRequest request) { - restore(listId, request, null); - } - - /** - * Restore a previously deleted list. - */ - public void restore(String listId, RestoreListRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .addPathSegments("restore") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get the list's subscriptions. - */ - public ListGetSubscriptionsResponse getSubscribers(String listId) { - return getSubscribers(listId, GetSubscriptionForListRequest.builder().build()); - } - - /** - * Get the list's subscriptions. - */ - public ListGetSubscriptionsResponse getSubscribers(String listId, GetSubscriptionForListRequest request) { - return getSubscribers(listId, request, null); - } - - /** - * Get the list's subscriptions. - */ - public ListGetSubscriptionsResponse getSubscribers( - String listId, GetSubscriptionForListRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .addPathSegments("subscriptions"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListGetSubscriptionsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new CourierApiNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Subscribes the users to the list, overwriting existing subscriptions. If the list does not exist, it will be automatically created. - */ - public void updateSubscribers(String listId, SubscribeUsersToListRequest request) { - updateSubscribers(listId, request, null); - } - - /** - * Subscribes the users to the list, overwriting existing subscriptions. If the list does not exist, it will be automatically created. - */ - public void updateSubscribers(String listId, SubscribeUsersToListRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .addPathSegments("subscriptions") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Subscribes additional users to the list, without modifying existing subscriptions. If the list does not exist, it will be automatically created. - */ - public void addSubscribers(String listId, AddSubscribersToList request) { - addSubscribers(listId, request, null); - } - - /** - * Subscribes additional users to the list, without modifying existing subscriptions. If the list does not exist, it will be automatically created. - */ - public void addSubscribers(String listId, AddSubscribersToList request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .addPathSegments("subscriptions") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Subscribe a user to an existing list (note: if the List does not exist, it will be automatically created). - */ - public void subscribe(String listId, String userId) { - subscribe(listId, userId, SubscribeUserToListRequest.builder().build()); - } - - /** - * Subscribe a user to an existing list (note: if the List does not exist, it will be automatically created). - */ - public void subscribe(String listId, String userId, SubscribeUserToListRequest request) { - subscribe(listId, userId, request, null); - } - - /** - * Subscribe a user to an existing list (note: if the List does not exist, it will be automatically created). - */ - public void subscribe( - String listId, String userId, SubscribeUserToListRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .addPathSegments("subscriptions") - .addPathSegment(userId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Delete a subscription to a list by list ID and user ID. - */ - public void unsubscribe(String listId, String userId) { - unsubscribe(listId, userId, null); - } - - /** - * Delete a subscription to a list by list ID and user ID. - */ - public void unsubscribe(String listId, String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("lists") - .addPathSegment(listId) - .addPathSegments("subscriptions") - .addPathSegment(userId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new CourierApiNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/requests/AddSubscribersToList.java b/src/main/java/com/courier/api/resources/lists/requests/AddSubscribersToList.java deleted file mode 100644 index 412c0b29..00000000 --- a/src/main/java/com/courier/api/resources/lists/requests/AddSubscribersToList.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.lists.types.PutSubscriptionsRecipient; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AddSubscribersToList.Builder.class) -public final class AddSubscribersToList { - private final List recipients; - - private final Map additionalProperties; - - private AddSubscribersToList(List recipients, Map additionalProperties) { - this.recipients = recipients; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("recipients") - public List getRecipients() { - return recipients; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddSubscribersToList && equalTo((AddSubscribersToList) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AddSubscribersToList other) { - return recipients.equals(other.recipients); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recipients); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List recipients = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AddSubscribersToList other) { - recipients(other.getRecipients()); - return this; - } - - @JsonSetter(value = "recipients", nulls = Nulls.SKIP) - public Builder recipients(List recipients) { - this.recipients.clear(); - this.recipients.addAll(recipients); - return this; - } - - public Builder addRecipients(PutSubscriptionsRecipient recipients) { - this.recipients.add(recipients); - return this; - } - - public Builder addAllRecipients(List recipients) { - this.recipients.addAll(recipients); - return this; - } - - public AddSubscribersToList build() { - return new AddSubscribersToList(recipients, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/requests/GetAllListsRequest.java b/src/main/java/com/courier/api/resources/lists/requests/GetAllListsRequest.java deleted file mode 100644 index ec2d6d78..00000000 --- a/src/main/java/com/courier/api/resources/lists/requests/GetAllListsRequest.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetAllListsRequest.Builder.class) -public final class GetAllListsRequest { - private final Optional cursor; - - private final Optional pattern; - - private final Map additionalProperties; - - private GetAllListsRequest( - Optional cursor, Optional pattern, Map additionalProperties) { - this.cursor = cursor; - this.pattern = pattern; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next page of lists. - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return "A pattern used to filter the list items returned. Pattern types supported: exact match on list_id or a pattern of one or more pattern parts. you may replace a part with either: * to match all parts in that position, or ** to signify a wildcard endsWith pattern match." - */ - @JsonProperty("pattern") - public Optional getPattern() { - return pattern; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetAllListsRequest && equalTo((GetAllListsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetAllListsRequest other) { - return cursor.equals(other.cursor) && pattern.equals(other.pattern); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor, this.pattern); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - private Optional pattern = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(GetAllListsRequest other) { - cursor(other.getCursor()); - pattern(other.getPattern()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @JsonSetter(value = "pattern", nulls = Nulls.SKIP) - public Builder pattern(Optional pattern) { - this.pattern = pattern; - return this; - } - - public Builder pattern(String pattern) { - this.pattern = Optional.of(pattern); - return this; - } - - public GetAllListsRequest build() { - return new GetAllListsRequest(cursor, pattern, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/requests/GetSubscriptionForListRequest.java b/src/main/java/com/courier/api/resources/lists/requests/GetSubscriptionForListRequest.java deleted file mode 100644 index 210d7b23..00000000 --- a/src/main/java/com/courier/api/resources/lists/requests/GetSubscriptionForListRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetSubscriptionForListRequest.Builder.class) -public final class GetSubscriptionForListRequest { - private final Optional cursor; - - private final Map additionalProperties; - - private GetSubscriptionForListRequest(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of list subscriptions - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetSubscriptionForListRequest && equalTo((GetSubscriptionForListRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetSubscriptionForListRequest other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(GetSubscriptionForListRequest other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public GetSubscriptionForListRequest build() { - return new GetSubscriptionForListRequest(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/requests/RestoreListRequest.java b/src/main/java/com/courier/api/resources/lists/requests/RestoreListRequest.java deleted file mode 100644 index 36d97308..00000000 --- a/src/main/java/com/courier/api/resources/lists/requests/RestoreListRequest.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RestoreListRequest.Builder.class) -public final class RestoreListRequest { - private final Map additionalProperties; - - private RestoreListRequest(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RestoreListRequest; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RestoreListRequest other) { - return this; - } - - public RestoreListRequest build() { - return new RestoreListRequest(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/requests/SubscribeUserToListRequest.java b/src/main/java/com/courier/api/resources/lists/requests/SubscribeUserToListRequest.java deleted file mode 100644 index 65016949..00000000 --- a/src/main/java/com/courier/api/resources/lists/requests/SubscribeUserToListRequest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscribeUserToListRequest.Builder.class) -public final class SubscribeUserToListRequest { - private final Optional preferences; - - private final Map additionalProperties; - - private SubscribeUserToListRequest( - Optional preferences, Map additionalProperties) { - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscribeUserToListRequest && equalTo((SubscribeUserToListRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubscribeUserToListRequest other) { - return preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubscribeUserToListRequest other) { - preferences(other.getPreferences()); - return this; - } - - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public Builder preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - public Builder preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - public SubscribeUserToListRequest build() { - return new SubscribeUserToListRequest(preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/requests/SubscribeUsersToListRequest.java b/src/main/java/com/courier/api/resources/lists/requests/SubscribeUsersToListRequest.java deleted file mode 100644 index 01587b0a..00000000 --- a/src/main/java/com/courier/api/resources/lists/requests/SubscribeUsersToListRequest.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.lists.types.PutSubscriptionsRecipient; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscribeUsersToListRequest.Builder.class) -public final class SubscribeUsersToListRequest { - private final List recipients; - - private final Map additionalProperties; - - private SubscribeUsersToListRequest( - List recipients, Map additionalProperties) { - this.recipients = recipients; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("recipients") - public List getRecipients() { - return recipients; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscribeUsersToListRequest && equalTo((SubscribeUsersToListRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubscribeUsersToListRequest other) { - return recipients.equals(other.recipients); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recipients); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List recipients = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubscribeUsersToListRequest other) { - recipients(other.getRecipients()); - return this; - } - - @JsonSetter(value = "recipients", nulls = Nulls.SKIP) - public Builder recipients(List recipients) { - this.recipients.clear(); - this.recipients.addAll(recipients); - return this; - } - - public Builder addRecipients(PutSubscriptionsRecipient recipients) { - this.recipients.add(recipients); - return this; - } - - public Builder addAllRecipients(List recipients) { - this.recipients.addAll(recipients); - return this; - } - - public SubscribeUsersToListRequest build() { - return new SubscribeUsersToListRequest(recipients, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/types/List.java b/src/main/java/com/courier/api/resources/lists/types/List.java deleted file mode 100644 index 4e2b15d3..00000000 --- a/src/main/java/com/courier/api/resources/lists/types/List.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = List.Builder.class) -public final class List { - private final String id; - - private final String name; - - private final Optional created; - - private final Optional updated; - - private final Map additionalProperties; - - private List( - String id, - String name, - Optional created, - Optional updated, - Map additionalProperties) { - this.id = id; - this.name = name; - this.created = created; - this.updated = updated; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("created") - public Optional getCreated() { - return created; - } - - @JsonProperty("updated") - public Optional getUpdated() { - return updated; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof List && equalTo((List) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(List other) { - return id.equals(other.id) - && name.equals(other.name) - && created.equals(other.created) - && updated.equals(other.updated); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.name, this.created, this.updated); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - NameStage id(String id); - - Builder from(List other); - } - - public interface NameStage { - _FinalStage name(String name); - } - - public interface _FinalStage { - List build(); - - _FinalStage created(Optional created); - - _FinalStage created(String created); - - _FinalStage updated(Optional updated); - - _FinalStage updated(String updated); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, _FinalStage { - private String id; - - private String name; - - private Optional updated = Optional.empty(); - - private Optional created = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(List other) { - id(other.getId()); - name(other.getName()); - created(other.getCreated()); - updated(other.getUpdated()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public NameStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - public _FinalStage updated(String updated) { - this.updated = Optional.of(updated); - return this; - } - - @java.lang.Override - @JsonSetter(value = "updated", nulls = Nulls.SKIP) - public _FinalStage updated(Optional updated) { - this.updated = updated; - return this; - } - - @java.lang.Override - public _FinalStage created(String created) { - this.created = Optional.of(created); - return this; - } - - @java.lang.Override - @JsonSetter(value = "created", nulls = Nulls.SKIP) - public _FinalStage created(Optional created) { - this.created = created; - return this; - } - - @java.lang.Override - public List build() { - return new List(id, name, created, updated, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/types/ListGetAllResponse.java b/src/main/java/com/courier/api/resources/lists/types/ListGetAllResponse.java deleted file mode 100644 index b9a8cacf..00000000 --- a/src/main/java/com/courier/api/resources/lists/types/ListGetAllResponse.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListGetAllResponse.Builder.class) -public final class ListGetAllResponse { - private final Paging paging; - - private final java.util.List items; - - private final Map additionalProperties; - - private ListGetAllResponse(Paging paging, java.util.List items, Map additionalProperties) { - this.paging = paging; - this.items = items; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @JsonProperty("items") - public java.util.List getItems() { - return items; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListGetAllResponse && equalTo((ListGetAllResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListGetAllResponse other) { - return paging.equals(other.paging) && items.equals(other.items); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.items); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(ListGetAllResponse other); - } - - public interface _FinalStage { - ListGetAllResponse build(); - - _FinalStage items(java.util.List items); - - _FinalStage addItems(List items); - - _FinalStage addAllItems(java.util.List items); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private java.util.List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListGetAllResponse other) { - paging(other.getPaging()); - items(other.getItems()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllItems(java.util.List items) { - this.items.addAll(items); - return this; - } - - @java.lang.Override - public _FinalStage addItems(List items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(java.util.List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - @java.lang.Override - public ListGetAllResponse build() { - return new ListGetAllResponse(paging, items, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/types/ListGetSubscriptionsResponse.java b/src/main/java/com/courier/api/resources/lists/types/ListGetSubscriptionsResponse.java deleted file mode 100644 index a4624eda..00000000 --- a/src/main/java/com/courier/api/resources/lists/types/ListGetSubscriptionsResponse.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListGetSubscriptionsResponse.Builder.class) -public final class ListGetSubscriptionsResponse { - private final Paging paging; - - private final List items; - - private final Map additionalProperties; - - private ListGetSubscriptionsResponse( - Paging paging, List items, Map additionalProperties) { - this.paging = paging; - this.items = items; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @JsonProperty("items") - public List getItems() { - return items; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListGetSubscriptionsResponse && equalTo((ListGetSubscriptionsResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListGetSubscriptionsResponse other) { - return paging.equals(other.paging) && items.equals(other.items); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.items); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(ListGetSubscriptionsResponse other); - } - - public interface _FinalStage { - ListGetSubscriptionsResponse build(); - - _FinalStage items(List items); - - _FinalStage addItems(ListSubscriptionRecipient items); - - _FinalStage addAllItems(List items); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListGetSubscriptionsResponse other) { - paging(other.getPaging()); - items(other.getItems()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllItems(List items) { - this.items.addAll(items); - return this; - } - - @java.lang.Override - public _FinalStage addItems(ListSubscriptionRecipient items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - @java.lang.Override - public ListGetSubscriptionsResponse build() { - return new ListGetSubscriptionsResponse(paging, items, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/types/ListPutParams.java b/src/main/java/com/courier/api/resources/lists/types/ListPutParams.java deleted file mode 100644 index 59a11bb9..00000000 --- a/src/main/java/com/courier/api/resources/lists/types/ListPutParams.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListPutParams.Builder.class) -public final class ListPutParams { - private final String name; - - private final Optional preferences; - - private final Map additionalProperties; - - private ListPutParams( - String name, Optional preferences, Map additionalProperties) { - this.name = name; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListPutParams && equalTo((ListPutParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListPutParams other) { - return name.equals(other.name) && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.name, this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - _FinalStage name(String name); - - Builder from(ListPutParams other); - } - - public interface _FinalStage { - ListPutParams build(); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(RecipientPreferences preferences); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NameStage, _FinalStage { - private String name; - - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListPutParams other) { - name(other.getName()); - preferences(other.getPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - public _FinalStage preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public ListPutParams build() { - return new ListPutParams(name, preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/types/ListSubscriptionRecipient.java b/src/main/java/com/courier/api/resources/lists/types/ListSubscriptionRecipient.java deleted file mode 100644 index e9de913b..00000000 --- a/src/main/java/com/courier/api/resources/lists/types/ListSubscriptionRecipient.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListSubscriptionRecipient.Builder.class) -public final class ListSubscriptionRecipient { - private final String recipientId; - - private final Optional created; - - private final Optional preferences; - - private final Map additionalProperties; - - private ListSubscriptionRecipient( - String recipientId, - Optional created, - Optional preferences, - Map additionalProperties) { - this.recipientId = recipientId; - this.created = created; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("recipientId") - public String getRecipientId() { - return recipientId; - } - - @JsonProperty("created") - public Optional getCreated() { - return created; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListSubscriptionRecipient && equalTo((ListSubscriptionRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListSubscriptionRecipient other) { - return recipientId.equals(other.recipientId) - && created.equals(other.created) - && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recipientId, this.created, this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RecipientIdStage builder() { - return new Builder(); - } - - public interface RecipientIdStage { - _FinalStage recipientId(String recipientId); - - Builder from(ListSubscriptionRecipient other); - } - - public interface _FinalStage { - ListSubscriptionRecipient build(); - - _FinalStage created(Optional created); - - _FinalStage created(String created); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(RecipientPreferences preferences); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RecipientIdStage, _FinalStage { - private String recipientId; - - private Optional preferences = Optional.empty(); - - private Optional created = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListSubscriptionRecipient other) { - recipientId(other.getRecipientId()); - created(other.getCreated()); - preferences(other.getPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("recipientId") - public _FinalStage recipientId(String recipientId) { - this.recipientId = recipientId; - return this; - } - - @java.lang.Override - public _FinalStage preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public _FinalStage created(String created) { - this.created = Optional.of(created); - return this; - } - - @java.lang.Override - @JsonSetter(value = "created", nulls = Nulls.SKIP) - public _FinalStage created(Optional created) { - this.created = created; - return this; - } - - @java.lang.Override - public ListSubscriptionRecipient build() { - return new ListSubscriptionRecipient(recipientId, created, preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/lists/types/PutSubscriptionsRecipient.java b/src/main/java/com/courier/api/resources/lists/types/PutSubscriptionsRecipient.java deleted file mode 100644 index a32c411b..00000000 --- a/src/main/java/com/courier/api/resources/lists/types/PutSubscriptionsRecipient.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.lists.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PutSubscriptionsRecipient.Builder.class) -public final class PutSubscriptionsRecipient { - private final String recipientId; - - private final Optional preferences; - - private final Map additionalProperties; - - private PutSubscriptionsRecipient( - String recipientId, Optional preferences, Map additionalProperties) { - this.recipientId = recipientId; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("recipientId") - public String getRecipientId() { - return recipientId; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PutSubscriptionsRecipient && equalTo((PutSubscriptionsRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PutSubscriptionsRecipient other) { - return recipientId.equals(other.recipientId) && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recipientId, this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RecipientIdStage builder() { - return new Builder(); - } - - public interface RecipientIdStage { - _FinalStage recipientId(String recipientId); - - Builder from(PutSubscriptionsRecipient other); - } - - public interface _FinalStage { - PutSubscriptionsRecipient build(); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(RecipientPreferences preferences); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RecipientIdStage, _FinalStage { - private String recipientId; - - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PutSubscriptionsRecipient other) { - recipientId(other.getRecipientId()); - preferences(other.getPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("recipientId") - public _FinalStage recipientId(String recipientId) { - this.recipientId = recipientId; - return this; - } - - @java.lang.Override - public _FinalStage preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public PutSubscriptionsRecipient build() { - return new PutSubscriptionsRecipient(recipientId, preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/MessagesClient.java b/src/main/java/com/courier/api/resources/messages/MessagesClient.java deleted file mode 100644 index 72dbcd2f..00000000 --- a/src/main/java/com/courier/api/resources/messages/MessagesClient.java +++ /dev/null @@ -1,370 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.errors.CourierApiMessageNotFoundError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.commons.types.MessageNotFound; -import com.courier.api.resources.messages.requests.GetMessageHistoryRequest; -import com.courier.api.resources.messages.requests.ListMessagesRequest; -import com.courier.api.resources.messages.types.ListMessagesResponse; -import com.courier.api.resources.messages.types.MessageDetails; -import com.courier.api.resources.messages.types.MessageDetailsExtended; -import com.courier.api.resources.messages.types.MessageHistoryResponse; -import com.courier.api.resources.messages.types.RenderOutputResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class MessagesClient { - protected final ClientOptions clientOptions; - - public MessagesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Fetch the statuses of messages you've previously sent. - */ - public ListMessagesResponse list() { - return list(ListMessagesRequest.builder().build()); - } - - /** - * Fetch the statuses of messages you've previously sent. - */ - public ListMessagesResponse list(ListMessagesRequest request) { - return list(request, null); - } - - /** - * Fetch the statuses of messages you've previously sent. - */ - public ListMessagesResponse list(ListMessagesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("messages"); - if (request.getArchived().isPresent()) { - httpUrl.addQueryParameter("archived", request.getArchived().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getEvent().isPresent()) { - httpUrl.addQueryParameter("event", request.getEvent().get()); - } - if (request.getList().isPresent()) { - httpUrl.addQueryParameter("list", request.getList().get()); - } - if (request.getMessageId().isPresent()) { - httpUrl.addQueryParameter("messageId", request.getMessageId().get()); - } - if (request.getNotification().isPresent()) { - httpUrl.addQueryParameter("notification", request.getNotification().get()); - } - if (request.getProvider().isPresent()) { - httpUrl.addQueryParameter("provider", request.getProvider().get()); - } - if (request.getRecipient().isPresent()) { - httpUrl.addQueryParameter("recipient", request.getRecipient().get()); - } - if (request.getStatus().isPresent()) { - httpUrl.addQueryParameter("status", request.getStatus().get()); - } - if (request.getTag().isPresent()) { - httpUrl.addQueryParameter("tag", request.getTag().get()); - } - if (request.getTags().isPresent()) { - httpUrl.addQueryParameter("tags", request.getTags().get()); - } - if (request.getTenantId().isPresent()) { - httpUrl.addQueryParameter("tenant_id", request.getTenantId().get()); - } - if (request.getEnqueuedAfter().isPresent()) { - httpUrl.addQueryParameter( - "enqueued_after", request.getEnqueuedAfter().get()); - } - if (request.getTraceId().isPresent()) { - httpUrl.addQueryParameter("traceId", request.getTraceId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListMessagesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Fetch the status of a message you've previously sent. - */ - public MessageDetailsExtended get(String messageId) { - return get(messageId, null); - } - - /** - * Fetch the status of a message you've previously sent. - */ - public MessageDetailsExtended get(String messageId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("messages") - .addPathSegment(messageId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MessageDetailsExtended.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - case 404: - throw new CourierApiMessageNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, MessageNotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Cancel a message that is currently in the process of being delivered. A well-formatted API call to the cancel message API will return either 200 status code for a successful cancellation or 409 status code for an unsuccessful cancellation. Both cases will include the actual message record in the response body (see details below). - */ - public MessageDetails cancel(String messageId) { - return cancel(messageId, null); - } - - /** - * Cancel a message that is currently in the process of being delivered. A well-formatted API call to the cancel message API will return either 200 status code for a successful cancellation or 409 status code for an unsuccessful cancellation. Both cases will include the actual message record in the response body (see details below). - */ - public MessageDetails cancel(String messageId, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("messages") - .addPathSegment(messageId) - .addPathSegments("cancel") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", RequestBody.create("", null)) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MessageDetails.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Fetch the array of events of a message you've previously sent. - */ - public MessageHistoryResponse getHistory(String messageId) { - return getHistory(messageId, GetMessageHistoryRequest.builder().build()); - } - - /** - * Fetch the array of events of a message you've previously sent. - */ - public MessageHistoryResponse getHistory(String messageId, GetMessageHistoryRequest request) { - return getHistory(messageId, request, null); - } - - /** - * Fetch the array of events of a message you've previously sent. - */ - public MessageHistoryResponse getHistory( - String messageId, GetMessageHistoryRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("messages") - .addPathSegment(messageId) - .addPathSegments("history"); - if (request.getType().isPresent()) { - httpUrl.addQueryParameter("type", request.getType().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MessageHistoryResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - case 404: - throw new CourierApiMessageNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, MessageNotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public RenderOutputResponse getContent(String messageId) { - return getContent(messageId, null); - } - - public RenderOutputResponse getContent(String messageId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("messages") - .addPathSegment(messageId) - .addPathSegments("output") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RenderOutputResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - switch (response.code()) { - case 400: - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - case 404: - throw new CourierApiMessageNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, MessageNotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void archive(String requestId) { - archive(requestId, null); - } - - public void archive(String requestId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("requests") - .addPathSegment(requestId) - .addPathSegments("archive") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/requests/GetMessageHistoryRequest.java b/src/main/java/com/courier/api/resources/messages/requests/GetMessageHistoryRequest.java deleted file mode 100644 index 470390a7..00000000 --- a/src/main/java/com/courier/api/resources/messages/requests/GetMessageHistoryRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetMessageHistoryRequest.Builder.class) -public final class GetMessageHistoryRequest { - private final Optional type; - - private final Map additionalProperties; - - private GetMessageHistoryRequest(Optional type, Map additionalProperties) { - this.type = type; - this.additionalProperties = additionalProperties; - } - - /** - * @return A supported Message History type that will filter the events returned. - */ - @JsonProperty("type") - public Optional getType() { - return type; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetMessageHistoryRequest && equalTo((GetMessageHistoryRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetMessageHistoryRequest other) { - return type.equals(other.type); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional type = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(GetMessageHistoryRequest other) { - type(other.getType()); - return this; - } - - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public Builder type(Optional type) { - this.type = type; - return this; - } - - public Builder type(String type) { - this.type = Optional.of(type); - return this; - } - - public GetMessageHistoryRequest build() { - return new GetMessageHistoryRequest(type, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/requests/ListMessagesRequest.java b/src/main/java/com/courier/api/resources/messages/requests/ListMessagesRequest.java deleted file mode 100644 index bdcf9781..00000000 --- a/src/main/java/com/courier/api/resources/messages/requests/ListMessagesRequest.java +++ /dev/null @@ -1,480 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListMessagesRequest.Builder.class) -public final class ListMessagesRequest { - private final Optional archived; - - private final Optional cursor; - - private final Optional event; - - private final Optional list; - - private final Optional messageId; - - private final Optional notification; - - private final Optional provider; - - private final Optional recipient; - - private final Optional status; - - private final Optional tag; - - private final Optional tags; - - private final Optional tenantId; - - private final Optional enqueuedAfter; - - private final Optional traceId; - - private final Map additionalProperties; - - private ListMessagesRequest( - Optional archived, - Optional cursor, - Optional event, - Optional list, - Optional messageId, - Optional notification, - Optional provider, - Optional recipient, - Optional status, - Optional tag, - Optional tags, - Optional tenantId, - Optional enqueuedAfter, - Optional traceId, - Map additionalProperties) { - this.archived = archived; - this.cursor = cursor; - this.event = event; - this.list = list; - this.messageId = messageId; - this.notification = notification; - this.provider = provider; - this.recipient = recipient; - this.status = status; - this.tag = tag; - this.tags = tags; - this.tenantId = tenantId; - this.enqueuedAfter = enqueuedAfter; - this.traceId = traceId; - this.additionalProperties = additionalProperties; - } - - /** - * @return A boolean value that indicates whether archived messages should be included in the response. - */ - @JsonProperty("archived") - public Optional getArchived() { - return archived; - } - - /** - * @return A unique identifier that allows for fetching the next set of messages. - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return A unique identifier representing the event that was used to send the event. - */ - @JsonProperty("event") - public Optional getEvent() { - return event; - } - - /** - * @return A unique identifier representing the list the message was sent to. - */ - @JsonProperty("list") - public Optional getList() { - return list; - } - - /** - * @return A unique identifier representing the message_id returned from either /send or /send/list. - */ - @JsonProperty("messageId") - public Optional getMessageId() { - return messageId; - } - - /** - * @return A unique identifier representing the notification that was used to send the event. - */ - @JsonProperty("notification") - public Optional getNotification() { - return notification; - } - - /** - * @return The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, slack, msteams, etc. Allows multiple values to be set in query parameters. - */ - @JsonProperty("provider") - public Optional getProvider() { - return provider; - } - - /** - * @return A unique identifier representing the recipient associated with the requested profile. - */ - @JsonProperty("recipient") - public Optional getRecipient() { - return recipient; - } - - /** - * @return An indicator of the current status of the message. Allows multiple values to be set in query parameters. - */ - @JsonProperty("status") - public Optional getStatus() { - return status; - } - - /** - * @return A tag placed in the metadata.tags during a notification send. Allows multiple values to be set in query parameters. - */ - @JsonProperty("tag") - public Optional getTag() { - return tag; - } - - /** - * @return A comma delimited list of 'tags'. Messages will be returned if they match any of the tags passed in. - */ - @JsonProperty("tags") - public Optional getTags() { - return tags; - } - - /** - * @return Messages sent with the context of a Tenant - */ - @JsonProperty("tenant_id") - public Optional getTenantId() { - return tenantId; - } - - /** - * @return The enqueued datetime of a message to filter out messages received before. - */ - @JsonProperty("enqueued_after") - public Optional getEnqueuedAfter() { - return enqueuedAfter; - } - - /** - * @return The unique identifier used to trace the requests - */ - @JsonProperty("traceId") - public Optional getTraceId() { - return traceId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListMessagesRequest && equalTo((ListMessagesRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListMessagesRequest other) { - return archived.equals(other.archived) - && cursor.equals(other.cursor) - && event.equals(other.event) - && list.equals(other.list) - && messageId.equals(other.messageId) - && notification.equals(other.notification) - && provider.equals(other.provider) - && recipient.equals(other.recipient) - && status.equals(other.status) - && tag.equals(other.tag) - && tags.equals(other.tags) - && tenantId.equals(other.tenantId) - && enqueuedAfter.equals(other.enqueuedAfter) - && traceId.equals(other.traceId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.archived, - this.cursor, - this.event, - this.list, - this.messageId, - this.notification, - this.provider, - this.recipient, - this.status, - this.tag, - this.tags, - this.tenantId, - this.enqueuedAfter, - this.traceId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional archived = Optional.empty(); - - private Optional cursor = Optional.empty(); - - private Optional event = Optional.empty(); - - private Optional list = Optional.empty(); - - private Optional messageId = Optional.empty(); - - private Optional notification = Optional.empty(); - - private Optional provider = Optional.empty(); - - private Optional recipient = Optional.empty(); - - private Optional status = Optional.empty(); - - private Optional tag = Optional.empty(); - - private Optional tags = Optional.empty(); - - private Optional tenantId = Optional.empty(); - - private Optional enqueuedAfter = Optional.empty(); - - private Optional traceId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListMessagesRequest other) { - archived(other.getArchived()); - cursor(other.getCursor()); - event(other.getEvent()); - list(other.getList()); - messageId(other.getMessageId()); - notification(other.getNotification()); - provider(other.getProvider()); - recipient(other.getRecipient()); - status(other.getStatus()); - tag(other.getTag()); - tags(other.getTags()); - tenantId(other.getTenantId()); - enqueuedAfter(other.getEnqueuedAfter()); - traceId(other.getTraceId()); - return this; - } - - @JsonSetter(value = "archived", nulls = Nulls.SKIP) - public Builder archived(Optional archived) { - this.archived = archived; - return this; - } - - public Builder archived(Boolean archived) { - this.archived = Optional.of(archived); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @JsonSetter(value = "event", nulls = Nulls.SKIP) - public Builder event(Optional event) { - this.event = event; - return this; - } - - public Builder event(String event) { - this.event = Optional.of(event); - return this; - } - - @JsonSetter(value = "list", nulls = Nulls.SKIP) - public Builder list(Optional list) { - this.list = list; - return this; - } - - public Builder list(String list) { - this.list = Optional.of(list); - return this; - } - - @JsonSetter(value = "messageId", nulls = Nulls.SKIP) - public Builder messageId(Optional messageId) { - this.messageId = messageId; - return this; - } - - public Builder messageId(String messageId) { - this.messageId = Optional.of(messageId); - return this; - } - - @JsonSetter(value = "notification", nulls = Nulls.SKIP) - public Builder notification(Optional notification) { - this.notification = notification; - return this; - } - - public Builder notification(String notification) { - this.notification = Optional.of(notification); - return this; - } - - @JsonSetter(value = "provider", nulls = Nulls.SKIP) - public Builder provider(Optional provider) { - this.provider = provider; - return this; - } - - public Builder provider(String provider) { - this.provider = Optional.of(provider); - return this; - } - - @JsonSetter(value = "recipient", nulls = Nulls.SKIP) - public Builder recipient(Optional recipient) { - this.recipient = recipient; - return this; - } - - public Builder recipient(String recipient) { - this.recipient = Optional.of(recipient); - return this; - } - - @JsonSetter(value = "status", nulls = Nulls.SKIP) - public Builder status(Optional status) { - this.status = status; - return this; - } - - public Builder status(String status) { - this.status = Optional.of(status); - return this; - } - - @JsonSetter(value = "tag", nulls = Nulls.SKIP) - public Builder tag(Optional tag) { - this.tag = tag; - return this; - } - - public Builder tag(String tag) { - this.tag = Optional.of(tag); - return this; - } - - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public Builder tags(Optional tags) { - this.tags = tags; - return this; - } - - public Builder tags(String tags) { - this.tags = Optional.of(tags); - return this; - } - - @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) - public Builder tenantId(Optional tenantId) { - this.tenantId = tenantId; - return this; - } - - public Builder tenantId(String tenantId) { - this.tenantId = Optional.of(tenantId); - return this; - } - - @JsonSetter(value = "enqueued_after", nulls = Nulls.SKIP) - public Builder enqueuedAfter(Optional enqueuedAfter) { - this.enqueuedAfter = enqueuedAfter; - return this; - } - - public Builder enqueuedAfter(String enqueuedAfter) { - this.enqueuedAfter = Optional.of(enqueuedAfter); - return this; - } - - @JsonSetter(value = "traceId", nulls = Nulls.SKIP) - public Builder traceId(Optional traceId) { - this.traceId = traceId; - return this; - } - - public Builder traceId(String traceId) { - this.traceId = Optional.of(traceId); - return this; - } - - public ListMessagesRequest build() { - return new ListMessagesRequest( - archived, - cursor, - event, - list, - messageId, - notification, - provider, - recipient, - status, - tag, - tags, - tenantId, - enqueuedAfter, - traceId, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/IMessageDetails.java b/src/main/java/com/courier/api/resources/messages/types/IMessageDetails.java deleted file mode 100644 index 3410691b..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/IMessageDetails.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import java.util.Optional; - -public interface IMessageDetails { - String getId(); - - MessageStatus getStatus(); - - long getEnqueued(); - - long getSent(); - - long getDelivered(); - - long getOpened(); - - long getClicked(); - - String getRecipient(); - - String getEvent(); - - String getNotification(); - - Optional getError(); - - Optional getReason(); -} diff --git a/src/main/java/com/courier/api/resources/messages/types/ListMessagesResponse.java b/src/main/java/com/courier/api/resources/messages/types/ListMessagesResponse.java deleted file mode 100644 index cd938417..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/ListMessagesResponse.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListMessagesResponse.Builder.class) -public final class ListMessagesResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private ListMessagesResponse( - Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - /** - * @return Paging information for the result set. - */ - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - /** - * @return An array of messages with their details. - */ - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListMessagesResponse && equalTo((ListMessagesResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListMessagesResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(ListMessagesResponse other); - } - - public interface _FinalStage { - ListMessagesResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(MessageDetails results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListMessagesResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - /** - *

Paging information for the result set.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - /** - *

An array of messages with their details.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - /** - *

An array of messages with their details.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addResults(MessageDetails results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public ListMessagesResponse build() { - return new ListMessagesResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/MessageDetails.java b/src/main/java/com/courier/api/resources/messages/types/MessageDetails.java deleted file mode 100644 index 9d9a6bf0..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/MessageDetails.java +++ /dev/null @@ -1,513 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageDetails.Builder.class) -public final class MessageDetails implements IMessageDetails { - private final String id; - - private final MessageStatus status; - - private final long enqueued; - - private final long sent; - - private final long delivered; - - private final long opened; - - private final long clicked; - - private final String recipient; - - private final String event; - - private final String notification; - - private final Optional error; - - private final Optional reason; - - private final Map additionalProperties; - - private MessageDetails( - String id, - MessageStatus status, - long enqueued, - long sent, - long delivered, - long opened, - long clicked, - String recipient, - String event, - String notification, - Optional error, - Optional reason, - Map additionalProperties) { - this.id = id; - this.status = status; - this.enqueued = enqueued; - this.sent = sent; - this.delivered = delivered; - this.opened = opened; - this.clicked = clicked; - this.recipient = recipient; - this.event = event; - this.notification = notification; - this.error = error; - this.reason = reason; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier associated with the message you wish to retrieve (results from a send). - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The current status of the message. - */ - @JsonProperty("status") - @java.lang.Override - public MessageStatus getStatus() { - return status; - } - - /** - * @return A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("enqueued") - @java.lang.Override - public long getEnqueued() { - return enqueued; - } - - /** - * @return A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("sent") - @java.lang.Override - public long getSent() { - return sent; - } - - /** - * @return A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("delivered") - @java.lang.Override - public long getDelivered() { - return delivered; - } - - /** - * @return A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("opened") - @java.lang.Override - public long getOpened() { - return opened; - } - - /** - * @return A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("clicked") - @java.lang.Override - public long getClicked() { - return clicked; - } - - /** - * @return A unique identifier associated with the recipient of the delivered message. - */ - @JsonProperty("recipient") - @java.lang.Override - public String getRecipient() { - return recipient; - } - - /** - * @return A unique identifier associated with the event of the delivered message. - */ - @JsonProperty("event") - @java.lang.Override - public String getEvent() { - return event; - } - - /** - * @return A unique identifier associated with the notification of the delivered message. - */ - @JsonProperty("notification") - @java.lang.Override - public String getNotification() { - return notification; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("error") - @java.lang.Override - public Optional getError() { - return error; - } - - /** - * @return The reason for the current status of the message. - */ - @JsonProperty("reason") - @java.lang.Override - public Optional getReason() { - return reason; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageDetails && equalTo((MessageDetails) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageDetails other) { - return id.equals(other.id) - && status.equals(other.status) - && enqueued == other.enqueued - && sent == other.sent - && delivered == other.delivered - && opened == other.opened - && clicked == other.clicked - && recipient.equals(other.recipient) - && event.equals(other.event) - && notification.equals(other.notification) - && error.equals(other.error) - && reason.equals(other.reason); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.id, - this.status, - this.enqueued, - this.sent, - this.delivered, - this.opened, - this.clicked, - this.recipient, - this.event, - this.notification, - this.error, - this.reason); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - StatusStage id(String id); - - Builder from(MessageDetails other); - } - - public interface StatusStage { - EnqueuedStage status(MessageStatus status); - } - - public interface EnqueuedStage { - SentStage enqueued(long enqueued); - } - - public interface SentStage { - DeliveredStage sent(long sent); - } - - public interface DeliveredStage { - OpenedStage delivered(long delivered); - } - - public interface OpenedStage { - ClickedStage opened(long opened); - } - - public interface ClickedStage { - RecipientStage clicked(long clicked); - } - - public interface RecipientStage { - EventStage recipient(String recipient); - } - - public interface EventStage { - NotificationStage event(String event); - } - - public interface NotificationStage { - _FinalStage notification(String notification); - } - - public interface _FinalStage { - MessageDetails build(); - - _FinalStage error(Optional error); - - _FinalStage error(String error); - - _FinalStage reason(Optional reason); - - _FinalStage reason(Reason reason); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - StatusStage, - EnqueuedStage, - SentStage, - DeliveredStage, - OpenedStage, - ClickedStage, - RecipientStage, - EventStage, - NotificationStage, - _FinalStage { - private String id; - - private MessageStatus status; - - private long enqueued; - - private long sent; - - private long delivered; - - private long opened; - - private long clicked; - - private String recipient; - - private String event; - - private String notification; - - private Optional reason = Optional.empty(); - - private Optional error = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MessageDetails other) { - id(other.getId()); - status(other.getStatus()); - enqueued(other.getEnqueued()); - sent(other.getSent()); - delivered(other.getDelivered()); - opened(other.getOpened()); - clicked(other.getClicked()); - recipient(other.getRecipient()); - event(other.getEvent()); - notification(other.getNotification()); - error(other.getError()); - reason(other.getReason()); - return this; - } - - /** - *

A unique identifier associated with the message you wish to retrieve (results from a send).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public StatusStage id(String id) { - this.id = id; - return this; - } - - /** - *

The current status of the message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("status") - public EnqueuedStage status(MessageStatus status) { - this.status = status; - return this; - } - - /** - *

A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("enqueued") - public SentStage enqueued(long enqueued) { - this.enqueued = enqueued; - return this; - } - - /** - *

A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("sent") - public DeliveredStage sent(long sent) { - this.sent = sent; - return this; - } - - /** - *

A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("delivered") - public OpenedStage delivered(long delivered) { - this.delivered = delivered; - return this; - } - - /** - *

A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("opened") - public ClickedStage opened(long opened) { - this.opened = opened; - return this; - } - - /** - *

A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("clicked") - public RecipientStage clicked(long clicked) { - this.clicked = clicked; - return this; - } - - /** - *

A unique identifier associated with the recipient of the delivered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("recipient") - public EventStage recipient(String recipient) { - this.recipient = recipient; - return this; - } - - /** - *

A unique identifier associated with the event of the delivered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("event") - public NotificationStage event(String event) { - this.event = event; - return this; - } - - /** - *

A unique identifier associated with the notification of the delivered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("notification") - public _FinalStage notification(String notification) { - this.notification = notification; - return this; - } - - /** - *

The reason for the current status of the message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage reason(Reason reason) { - this.reason = Optional.of(reason); - return this; - } - - @java.lang.Override - @JsonSetter(value = "reason", nulls = Nulls.SKIP) - public _FinalStage reason(Optional reason) { - this.reason = reason; - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage error(String error) { - this.error = Optional.of(error); - return this; - } - - @java.lang.Override - @JsonSetter(value = "error", nulls = Nulls.SKIP) - public _FinalStage error(Optional error) { - this.error = error; - return this; - } - - @java.lang.Override - public MessageDetails build() { - return new MessageDetails( - id, - status, - enqueued, - sent, - delivered, - opened, - clicked, - recipient, - event, - notification, - error, - reason, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/MessageDetailsExtended.java b/src/main/java/com/courier/api/resources/messages/types/MessageDetailsExtended.java deleted file mode 100644 index be7bf047..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/MessageDetailsExtended.java +++ /dev/null @@ -1,546 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageDetailsExtended.Builder.class) -public final class MessageDetailsExtended implements IMessageDetails { - private final String id; - - private final MessageStatus status; - - private final long enqueued; - - private final long sent; - - private final long delivered; - - private final long opened; - - private final long clicked; - - private final String recipient; - - private final String event; - - private final String notification; - - private final Optional error; - - private final Optional reason; - - private final Optional>> providers; - - private final Map additionalProperties; - - private MessageDetailsExtended( - String id, - MessageStatus status, - long enqueued, - long sent, - long delivered, - long opened, - long clicked, - String recipient, - String event, - String notification, - Optional error, - Optional reason, - Optional>> providers, - Map additionalProperties) { - this.id = id; - this.status = status; - this.enqueued = enqueued; - this.sent = sent; - this.delivered = delivered; - this.opened = opened; - this.clicked = clicked; - this.recipient = recipient; - this.event = event; - this.notification = notification; - this.error = error; - this.reason = reason; - this.providers = providers; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier associated with the message you wish to retrieve (results from a send). - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The current status of the message. - */ - @JsonProperty("status") - @java.lang.Override - public MessageStatus getStatus() { - return status; - } - - /** - * @return A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("enqueued") - @java.lang.Override - public long getEnqueued() { - return enqueued; - } - - /** - * @return A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("sent") - @java.lang.Override - public long getSent() { - return sent; - } - - /** - * @return A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("delivered") - @java.lang.Override - public long getDelivered() { - return delivered; - } - - /** - * @return A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("opened") - @java.lang.Override - public long getOpened() { - return opened; - } - - /** - * @return A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch. - */ - @JsonProperty("clicked") - @java.lang.Override - public long getClicked() { - return clicked; - } - - /** - * @return A unique identifier associated with the recipient of the delivered message. - */ - @JsonProperty("recipient") - @java.lang.Override - public String getRecipient() { - return recipient; - } - - /** - * @return A unique identifier associated with the event of the delivered message. - */ - @JsonProperty("event") - @java.lang.Override - public String getEvent() { - return event; - } - - /** - * @return A unique identifier associated with the notification of the delivered message. - */ - @JsonProperty("notification") - @java.lang.Override - public String getNotification() { - return notification; - } - - /** - * @return A message describing the error that occurred. - */ - @JsonProperty("error") - @java.lang.Override - public Optional getError() { - return error; - } - - /** - * @return The reason for the current status of the message. - */ - @JsonProperty("reason") - @java.lang.Override - public Optional getReason() { - return reason; - } - - @JsonProperty("providers") - public Optional>> getProviders() { - return providers; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageDetailsExtended && equalTo((MessageDetailsExtended) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageDetailsExtended other) { - return id.equals(other.id) - && status.equals(other.status) - && enqueued == other.enqueued - && sent == other.sent - && delivered == other.delivered - && opened == other.opened - && clicked == other.clicked - && recipient.equals(other.recipient) - && event.equals(other.event) - && notification.equals(other.notification) - && error.equals(other.error) - && reason.equals(other.reason) - && providers.equals(other.providers); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.id, - this.status, - this.enqueued, - this.sent, - this.delivered, - this.opened, - this.clicked, - this.recipient, - this.event, - this.notification, - this.error, - this.reason, - this.providers); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - StatusStage id(String id); - - Builder from(MessageDetailsExtended other); - } - - public interface StatusStage { - EnqueuedStage status(MessageStatus status); - } - - public interface EnqueuedStage { - SentStage enqueued(long enqueued); - } - - public interface SentStage { - DeliveredStage sent(long sent); - } - - public interface DeliveredStage { - OpenedStage delivered(long delivered); - } - - public interface OpenedStage { - ClickedStage opened(long opened); - } - - public interface ClickedStage { - RecipientStage clicked(long clicked); - } - - public interface RecipientStage { - EventStage recipient(String recipient); - } - - public interface EventStage { - NotificationStage event(String event); - } - - public interface NotificationStage { - _FinalStage notification(String notification); - } - - public interface _FinalStage { - MessageDetailsExtended build(); - - _FinalStage error(Optional error); - - _FinalStage error(String error); - - _FinalStage reason(Optional reason); - - _FinalStage reason(Reason reason); - - _FinalStage providers(Optional>> providers); - - _FinalStage providers(List> providers); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements IdStage, - StatusStage, - EnqueuedStage, - SentStage, - DeliveredStage, - OpenedStage, - ClickedStage, - RecipientStage, - EventStage, - NotificationStage, - _FinalStage { - private String id; - - private MessageStatus status; - - private long enqueued; - - private long sent; - - private long delivered; - - private long opened; - - private long clicked; - - private String recipient; - - private String event; - - private String notification; - - private Optional>> providers = Optional.empty(); - - private Optional reason = Optional.empty(); - - private Optional error = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MessageDetailsExtended other) { - id(other.getId()); - status(other.getStatus()); - enqueued(other.getEnqueued()); - sent(other.getSent()); - delivered(other.getDelivered()); - opened(other.getOpened()); - clicked(other.getClicked()); - recipient(other.getRecipient()); - event(other.getEvent()); - notification(other.getNotification()); - error(other.getError()); - reason(other.getReason()); - providers(other.getProviders()); - return this; - } - - /** - *

A unique identifier associated with the message you wish to retrieve (results from a send).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public StatusStage id(String id) { - this.id = id; - return this; - } - - /** - *

The current status of the message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("status") - public EnqueuedStage status(MessageStatus status) { - this.status = status; - return this; - } - - /** - *

A UTC timestamp at which Courier received the message request. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("enqueued") - public SentStage enqueued(long enqueued) { - this.enqueued = enqueued; - return this; - } - - /** - *

A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("sent") - public DeliveredStage sent(long sent) { - this.sent = sent; - return this; - } - - /** - *

A UTC timestamp at which the Integration provider delivered the message. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("delivered") - public OpenedStage delivered(long delivered) { - this.delivered = delivered; - return this; - } - - /** - *

A UTC timestamp at which the recipient opened a message for the first time. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("opened") - public ClickedStage opened(long opened) { - this.opened = opened; - return this; - } - - /** - *

A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored as a millisecond representation of the Unix epoch.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("clicked") - public RecipientStage clicked(long clicked) { - this.clicked = clicked; - return this; - } - - /** - *

A unique identifier associated with the recipient of the delivered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("recipient") - public EventStage recipient(String recipient) { - this.recipient = recipient; - return this; - } - - /** - *

A unique identifier associated with the event of the delivered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("event") - public NotificationStage event(String event) { - this.event = event; - return this; - } - - /** - *

A unique identifier associated with the notification of the delivered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("notification") - public _FinalStage notification(String notification) { - this.notification = notification; - return this; - } - - @java.lang.Override - public _FinalStage providers(List> providers) { - this.providers = Optional.of(providers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public _FinalStage providers(Optional>> providers) { - this.providers = providers; - return this; - } - - /** - *

The reason for the current status of the message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage reason(Reason reason) { - this.reason = Optional.of(reason); - return this; - } - - @java.lang.Override - @JsonSetter(value = "reason", nulls = Nulls.SKIP) - public _FinalStage reason(Optional reason) { - this.reason = reason; - return this; - } - - /** - *

A message describing the error that occurred.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage error(String error) { - this.error = Optional.of(error); - return this; - } - - @java.lang.Override - @JsonSetter(value = "error", nulls = Nulls.SKIP) - public _FinalStage error(Optional error) { - this.error = error; - return this; - } - - @java.lang.Override - public MessageDetailsExtended build() { - return new MessageDetailsExtended( - id, - status, - enqueued, - sent, - delivered, - opened, - clicked, - recipient, - event, - notification, - error, - reason, - providers, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/MessageHistoryResponse.java b/src/main/java/com/courier/api/resources/messages/types/MessageHistoryResponse.java deleted file mode 100644 index 0efa96ef..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/MessageHistoryResponse.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageHistoryResponse.Builder.class) -public final class MessageHistoryResponse { - private final List> results; - - private final Map additionalProperties; - - private MessageHistoryResponse(List> results, Map additionalProperties) { - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("results") - public List> getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageHistoryResponse && equalTo((MessageHistoryResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageHistoryResponse other) { - return results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List> results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MessageHistoryResponse other) { - results(other.getResults()); - return this; - } - - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public Builder results(List> results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - public Builder addResults(Map results) { - this.results.add(results); - return this; - } - - public Builder addAllResults(List> results) { - this.results.addAll(results); - return this; - } - - public MessageHistoryResponse build() { - return new MessageHistoryResponse(results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/MessageStatus.java b/src/main/java/com/courier/api/resources/messages/types/MessageStatus.java deleted file mode 100644 index 16c4093b..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/MessageStatus.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum MessageStatus { - CANCELED("CANCELED"), - - CLICKED("CLICKED"), - - DELAYED("DELAYED"), - - DELIVERED("DELIVERED"), - - DIGESTED("DIGESTED"), - - ENQUEUED("ENQUEUED"), - - FILTERED("FILTERED"), - - OPENED("OPENED"), - - ROUTED("ROUTED"), - - SENT("SENT"), - - SIMULATED("SIMULATED"), - - THROTTLED("THROTTLED"), - - UNDELIVERABLE("UNDELIVERABLE"), - - UNMAPPED("UNMAPPED"), - - UNROUTABLE("UNROUTABLE"); - - private final String value; - - MessageStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/Reason.java b/src/main/java/com/courier/api/resources/messages/types/Reason.java deleted file mode 100644 index 54f1e526..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/Reason.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum Reason { - BOUNCED("BOUNCED"), - - FAILED("FAILED"), - - FILTERED("FILTERED"), - - NO_CHANNELS("NO_CHANNELS"), - - NO_PROVIDERS("NO_PROVIDERS"), - - OPT_IN_REQUIRED("OPT_IN_REQUIRED"), - - PROVIDER_ERROR("PROVIDER_ERROR"), - - UNPUBLISHED("UNPUBLISHED"), - - UNSUBSCRIBED("UNSUBSCRIBED"); - - private final String value; - - Reason(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/RenderOutput.java b/src/main/java/com/courier/api/resources/messages/types/RenderOutput.java deleted file mode 100644 index dae1c2e2..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/RenderOutput.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RenderOutput.Builder.class) -public final class RenderOutput { - private final String channel; - - private final String channelId; - - private final RenderedMessageContent content; - - private final Map additionalProperties; - - private RenderOutput( - String channel, - String channelId, - RenderedMessageContent content, - Map additionalProperties) { - this.channel = channel; - this.channelId = channelId; - this.content = content; - this.additionalProperties = additionalProperties; - } - - /** - * @return The channel used for rendering the message. - */ - @JsonProperty("channel") - public String getChannel() { - return channel; - } - - /** - * @return The ID of channel used for rendering the message. - */ - @JsonProperty("channel_id") - public String getChannelId() { - return channelId; - } - - /** - * @return Content details of the rendered message. - */ - @JsonProperty("content") - public RenderedMessageContent getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RenderOutput && equalTo((RenderOutput) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RenderOutput other) { - return channel.equals(other.channel) && channelId.equals(other.channelId) && content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channel, this.channelId, this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ChannelStage builder() { - return new Builder(); - } - - public interface ChannelStage { - ChannelIdStage channel(String channel); - - Builder from(RenderOutput other); - } - - public interface ChannelIdStage { - ContentStage channelId(String channelId); - } - - public interface ContentStage { - _FinalStage content(RenderedMessageContent content); - } - - public interface _FinalStage { - RenderOutput build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ChannelStage, ChannelIdStage, ContentStage, _FinalStage { - private String channel; - - private String channelId; - - private RenderedMessageContent content; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(RenderOutput other) { - channel(other.getChannel()); - channelId(other.getChannelId()); - content(other.getContent()); - return this; - } - - /** - *

The channel used for rendering the message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("channel") - public ChannelIdStage channel(String channel) { - this.channel = channel; - return this; - } - - /** - *

The ID of channel used for rendering the message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("channel_id") - public ContentStage channelId(String channelId) { - this.channelId = channelId; - return this; - } - - /** - *

Content details of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(RenderedMessageContent content) { - this.content = content; - return this; - } - - @java.lang.Override - public RenderOutput build() { - return new RenderOutput(channel, channelId, content, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/RenderOutputResponse.java b/src/main/java/com/courier/api/resources/messages/types/RenderOutputResponse.java deleted file mode 100644 index 9bcc23b0..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/RenderOutputResponse.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RenderOutputResponse.Builder.class) -public final class RenderOutputResponse { - private final List results; - - private final Map additionalProperties; - - private RenderOutputResponse(List results, Map additionalProperties) { - this.results = results; - this.additionalProperties = additionalProperties; - } - - /** - * @return An array of render output of a previously sent message. - */ - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RenderOutputResponse && equalTo((RenderOutputResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RenderOutputResponse other) { - return results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(RenderOutputResponse other) { - results(other.getResults()); - return this; - } - - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public Builder results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - public Builder addResults(RenderOutput results) { - this.results.add(results); - return this; - } - - public Builder addAllResults(List results) { - this.results.addAll(results); - return this; - } - - public RenderOutputResponse build() { - return new RenderOutputResponse(results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/RenderedMessageBlock.java b/src/main/java/com/courier/api/resources/messages/types/RenderedMessageBlock.java deleted file mode 100644 index cb26f85a..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/RenderedMessageBlock.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RenderedMessageBlock.Builder.class) -public final class RenderedMessageBlock { - private final String type; - - private final String text; - - private final Map additionalProperties; - - private RenderedMessageBlock(String type, String text, Map additionalProperties) { - this.type = type; - this.text = text; - this.additionalProperties = additionalProperties; - } - - /** - * @return The block type of the rendered message block. - */ - @JsonProperty("type") - public String getType() { - return type; - } - - /** - * @return The block text of the rendered message block. - */ - @JsonProperty("text") - public String getText() { - return text; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RenderedMessageBlock && equalTo((RenderedMessageBlock) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RenderedMessageBlock other) { - return type.equals(other.type) && text.equals(other.text); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.text); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TypeStage builder() { - return new Builder(); - } - - public interface TypeStage { - TextStage type(String type); - - Builder from(RenderedMessageBlock other); - } - - public interface TextStage { - _FinalStage text(String text); - } - - public interface _FinalStage { - RenderedMessageBlock build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TypeStage, TextStage, _FinalStage { - private String type; - - private String text; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(RenderedMessageBlock other) { - type(other.getType()); - text(other.getText()); - return this; - } - - /** - *

The block type of the rendered message block.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("type") - public TextStage type(String type) { - this.type = type; - return this; - } - - /** - *

The block text of the rendered message block.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("text") - public _FinalStage text(String text) { - this.text = text; - return this; - } - - @java.lang.Override - public RenderedMessageBlock build() { - return new RenderedMessageBlock(type, text, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/messages/types/RenderedMessageContent.java b/src/main/java/com/courier/api/resources/messages/types/RenderedMessageContent.java deleted file mode 100644 index 89af65f1..00000000 --- a/src/main/java/com/courier/api/resources/messages/types/RenderedMessageContent.java +++ /dev/null @@ -1,288 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.messages.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RenderedMessageContent.Builder.class) -public final class RenderedMessageContent { - private final String html; - - private final String title; - - private final String body; - - private final String subject; - - private final String text; - - private final List blocks; - - private final Map additionalProperties; - - private RenderedMessageContent( - String html, - String title, - String body, - String subject, - String text, - List blocks, - Map additionalProperties) { - this.html = html; - this.title = title; - this.body = body; - this.subject = subject; - this.text = text; - this.blocks = blocks; - this.additionalProperties = additionalProperties; - } - - /** - * @return The html content of the rendered message. - */ - @JsonProperty("html") - public String getHtml() { - return html; - } - - /** - * @return The title of the rendered message. - */ - @JsonProperty("title") - public String getTitle() { - return title; - } - - /** - * @return The body of the rendered message. - */ - @JsonProperty("body") - public String getBody() { - return body; - } - - /** - * @return The subject of the rendered message. - */ - @JsonProperty("subject") - public String getSubject() { - return subject; - } - - /** - * @return The text of the rendered message. - */ - @JsonProperty("text") - public String getText() { - return text; - } - - /** - * @return The blocks of the rendered message. - */ - @JsonProperty("blocks") - public List getBlocks() { - return blocks; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RenderedMessageContent && equalTo((RenderedMessageContent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RenderedMessageContent other) { - return html.equals(other.html) - && title.equals(other.title) - && body.equals(other.body) - && subject.equals(other.subject) - && text.equals(other.text) - && blocks.equals(other.blocks); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.html, this.title, this.body, this.subject, this.text, this.blocks); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static HtmlStage builder() { - return new Builder(); - } - - public interface HtmlStage { - TitleStage html(String html); - - Builder from(RenderedMessageContent other); - } - - public interface TitleStage { - BodyStage title(String title); - } - - public interface BodyStage { - SubjectStage body(String body); - } - - public interface SubjectStage { - TextStage subject(String subject); - } - - public interface TextStage { - _FinalStage text(String text); - } - - public interface _FinalStage { - RenderedMessageContent build(); - - _FinalStage blocks(List blocks); - - _FinalStage addBlocks(RenderedMessageBlock blocks); - - _FinalStage addAllBlocks(List blocks); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements HtmlStage, TitleStage, BodyStage, SubjectStage, TextStage, _FinalStage { - private String html; - - private String title; - - private String body; - - private String subject; - - private String text; - - private List blocks = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(RenderedMessageContent other) { - html(other.getHtml()); - title(other.getTitle()); - body(other.getBody()); - subject(other.getSubject()); - text(other.getText()); - blocks(other.getBlocks()); - return this; - } - - /** - *

The html content of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("html") - public TitleStage html(String html) { - this.html = html; - return this; - } - - /** - *

The title of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("title") - public BodyStage title(String title) { - this.title = title; - return this; - } - - /** - *

The body of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("body") - public SubjectStage body(String body) { - this.body = body; - return this; - } - - /** - *

The subject of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("subject") - public TextStage subject(String subject) { - this.subject = subject; - return this; - } - - /** - *

The text of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("text") - public _FinalStage text(String text) { - this.text = text; - return this; - } - - /** - *

The blocks of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllBlocks(List blocks) { - this.blocks.addAll(blocks); - return this; - } - - /** - *

The blocks of the rendered message.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addBlocks(RenderedMessageBlock blocks) { - this.blocks.add(blocks); - return this; - } - - @java.lang.Override - @JsonSetter(value = "blocks", nulls = Nulls.SKIP) - public _FinalStage blocks(List blocks) { - this.blocks.clear(); - this.blocks.addAll(blocks); - return this; - } - - @java.lang.Override - public RenderedMessageContent build() { - return new RenderedMessageContent(html, title, body, subject, text, blocks, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/NotificationsClient.java b/src/main/java/com/courier/api/resources/notifications/NotificationsClient.java deleted file mode 100644 index ebfcca12..00000000 --- a/src/main/java/com/courier/api/resources/notifications/NotificationsClient.java +++ /dev/null @@ -1,270 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.notifications.requests.NotificationListParams; -import com.courier.api.resources.notifications.requests.SubmissionChecksReplaceParams; -import com.courier.api.resources.notifications.types.NotificationGetContentResponse; -import com.courier.api.resources.notifications.types.NotificationListResponse; -import com.courier.api.resources.notifications.types.SubmissionChecksGetResponse; -import com.courier.api.resources.notifications.types.SubmissionChecksReplaceResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class NotificationsClient { - protected final ClientOptions clientOptions; - - public NotificationsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public NotificationListResponse list() { - return list(NotificationListParams.builder().build()); - } - - public NotificationListResponse list(NotificationListParams request) { - return list(request, null); - } - - public NotificationListResponse list(NotificationListParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - if (request.getNotes().isPresent()) { - httpUrl.addQueryParameter("notes", request.getNotes().get().toString()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NotificationListResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public NotificationGetContentResponse getContent(String id) { - return getContent(id, null); - } - - public NotificationGetContentResponse getContent(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications") - .addPathSegment(id) - .addPathSegments("content") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NotificationGetContentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public NotificationGetContentResponse getDraftContent(String id) { - return getDraftContent(id, null); - } - - public NotificationGetContentResponse getDraftContent(String id, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications") - .addPathSegment(id) - .addPathSegments("draft/content") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), NotificationGetContentResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public SubmissionChecksGetResponse getSubmissionChecks(String id, String submissionId) { - return getSubmissionChecks(id, submissionId, null); - } - - public SubmissionChecksGetResponse getSubmissionChecks( - String id, String submissionId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications") - .addPathSegment(id) - .addPathSegment(submissionId) - .addPathSegments("checks") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubmissionChecksGetResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public SubmissionChecksReplaceResponse replaceSubmissionChecks( - String id, String submissionId, SubmissionChecksReplaceParams request) { - return replaceSubmissionChecks(id, submissionId, request, null); - } - - public SubmissionChecksReplaceResponse replaceSubmissionChecks( - String id, String submissionId, SubmissionChecksReplaceParams request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications") - .addPathSegment(id) - .addPathSegment(submissionId) - .addPathSegments("checks") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), SubmissionChecksReplaceResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void cancelSubmission(String id, String submissionId) { - cancelSubmission(id, submissionId, null); - } - - public void cancelSubmission(String id, String submissionId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications") - .addPathSegment(id) - .addPathSegment(submissionId) - .addPathSegments("checks") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/requests/NotificationListParams.java b/src/main/java/com/courier/api/resources/notifications/requests/NotificationListParams.java deleted file mode 100644 index 3a9f12c8..00000000 --- a/src/main/java/com/courier/api/resources/notifications/requests/NotificationListParams.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationListParams.Builder.class) -public final class NotificationListParams { - private final Optional cursor; - - private final Optional notes; - - private final Map additionalProperties; - - private NotificationListParams( - Optional cursor, Optional notes, Map additionalProperties) { - this.cursor = cursor; - this.notes = notes; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return Retrieve the notes from the Notification template settings. - */ - @JsonProperty("notes") - public Optional getNotes() { - return notes; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationListParams && equalTo((NotificationListParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationListParams other) { - return cursor.equals(other.cursor) && notes.equals(other.notes); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor, this.notes); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - private Optional notes = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(NotificationListParams other) { - cursor(other.getCursor()); - notes(other.getNotes()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @JsonSetter(value = "notes", nulls = Nulls.SKIP) - public Builder notes(Optional notes) { - this.notes = notes; - return this; - } - - public Builder notes(Boolean notes) { - this.notes = Optional.of(notes); - return this; - } - - public NotificationListParams build() { - return new NotificationListParams(cursor, notes, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/requests/SubmissionChecksReplaceParams.java b/src/main/java/com/courier/api/resources/notifications/requests/SubmissionChecksReplaceParams.java deleted file mode 100644 index 8242b658..00000000 --- a/src/main/java/com/courier/api/resources/notifications/requests/SubmissionChecksReplaceParams.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.notifications.types.BaseCheck; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubmissionChecksReplaceParams.Builder.class) -public final class SubmissionChecksReplaceParams { - private final List checks; - - private final Map additionalProperties; - - private SubmissionChecksReplaceParams(List checks, Map additionalProperties) { - this.checks = checks; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("checks") - public List getChecks() { - return checks; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubmissionChecksReplaceParams && equalTo((SubmissionChecksReplaceParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubmissionChecksReplaceParams other) { - return checks.equals(other.checks); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.checks); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List checks = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubmissionChecksReplaceParams other) { - checks(other.getChecks()); - return this; - } - - @JsonSetter(value = "checks", nulls = Nulls.SKIP) - public Builder checks(List checks) { - this.checks.clear(); - this.checks.addAll(checks); - return this; - } - - public Builder addChecks(BaseCheck checks) { - this.checks.add(checks); - return this; - } - - public Builder addAllChecks(List checks) { - this.checks.addAll(checks); - return this; - } - - public SubmissionChecksReplaceParams build() { - return new SubmissionChecksReplaceParams(checks, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/BaseCheck.java b/src/main/java/com/courier/api/resources/notifications/types/BaseCheck.java deleted file mode 100644 index 3796e7a8..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/BaseCheck.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseCheck.Builder.class) -public final class BaseCheck implements IBaseCheck { - private final String id; - - private final CheckStatus status; - - private final Map additionalProperties; - - private BaseCheck(String id, CheckStatus status, Map additionalProperties) { - this.id = id; - this.status = status; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - @JsonProperty("status") - @java.lang.Override - public CheckStatus getStatus() { - return status; - } - - @JsonProperty("type") - @java.lang.Override - public String getType() { - return "custom"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseCheck && equalTo((BaseCheck) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseCheck other) { - return id.equals(other.id) && status.equals(other.status); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.status); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - StatusStage id(String id); - - Builder from(BaseCheck other); - } - - public interface StatusStage { - _FinalStage status(CheckStatus status); - } - - public interface _FinalStage { - BaseCheck build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, StatusStage, _FinalStage { - private String id; - - private CheckStatus status; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BaseCheck other) { - id(other.getId()); - status(other.getStatus()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public StatusStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(CheckStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - public BaseCheck build() { - return new BaseCheck(id, status, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/BlockType.java b/src/main/java/com/courier/api/resources/notifications/types/BlockType.java deleted file mode 100644 index d0264e88..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/BlockType.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum BlockType { - ACTION("action"), - - DIVIDER("divider"), - - IMAGE("image"), - - JSONNET("jsonnet"), - - LIST("list"), - - MARKDOWN("markdown"), - - QUOTE("quote"), - - TEMPLATE("template"), - - TEXT("text"); - - private final String value; - - BlockType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/Check.java b/src/main/java/com/courier/api/resources/notifications/types/Check.java deleted file mode 100644 index 5273639c..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/Check.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Check.Builder.class) -public final class Check implements IBaseCheck { - private final String id; - - private final CheckStatus status; - - private final long updated; - - private final Map additionalProperties; - - private Check(String id, CheckStatus status, long updated, Map additionalProperties) { - this.id = id; - this.status = status; - this.updated = updated; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - @JsonProperty("status") - @java.lang.Override - public CheckStatus getStatus() { - return status; - } - - @JsonProperty("type") - @java.lang.Override - public String getType() { - return "custom"; - } - - @JsonProperty("updated") - public long getUpdated() { - return updated; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Check && equalTo((Check) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Check other) { - return id.equals(other.id) && status.equals(other.status) && updated == other.updated; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.status, this.updated); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - StatusStage id(String id); - - Builder from(Check other); - } - - public interface StatusStage { - UpdatedStage status(CheckStatus status); - } - - public interface UpdatedStage { - _FinalStage updated(long updated); - } - - public interface _FinalStage { - Check build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, StatusStage, UpdatedStage, _FinalStage { - private String id; - - private CheckStatus status; - - private long updated; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Check other) { - id(other.getId()); - status(other.getStatus()); - updated(other.getUpdated()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public StatusStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - @JsonSetter("status") - public UpdatedStage status(CheckStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - @JsonSetter("updated") - public _FinalStage updated(long updated) { - this.updated = updated; - return this; - } - - @java.lang.Override - public Check build() { - return new Check(id, status, updated, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/CheckStatus.java b/src/main/java/com/courier/api/resources/notifications/types/CheckStatus.java deleted file mode 100644 index 9b021ce8..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/CheckStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum CheckStatus { - RESOLVED("RESOLVED"), - - FAILED("FAILED"), - - PENDING("PENDING"); - - private final String value; - - CheckStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/IBaseCheck.java b/src/main/java/com/courier/api/resources/notifications/types/IBaseCheck.java deleted file mode 100644 index cf293aea..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/IBaseCheck.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -public interface IBaseCheck { - String getId(); - - CheckStatus getStatus(); - - String getType(); -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/MessageRouting.java b/src/main/java/com/courier/api/resources/notifications/types/MessageRouting.java deleted file mode 100644 index 65f79893..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/MessageRouting.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageRouting.Builder.class) -public final class MessageRouting { - private final MessageRoutingMethod method; - - private final List channels; - - private final Map additionalProperties; - - private MessageRouting( - MessageRoutingMethod method, - List channels, - Map additionalProperties) { - this.method = method; - this.channels = channels; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("method") - public MessageRoutingMethod getMethod() { - return method; - } - - @JsonProperty("channels") - public List getChannels() { - return channels; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageRouting && equalTo((MessageRouting) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageRouting other) { - return method.equals(other.method) && channels.equals(other.channels); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.method, this.channels); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MethodStage builder() { - return new Builder(); - } - - public interface MethodStage { - _FinalStage method(MessageRoutingMethod method); - - Builder from(MessageRouting other); - } - - public interface _FinalStage { - MessageRouting build(); - - _FinalStage channels(List channels); - - _FinalStage addChannels(MessageRoutingChannel channels); - - _FinalStage addAllChannels(List channels); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MethodStage, _FinalStage { - private MessageRoutingMethod method; - - private List channels = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MessageRouting other) { - method(other.getMethod()); - channels(other.getChannels()); - return this; - } - - @java.lang.Override - @JsonSetter("method") - public _FinalStage method(MessageRoutingMethod method) { - this.method = method; - return this; - } - - @java.lang.Override - public _FinalStage addAllChannels(List channels) { - this.channels.addAll(channels); - return this; - } - - @java.lang.Override - public _FinalStage addChannels(MessageRoutingChannel channels) { - this.channels.add(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(List channels) { - this.channels.clear(); - this.channels.addAll(channels); - return this; - } - - @java.lang.Override - public MessageRouting build() { - return new MessageRouting(method, channels, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/MessageRoutingChannel.java b/src/main/java/com/courier/api/resources/notifications/types/MessageRoutingChannel.java deleted file mode 100644 index 14408004..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/MessageRoutingChannel.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MessageRoutingChannel.Deserializer.class) -public final class MessageRoutingChannel { - private final Object value; - - private final int type; - - private MessageRoutingChannel(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((MessageRouting) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageRoutingChannel && equalTo((MessageRoutingChannel) other); - } - - private boolean equalTo(MessageRoutingChannel other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MessageRoutingChannel of(String value) { - return new MessageRoutingChannel(value, 0); - } - - public static MessageRoutingChannel of(MessageRouting value) { - return new MessageRoutingChannel(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(MessageRouting value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MessageRoutingChannel.class); - } - - @java.lang.Override - public MessageRoutingChannel deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, MessageRouting.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/MessageRoutingMethod.java b/src/main/java/com/courier/api/resources/notifications/types/MessageRoutingMethod.java deleted file mode 100644 index 313ecb69..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/MessageRoutingMethod.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum MessageRoutingMethod { - ALL("all"), - - SINGLE("single"); - - private final String value; - - MessageRoutingMethod(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/Notification.java b/src/main/java/com/courier/api/resources/notifications/types/Notification.java deleted file mode 100644 index af4f427f..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/Notification.java +++ /dev/null @@ -1,288 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Notification.Builder.class) -public final class Notification { - private final long createdAt; - - private final long updatedAt; - - private final String id; - - private final MessageRouting routing; - - private final Optional tags; - - private final Optional title; - - private final String topicId; - - private final String note; - - private final Map additionalProperties; - - private Notification( - long createdAt, - long updatedAt, - String id, - MessageRouting routing, - Optional tags, - Optional title, - String topicId, - String note, - Map additionalProperties) { - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.id = id; - this.routing = routing; - this.tags = tags; - this.title = title; - this.topicId = topicId; - this.note = note; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("created_at") - public long getCreatedAt() { - return createdAt; - } - - @JsonProperty("updated_at") - public long getUpdatedAt() { - return updatedAt; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("routing") - public MessageRouting getRouting() { - return routing; - } - - @JsonProperty("tags") - public Optional getTags() { - return tags; - } - - @JsonProperty("title") - public Optional getTitle() { - return title; - } - - @JsonProperty("topic_id") - public String getTopicId() { - return topicId; - } - - @JsonProperty("note") - public String getNote() { - return note; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Notification && equalTo((Notification) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Notification other) { - return createdAt == other.createdAt - && updatedAt == other.updatedAt - && id.equals(other.id) - && routing.equals(other.routing) - && tags.equals(other.tags) - && title.equals(other.title) - && topicId.equals(other.topicId) - && note.equals(other.note); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.createdAt, this.updatedAt, this.id, this.routing, this.tags, this.title, this.topicId, this.note); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static CreatedAtStage builder() { - return new Builder(); - } - - public interface CreatedAtStage { - UpdatedAtStage createdAt(long createdAt); - - Builder from(Notification other); - } - - public interface UpdatedAtStage { - IdStage updatedAt(long updatedAt); - } - - public interface IdStage { - RoutingStage id(String id); - } - - public interface RoutingStage { - TopicIdStage routing(MessageRouting routing); - } - - public interface TopicIdStage { - NoteStage topicId(String topicId); - } - - public interface NoteStage { - _FinalStage note(String note); - } - - public interface _FinalStage { - Notification build(); - - _FinalStage tags(Optional tags); - - _FinalStage tags(NotificationTag tags); - - _FinalStage title(Optional title); - - _FinalStage title(String title); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements CreatedAtStage, UpdatedAtStage, IdStage, RoutingStage, TopicIdStage, NoteStage, _FinalStage { - private long createdAt; - - private long updatedAt; - - private String id; - - private MessageRouting routing; - - private String topicId; - - private String note; - - private Optional title = Optional.empty(); - - private Optional tags = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Notification other) { - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - id(other.getId()); - routing(other.getRouting()); - tags(other.getTags()); - title(other.getTitle()); - topicId(other.getTopicId()); - note(other.getNote()); - return this; - } - - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(long createdAt) { - this.createdAt = createdAt; - return this; - } - - @java.lang.Override - @JsonSetter("updated_at") - public IdStage updatedAt(long updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @java.lang.Override - @JsonSetter("id") - public RoutingStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - @JsonSetter("routing") - public TopicIdStage routing(MessageRouting routing) { - this.routing = routing; - return this; - } - - @java.lang.Override - @JsonSetter("topic_id") - public NoteStage topicId(String topicId) { - this.topicId = topicId; - return this; - } - - @java.lang.Override - @JsonSetter("note") - public _FinalStage note(String note) { - this.note = note; - return this; - } - - @java.lang.Override - public _FinalStage title(String title) { - this.title = Optional.of(title); - return this; - } - - @java.lang.Override - @JsonSetter(value = "title", nulls = Nulls.SKIP) - public _FinalStage title(Optional title) { - this.title = title; - return this; - } - - @java.lang.Override - public _FinalStage tags(NotificationTag tags) { - this.tags = Optional.of(tags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public _FinalStage tags(Optional tags) { - this.tags = tags; - return this; - } - - @java.lang.Override - public Notification build() { - return new Notification( - createdAt, updatedAt, id, routing, tags, title, topicId, note, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationBlock.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationBlock.java deleted file mode 100644 index 7e59b687..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationBlock.java +++ /dev/null @@ -1,279 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationBlock.Builder.class) -public final class NotificationBlock { - private final Optional alias; - - private final Optional context; - - private final String id; - - private final BlockType type; - - private final Optional content; - - private final Optional> locales; - - private final Optional checksum; - - private final Map additionalProperties; - - private NotificationBlock( - Optional alias, - Optional context, - String id, - BlockType type, - Optional content, - Optional> locales, - Optional checksum, - Map additionalProperties) { - this.alias = alias; - this.context = context; - this.id = id; - this.type = type; - this.content = content; - this.locales = locales; - this.checksum = checksum; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("alias") - public Optional getAlias() { - return alias; - } - - @JsonProperty("context") - public Optional getContext() { - return context; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("type") - public BlockType getType() { - return type; - } - - @JsonProperty("content") - public Optional getContent() { - return content; - } - - @JsonProperty("locales") - public Optional> getLocales() { - return locales; - } - - @JsonProperty("checksum") - public Optional getChecksum() { - return checksum; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationBlock && equalTo((NotificationBlock) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationBlock other) { - return alias.equals(other.alias) - && context.equals(other.context) - && id.equals(other.id) - && type.equals(other.type) - && content.equals(other.content) - && locales.equals(other.locales) - && checksum.equals(other.checksum); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.alias, this.context, this.id, this.type, this.content, this.locales, this.checksum); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - TypeStage id(String id); - - Builder from(NotificationBlock other); - } - - public interface TypeStage { - _FinalStage type(BlockType type); - } - - public interface _FinalStage { - NotificationBlock build(); - - _FinalStage alias(Optional alias); - - _FinalStage alias(String alias); - - _FinalStage context(Optional context); - - _FinalStage context(String context); - - _FinalStage content(Optional content); - - _FinalStage content(NotificationContent content); - - _FinalStage locales(Optional> locales); - - _FinalStage locales(Map locales); - - _FinalStage checksum(Optional checksum); - - _FinalStage checksum(String checksum); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, TypeStage, _FinalStage { - private String id; - - private BlockType type; - - private Optional checksum = Optional.empty(); - - private Optional> locales = Optional.empty(); - - private Optional content = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional alias = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotificationBlock other) { - alias(other.getAlias()); - context(other.getContext()); - id(other.getId()); - type(other.getType()); - content(other.getContent()); - locales(other.getLocales()); - checksum(other.getChecksum()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public TypeStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - @JsonSetter("type") - public _FinalStage type(BlockType type) { - this.type = type; - return this; - } - - @java.lang.Override - public _FinalStage checksum(String checksum) { - this.checksum = Optional.of(checksum); - return this; - } - - @java.lang.Override - @JsonSetter(value = "checksum", nulls = Nulls.SKIP) - public _FinalStage checksum(Optional checksum) { - this.checksum = checksum; - return this; - } - - @java.lang.Override - public _FinalStage locales(Map locales) { - this.locales = Optional.of(locales); - return this; - } - - @java.lang.Override - @JsonSetter(value = "locales", nulls = Nulls.SKIP) - public _FinalStage locales(Optional> locales) { - this.locales = locales; - return this; - } - - @java.lang.Override - public _FinalStage content(NotificationContent content) { - this.content = Optional.of(content); - return this; - } - - @java.lang.Override - @JsonSetter(value = "content", nulls = Nulls.SKIP) - public _FinalStage content(Optional content) { - this.content = content; - return this; - } - - @java.lang.Override - public _FinalStage context(String context) { - this.context = Optional.of(context); - return this; - } - - @java.lang.Override - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public _FinalStage context(Optional context) { - this.context = context; - return this; - } - - @java.lang.Override - public _FinalStage alias(String alias) { - this.alias = Optional.of(alias); - return this; - } - - @java.lang.Override - @JsonSetter(value = "alias", nulls = Nulls.SKIP) - public _FinalStage alias(Optional alias) { - this.alias = alias; - return this; - } - - @java.lang.Override - public NotificationBlock build() { - return new NotificationBlock(alias, context, id, type, content, locales, checksum, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationChannel.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationChannel.java deleted file mode 100644 index e0a4098e..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationChannel.java +++ /dev/null @@ -1,225 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationChannel.Builder.class) -public final class NotificationChannel { - private final String id; - - private final Optional type; - - private final Optional content; - - private final Optional> locales; - - private final Optional checksum; - - private final Map additionalProperties; - - private NotificationChannel( - String id, - Optional type, - Optional content, - Optional> locales, - Optional checksum, - Map additionalProperties) { - this.id = id; - this.type = type; - this.content = content; - this.locales = locales; - this.checksum = checksum; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("type") - public Optional getType() { - return type; - } - - @JsonProperty("content") - public Optional getContent() { - return content; - } - - @JsonProperty("locales") - public Optional> getLocales() { - return locales; - } - - @JsonProperty("checksum") - public Optional getChecksum() { - return checksum; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationChannel && equalTo((NotificationChannel) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationChannel other) { - return id.equals(other.id) - && type.equals(other.type) - && content.equals(other.content) - && locales.equals(other.locales) - && checksum.equals(other.checksum); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.type, this.content, this.locales, this.checksum); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - _FinalStage id(String id); - - Builder from(NotificationChannel other); - } - - public interface _FinalStage { - NotificationChannel build(); - - _FinalStage type(Optional type); - - _FinalStage type(String type); - - _FinalStage content(Optional content); - - _FinalStage content(NotificationChannelContent content); - - _FinalStage locales(Optional> locales); - - _FinalStage locales(Map locales); - - _FinalStage checksum(Optional checksum); - - _FinalStage checksum(String checksum); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, _FinalStage { - private String id; - - private Optional checksum = Optional.empty(); - - private Optional> locales = Optional.empty(); - - private Optional content = Optional.empty(); - - private Optional type = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotificationChannel other) { - id(other.getId()); - type(other.getType()); - content(other.getContent()); - locales(other.getLocales()); - checksum(other.getChecksum()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public _FinalStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - public _FinalStage checksum(String checksum) { - this.checksum = Optional.of(checksum); - return this; - } - - @java.lang.Override - @JsonSetter(value = "checksum", nulls = Nulls.SKIP) - public _FinalStage checksum(Optional checksum) { - this.checksum = checksum; - return this; - } - - @java.lang.Override - public _FinalStage locales(Map locales) { - this.locales = Optional.of(locales); - return this; - } - - @java.lang.Override - @JsonSetter(value = "locales", nulls = Nulls.SKIP) - public _FinalStage locales(Optional> locales) { - this.locales = locales; - return this; - } - - @java.lang.Override - public _FinalStage content(NotificationChannelContent content) { - this.content = Optional.of(content); - return this; - } - - @java.lang.Override - @JsonSetter(value = "content", nulls = Nulls.SKIP) - public _FinalStage content(Optional content) { - this.content = content; - return this; - } - - @java.lang.Override - public _FinalStage type(String type) { - this.type = Optional.of(type); - return this; - } - - @java.lang.Override - @JsonSetter(value = "type", nulls = Nulls.SKIP) - public _FinalStage type(Optional type) { - this.type = type; - return this; - } - - @java.lang.Override - public NotificationChannel build() { - return new NotificationChannel(id, type, content, locales, checksum, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationChannelContent.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationChannelContent.java deleted file mode 100644 index 43921093..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationChannelContent.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationChannelContent.Builder.class) -public final class NotificationChannelContent { - private final Optional subject; - - private final Optional title; - - private final Map additionalProperties; - - private NotificationChannelContent( - Optional subject, Optional title, Map additionalProperties) { - this.subject = subject; - this.title = title; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("subject") - public Optional getSubject() { - return subject; - } - - @JsonProperty("title") - public Optional getTitle() { - return title; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationChannelContent && equalTo((NotificationChannelContent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationChannelContent other) { - return subject.equals(other.subject) && title.equals(other.title); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.subject, this.title); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional subject = Optional.empty(); - - private Optional title = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(NotificationChannelContent other) { - subject(other.getSubject()); - title(other.getTitle()); - return this; - } - - @JsonSetter(value = "subject", nulls = Nulls.SKIP) - public Builder subject(Optional subject) { - this.subject = subject; - return this; - } - - public Builder subject(String subject) { - this.subject = Optional.of(subject); - return this; - } - - @JsonSetter(value = "title", nulls = Nulls.SKIP) - public Builder title(Optional title) { - this.title = title; - return this; - } - - public Builder title(String title) { - this.title = Optional.of(title); - return this; - } - - public NotificationChannelContent build() { - return new NotificationChannelContent(subject, title, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationContent.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationContent.java deleted file mode 100644 index fd4614eb..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationContent.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = NotificationContent.Deserializer.class) -public final class NotificationContent { - private final Object value; - - private final int type; - - private NotificationContent(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((NotificationContentHierarchy) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationContent && equalTo((NotificationContent) other); - } - - private boolean equalTo(NotificationContent other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static NotificationContent of(String value) { - return new NotificationContent(value, 0); - } - - public static NotificationContent of(NotificationContentHierarchy value) { - return new NotificationContent(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(NotificationContentHierarchy value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(NotificationContent.class); - } - - @java.lang.Override - public NotificationContent deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, NotificationContentHierarchy.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationContentHierarchy.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationContentHierarchy.java deleted file mode 100644 index b82b7963..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationContentHierarchy.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationContentHierarchy.Builder.class) -public final class NotificationContentHierarchy { - private final Optional parent; - - private final Optional children; - - private final Map additionalProperties; - - private NotificationContentHierarchy( - Optional parent, Optional children, Map additionalProperties) { - this.parent = parent; - this.children = children; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("parent") - public Optional getParent() { - return parent; - } - - @JsonProperty("children") - public Optional getChildren() { - return children; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationContentHierarchy && equalTo((NotificationContentHierarchy) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationContentHierarchy other) { - return parent.equals(other.parent) && children.equals(other.children); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.parent, this.children); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional parent = Optional.empty(); - - private Optional children = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(NotificationContentHierarchy other) { - parent(other.getParent()); - children(other.getChildren()); - return this; - } - - @JsonSetter(value = "parent", nulls = Nulls.SKIP) - public Builder parent(Optional parent) { - this.parent = parent; - return this; - } - - public Builder parent(String parent) { - this.parent = Optional.of(parent); - return this; - } - - @JsonSetter(value = "children", nulls = Nulls.SKIP) - public Builder children(Optional children) { - this.children = children; - return this; - } - - public Builder children(String children) { - this.children = Optional.of(children); - return this; - } - - public NotificationContentHierarchy build() { - return new NotificationContentHierarchy(parent, children, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationGetContentResponse.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationGetContentResponse.java deleted file mode 100644 index 1b7c61e8..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationGetContentResponse.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationGetContentResponse.Builder.class) -public final class NotificationGetContentResponse { - private final Optional> blocks; - - private final Optional> channels; - - private final Optional checksum; - - private final Map additionalProperties; - - private NotificationGetContentResponse( - Optional> blocks, - Optional> channels, - Optional checksum, - Map additionalProperties) { - this.blocks = blocks; - this.channels = channels; - this.checksum = checksum; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("blocks") - public Optional> getBlocks() { - return blocks; - } - - @JsonProperty("channels") - public Optional> getChannels() { - return channels; - } - - @JsonProperty("checksum") - public Optional getChecksum() { - return checksum; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationGetContentResponse && equalTo((NotificationGetContentResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationGetContentResponse other) { - return blocks.equals(other.blocks) && channels.equals(other.channels) && checksum.equals(other.checksum); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.blocks, this.channels, this.checksum); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> blocks = Optional.empty(); - - private Optional> channels = Optional.empty(); - - private Optional checksum = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(NotificationGetContentResponse other) { - blocks(other.getBlocks()); - channels(other.getChannels()); - checksum(other.getChecksum()); - return this; - } - - @JsonSetter(value = "blocks", nulls = Nulls.SKIP) - public Builder blocks(Optional> blocks) { - this.blocks = blocks; - return this; - } - - public Builder blocks(List blocks) { - this.blocks = Optional.of(blocks); - return this; - } - - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public Builder channels(Optional> channels) { - this.channels = channels; - return this; - } - - public Builder channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @JsonSetter(value = "checksum", nulls = Nulls.SKIP) - public Builder checksum(Optional checksum) { - this.checksum = checksum; - return this; - } - - public Builder checksum(String checksum) { - this.checksum = Optional.of(checksum); - return this; - } - - public NotificationGetContentResponse build() { - return new NotificationGetContentResponse(blocks, channels, checksum, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationListResponse.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationListResponse.java deleted file mode 100644 index 291e46d4..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationListResponse.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationListResponse.Builder.class) -public final class NotificationListResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private NotificationListResponse( - Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationListResponse && equalTo((NotificationListResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationListResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(NotificationListResponse other); - } - - public interface _FinalStage { - NotificationListResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(Notification results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotificationListResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - @java.lang.Override - public _FinalStage addResults(Notification results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public NotificationListResponse build() { - return new NotificationListResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationTag.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationTag.java deleted file mode 100644 index cf0bf0d3..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationTag.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationTag.Builder.class) -public final class NotificationTag { - private final List data; - - private final Map additionalProperties; - - private NotificationTag(List data, Map additionalProperties) { - this.data = data; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("data") - public List getData() { - return data; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationTag && equalTo((NotificationTag) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationTag other) { - return data.equals(other.data); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.data); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List data = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(NotificationTag other) { - data(other.getData()); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(List data) { - this.data.clear(); - this.data.addAll(data); - return this; - } - - public Builder addData(NotificationTagData data) { - this.data.add(data); - return this; - } - - public Builder addAllData(List data) { - this.data.addAll(data); - return this; - } - - public NotificationTag build() { - return new NotificationTag(data, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/NotificationTagData.java b/src/main/java/com/courier/api/resources/notifications/types/NotificationTagData.java deleted file mode 100644 index 6c9da961..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/NotificationTagData.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationTagData.Builder.class) -public final class NotificationTagData { - private final String id; - - private final String name; - - private final Map additionalProperties; - - private NotificationTagData(String id, String name, Map additionalProperties) { - this.id = id; - this.name = name; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationTagData && equalTo((NotificationTagData) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationTagData other) { - return id.equals(other.id) && name.equals(other.name); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.name); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - NameStage id(String id); - - Builder from(NotificationTagData other); - } - - public interface NameStage { - _FinalStage name(String name); - } - - public interface _FinalStage { - NotificationTagData build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, _FinalStage { - private String id; - - private String name; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotificationTagData other) { - id(other.getId()); - name(other.getName()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public NameStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - public NotificationTagData build() { - return new NotificationTagData(id, name, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksGetResponse.java b/src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksGetResponse.java deleted file mode 100644 index b700f33e..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksGetResponse.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubmissionChecksGetResponse.Builder.class) -public final class SubmissionChecksGetResponse { - private final List checks; - - private final Map additionalProperties; - - private SubmissionChecksGetResponse(List checks, Map additionalProperties) { - this.checks = checks; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("checks") - public List getChecks() { - return checks; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubmissionChecksGetResponse && equalTo((SubmissionChecksGetResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubmissionChecksGetResponse other) { - return checks.equals(other.checks); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.checks); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List checks = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubmissionChecksGetResponse other) { - checks(other.getChecks()); - return this; - } - - @JsonSetter(value = "checks", nulls = Nulls.SKIP) - public Builder checks(List checks) { - this.checks.clear(); - this.checks.addAll(checks); - return this; - } - - public Builder addChecks(Check checks) { - this.checks.add(checks); - return this; - } - - public Builder addAllChecks(List checks) { - this.checks.addAll(checks); - return this; - } - - public SubmissionChecksGetResponse build() { - return new SubmissionChecksGetResponse(checks, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksReplaceResponse.java b/src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksReplaceResponse.java deleted file mode 100644 index caa3a5d9..00000000 --- a/src/main/java/com/courier/api/resources/notifications/types/SubmissionChecksReplaceResponse.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.notifications.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubmissionChecksReplaceResponse.Builder.class) -public final class SubmissionChecksReplaceResponse { - private final List checks; - - private final Map additionalProperties; - - private SubmissionChecksReplaceResponse(List checks, Map additionalProperties) { - this.checks = checks; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("checks") - public List getChecks() { - return checks; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubmissionChecksReplaceResponse && equalTo((SubmissionChecksReplaceResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubmissionChecksReplaceResponse other) { - return checks.equals(other.checks); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.checks); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List checks = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubmissionChecksReplaceResponse other) { - checks(other.getChecks()); - return this; - } - - @JsonSetter(value = "checks", nulls = Nulls.SKIP) - public Builder checks(List checks) { - this.checks.clear(); - this.checks.addAll(checks); - return this; - } - - public Builder addChecks(Check checks) { - this.checks.add(checks); - return this; - } - - public Builder addAllChecks(List checks) { - this.checks.addAll(checks); - return this; - } - - public SubmissionChecksReplaceResponse build() { - return new SubmissionChecksReplaceResponse(checks, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/ProfilesClient.java b/src/main/java/com/courier/api/resources/profiles/ProfilesClient.java deleted file mode 100644 index 7dfe4370..00000000 --- a/src/main/java/com/courier/api/resources/profiles/ProfilesClient.java +++ /dev/null @@ -1,469 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.IdempotentRequestOptions; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.profiles.requests.GetListSubscriptionsRequest; -import com.courier.api.resources.profiles.requests.MergeProfileRequest; -import com.courier.api.resources.profiles.requests.ReplaceProfileRequest; -import com.courier.api.resources.profiles.types.DeleteListSubscriptionResponse; -import com.courier.api.resources.profiles.types.GetListSubscriptionsResponse; -import com.courier.api.resources.profiles.types.MergeProfileResponse; -import com.courier.api.resources.profiles.types.ProfileGetResponse; -import com.courier.api.resources.profiles.types.ProfileUpdateRequest; -import com.courier.api.resources.profiles.types.ReplaceProfileResponse; -import com.courier.api.resources.profiles.types.SubscribeToListsRequest; -import com.courier.api.resources.profiles.types.SubscribeToListsResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class ProfilesClient { - protected final ClientOptions clientOptions; - - public ProfilesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns the specified user profile. - */ - public ProfileGetResponse get(String userId) { - return get(userId, null); - } - - /** - * Returns the specified user profile. - */ - public ProfileGetResponse get(String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ProfileGetResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Merge the supplied values with an existing profile or create a new profile if one doesn't already exist. - */ - public MergeProfileResponse create(String userId, MergeProfileRequest request) { - return create(userId, request, null); - } - - /** - * Merge the supplied values with an existing profile or create a new profile if one doesn't already exist. - */ - public MergeProfileResponse create( - String userId, MergeProfileRequest request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), MergeProfileResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * When using PUT, be sure to include all the key-value pairs required by the recipient's profile. - * Any key-value pairs that exist in the profile but fail to be included in the PUT request will be - * removed from the profile. Remember, a PUT update is a full replacement of the data. For partial updates, - * use the Patch request. - */ - public ReplaceProfileResponse replace(String userId, ReplaceProfileRequest request) { - return replace(userId, request, null); - } - - /** - * When using PUT, be sure to include all the key-value pairs required by the recipient's profile. - * Any key-value pairs that exist in the profile but fail to be included in the PUT request will be - * removed from the profile. Remember, a PUT update is a full replacement of the data. For partial updates, - * use the Patch request. - */ - public ReplaceProfileResponse replace(String userId, ReplaceProfileRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ReplaceProfileResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void mergeProfile(String userId, ProfileUpdateRequest request) { - mergeProfile(userId, request, null); - } - - public void mergeProfile(String userId, ProfileUpdateRequest request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Deletes the specified user profile. - */ - public void delete(String userId) { - delete(userId, null); - } - - /** - * Deletes the specified user profile. - */ - public void delete(String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Returns the subscribed lists for a specified user. - */ - public GetListSubscriptionsResponse getListSubscriptions(String userId) { - return getListSubscriptions( - userId, GetListSubscriptionsRequest.builder().build()); - } - - /** - * Returns the subscribed lists for a specified user. - */ - public GetListSubscriptionsResponse getListSubscriptions(String userId, GetListSubscriptionsRequest request) { - return getListSubscriptions(userId, request, null); - } - - /** - * Returns the subscribed lists for a specified user. - */ - public GetListSubscriptionsResponse getListSubscriptions( - String userId, GetListSubscriptionsRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .addPathSegments("lists"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetListSubscriptionsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Subscribes the given user to one or more lists. If the list does not exist, it will be created. - */ - public SubscribeToListsResponse subscribeToLists(String userId, SubscribeToListsRequest request) { - return subscribeToLists(userId, request, null); - } - - /** - * Subscribes the given user to one or more lists. If the list does not exist, it will be created. - */ - public SubscribeToListsResponse subscribeToLists( - String userId, SubscribeToListsRequest request, IdempotentRequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .addPathSegments("lists") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("POST", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), SubscribeToListsResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Removes all list subscriptions for given user. - */ - public DeleteListSubscriptionResponse deleteListSubscription(String userId) { - return deleteListSubscription(userId, null); - } - - /** - * Removes all list subscriptions for given user. - */ - public DeleteListSubscriptionResponse deleteListSubscription(String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("profiles") - .addPathSegment(userId) - .addPathSegments("lists") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), DeleteListSubscriptionResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/requests/GetListSubscriptionsRequest.java b/src/main/java/com/courier/api/resources/profiles/requests/GetListSubscriptionsRequest.java deleted file mode 100644 index 5fcd2f64..00000000 --- a/src/main/java/com/courier/api/resources/profiles/requests/GetListSubscriptionsRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetListSubscriptionsRequest.Builder.class) -public final class GetListSubscriptionsRequest { - private final Optional cursor; - - private final Map additionalProperties; - - private GetListSubscriptionsRequest(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of message statuses. - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetListSubscriptionsRequest && equalTo((GetListSubscriptionsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetListSubscriptionsRequest other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(GetListSubscriptionsRequest other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public GetListSubscriptionsRequest build() { - return new GetListSubscriptionsRequest(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/requests/MergeProfileRequest.java b/src/main/java/com/courier/api/resources/profiles/requests/MergeProfileRequest.java deleted file mode 100644 index be9d215e..00000000 --- a/src/main/java/com/courier/api/resources/profiles/requests/MergeProfileRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MergeProfileRequest.Builder.class) -public final class MergeProfileRequest { - private final Map profile; - - private final Map additionalProperties; - - private MergeProfileRequest(Map profile, Map additionalProperties) { - this.profile = profile; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("profile") - public Map getProfile() { - return profile; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MergeProfileRequest && equalTo((MergeProfileRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MergeProfileRequest other) { - return profile.equals(other.profile); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.profile); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Map profile = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MergeProfileRequest other) { - profile(other.getProfile()); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Map profile) { - this.profile.clear(); - this.profile.putAll(profile); - return this; - } - - public Builder putAllProfile(Map profile) { - this.profile.putAll(profile); - return this; - } - - public Builder profile(String key, Object value) { - this.profile.put(key, value); - return this; - } - - public MergeProfileRequest build() { - return new MergeProfileRequest(profile, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/requests/ReplaceProfileRequest.java b/src/main/java/com/courier/api/resources/profiles/requests/ReplaceProfileRequest.java deleted file mode 100644 index 0efa2a99..00000000 --- a/src/main/java/com/courier/api/resources/profiles/requests/ReplaceProfileRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ReplaceProfileRequest.Builder.class) -public final class ReplaceProfileRequest { - private final Map profile; - - private final Map additionalProperties; - - private ReplaceProfileRequest(Map profile, Map additionalProperties) { - this.profile = profile; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("profile") - public Map getProfile() { - return profile; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ReplaceProfileRequest && equalTo((ReplaceProfileRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ReplaceProfileRequest other) { - return profile.equals(other.profile); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.profile); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Map profile = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ReplaceProfileRequest other) { - profile(other.getProfile()); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Map profile) { - this.profile.clear(); - this.profile.putAll(profile); - return this; - } - - public Builder putAllProfile(Map profile) { - this.profile.putAll(profile); - return this; - } - - public Builder profile(String key, Object value) { - this.profile.put(key, value); - return this; - } - - public ReplaceProfileRequest build() { - return new ReplaceProfileRequest(profile, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Address.java b/src/main/java/com/courier/api/resources/profiles/types/Address.java deleted file mode 100644 index 9fd2f9b0..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Address.java +++ /dev/null @@ -1,231 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Address.Builder.class) -public final class Address { - private final String formatted; - - private final String streetAddress; - - private final String locality; - - private final String region; - - private final String postalCode; - - private final String country; - - private final Map additionalProperties; - - private Address( - String formatted, - String streetAddress, - String locality, - String region, - String postalCode, - String country, - Map additionalProperties) { - this.formatted = formatted; - this.streetAddress = streetAddress; - this.locality = locality; - this.region = region; - this.postalCode = postalCode; - this.country = country; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("formatted") - public String getFormatted() { - return formatted; - } - - @JsonProperty("street_address") - public String getStreetAddress() { - return streetAddress; - } - - @JsonProperty("locality") - public String getLocality() { - return locality; - } - - @JsonProperty("region") - public String getRegion() { - return region; - } - - @JsonProperty("postal_code") - public String getPostalCode() { - return postalCode; - } - - @JsonProperty("country") - public String getCountry() { - return country; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Address && equalTo((Address) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Address other) { - return formatted.equals(other.formatted) - && streetAddress.equals(other.streetAddress) - && locality.equals(other.locality) - && region.equals(other.region) - && postalCode.equals(other.postalCode) - && country.equals(other.country); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.formatted, this.streetAddress, this.locality, this.region, this.postalCode, this.country); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static FormattedStage builder() { - return new Builder(); - } - - public interface FormattedStage { - StreetAddressStage formatted(String formatted); - - Builder from(Address other); - } - - public interface StreetAddressStage { - LocalityStage streetAddress(String streetAddress); - } - - public interface LocalityStage { - RegionStage locality(String locality); - } - - public interface RegionStage { - PostalCodeStage region(String region); - } - - public interface PostalCodeStage { - CountryStage postalCode(String postalCode); - } - - public interface CountryStage { - _FinalStage country(String country); - } - - public interface _FinalStage { - Address build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements FormattedStage, - StreetAddressStage, - LocalityStage, - RegionStage, - PostalCodeStage, - CountryStage, - _FinalStage { - private String formatted; - - private String streetAddress; - - private String locality; - - private String region; - - private String postalCode; - - private String country; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Address other) { - formatted(other.getFormatted()); - streetAddress(other.getStreetAddress()); - locality(other.getLocality()); - region(other.getRegion()); - postalCode(other.getPostalCode()); - country(other.getCountry()); - return this; - } - - @java.lang.Override - @JsonSetter("formatted") - public StreetAddressStage formatted(String formatted) { - this.formatted = formatted; - return this; - } - - @java.lang.Override - @JsonSetter("street_address") - public LocalityStage streetAddress(String streetAddress) { - this.streetAddress = streetAddress; - return this; - } - - @java.lang.Override - @JsonSetter("locality") - public RegionStage locality(String locality) { - this.locality = locality; - return this; - } - - @java.lang.Override - @JsonSetter("region") - public PostalCodeStage region(String region) { - this.region = region; - return this; - } - - @java.lang.Override - @JsonSetter("postal_code") - public CountryStage postalCode(String postalCode) { - this.postalCode = postalCode; - return this; - } - - @java.lang.Override - @JsonSetter("country") - public _FinalStage country(String country) { - this.country = country; - return this; - } - - @java.lang.Override - public Address build() { - return new Address(formatted, streetAddress, locality, region, postalCode, country, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/AirshipProfile.java b/src/main/java/com/courier/api/resources/profiles/types/AirshipProfile.java deleted file mode 100644 index 34fbab69..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/AirshipProfile.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AirshipProfile.Builder.class) -public final class AirshipProfile { - private final AirshipProfileAudience audience; - - private final List deviceTypes; - - private final Map additionalProperties; - - private AirshipProfile( - AirshipProfileAudience audience, List deviceTypes, Map additionalProperties) { - this.audience = audience; - this.deviceTypes = deviceTypes; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("audience") - public AirshipProfileAudience getAudience() { - return audience; - } - - @JsonProperty("device_types") - public List getDeviceTypes() { - return deviceTypes; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AirshipProfile && equalTo((AirshipProfile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AirshipProfile other) { - return audience.equals(other.audience) && deviceTypes.equals(other.deviceTypes); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.audience, this.deviceTypes); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AudienceStage builder() { - return new Builder(); - } - - public interface AudienceStage { - _FinalStage audience(AirshipProfileAudience audience); - - Builder from(AirshipProfile other); - } - - public interface _FinalStage { - AirshipProfile build(); - - _FinalStage deviceTypes(List deviceTypes); - - _FinalStage addDeviceTypes(Object deviceTypes); - - _FinalStage addAllDeviceTypes(List deviceTypes); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AudienceStage, _FinalStage { - private AirshipProfileAudience audience; - - private List deviceTypes = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AirshipProfile other) { - audience(other.getAudience()); - deviceTypes(other.getDeviceTypes()); - return this; - } - - @java.lang.Override - @JsonSetter("audience") - public _FinalStage audience(AirshipProfileAudience audience) { - this.audience = audience; - return this; - } - - @java.lang.Override - public _FinalStage addAllDeviceTypes(List deviceTypes) { - this.deviceTypes.addAll(deviceTypes); - return this; - } - - @java.lang.Override - public _FinalStage addDeviceTypes(Object deviceTypes) { - this.deviceTypes.add(deviceTypes); - return this; - } - - @java.lang.Override - @JsonSetter(value = "device_types", nulls = Nulls.SKIP) - public _FinalStage deviceTypes(List deviceTypes) { - this.deviceTypes.clear(); - this.deviceTypes.addAll(deviceTypes); - return this; - } - - @java.lang.Override - public AirshipProfile build() { - return new AirshipProfile(audience, deviceTypes, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/AirshipProfileAudience.java b/src/main/java/com/courier/api/resources/profiles/types/AirshipProfileAudience.java deleted file mode 100644 index 50b52031..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/AirshipProfileAudience.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AirshipProfileAudience.Builder.class) -public final class AirshipProfileAudience { - private final String namedUser; - - private final Map additionalProperties; - - private AirshipProfileAudience(String namedUser, Map additionalProperties) { - this.namedUser = namedUser; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("named_user") - public String getNamedUser() { - return namedUser; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AirshipProfileAudience && equalTo((AirshipProfileAudience) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AirshipProfileAudience other) { - return namedUser.equals(other.namedUser); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.namedUser); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NamedUserStage builder() { - return new Builder(); - } - - public interface NamedUserStage { - _FinalStage namedUser(String namedUser); - - Builder from(AirshipProfileAudience other); - } - - public interface _FinalStage { - AirshipProfileAudience build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NamedUserStage, _FinalStage { - private String namedUser; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AirshipProfileAudience other) { - namedUser(other.getNamedUser()); - return this; - } - - @java.lang.Override - @JsonSetter("named_user") - public _FinalStage namedUser(String namedUser) { - this.namedUser = namedUser; - return this; - } - - @java.lang.Override - public AirshipProfileAudience build() { - return new AirshipProfileAudience(namedUser, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/DeleteListSubscriptionResponse.java b/src/main/java/com/courier/api/resources/profiles/types/DeleteListSubscriptionResponse.java deleted file mode 100644 index 2ea5c990..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/DeleteListSubscriptionResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DeleteListSubscriptionResponse.Builder.class) -public final class DeleteListSubscriptionResponse { - private final Map additionalProperties; - - private DeleteListSubscriptionResponse(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public String getStatus() { - return "SUCCESS"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeleteListSubscriptionResponse; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DeleteListSubscriptionResponse other) { - return this; - } - - public DeleteListSubscriptionResponse build() { - return new DeleteListSubscriptionResponse(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Discord.java b/src/main/java/com/courier/api/resources/profiles/types/Discord.java deleted file mode 100644 index 0d1ac1f2..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Discord.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Discord.Deserializer.class) -public final class Discord { - private final Object value; - - private final int type; - - private Discord(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SendToChannel) this.value); - } else if (this.type == 1) { - return visitor.visit((SendDirectMessage) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Discord && equalTo((Discord) other); - } - - private boolean equalTo(Discord other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Discord of(SendToChannel value) { - return new Discord(value, 0); - } - - public static Discord of(SendDirectMessage value) { - return new Discord(value, 1); - } - - public interface Visitor { - T visit(SendToChannel value); - - T visit(SendDirectMessage value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Discord.class); - } - - @java.lang.Override - public Discord deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToChannel.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendDirectMessage.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Expo.java b/src/main/java/com/courier/api/resources/profiles/types/Expo.java deleted file mode 100644 index dc78f72b..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Expo.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Expo.Deserializer.class) -public final class Expo { - private final Object value; - - private final int type; - - private Expo(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Token) this.value); - } else if (this.type == 1) { - return visitor.visit((MultipleTokens) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Expo && equalTo((Expo) other); - } - - private boolean equalTo(Expo other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Expo of(Token value) { - return new Expo(value, 0); - } - - public static Expo of(MultipleTokens value) { - return new Expo(value, 1); - } - - public interface Visitor { - T visit(Token value); - - T visit(MultipleTokens value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Expo.class); - } - - @java.lang.Override - public Expo deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Token.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, MultipleTokens.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsList.java b/src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsList.java deleted file mode 100644 index ec99ec17..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsList.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetListSubscriptionsList.Builder.class) -public final class GetListSubscriptionsList { - private final String id; - - private final String name; - - private final String created; - - private final String updated; - - private final Optional preferences; - - private final Map additionalProperties; - - private GetListSubscriptionsList( - String id, - String name, - String created, - String updated, - Optional preferences, - Map additionalProperties) { - this.id = id; - this.name = name; - this.created = created; - this.updated = updated; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * @return List name - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return The date/time of when the list was created. Represented as a string in ISO format. - */ - @JsonProperty("created") - public String getCreated() { - return created; - } - - /** - * @return The date/time of when the list was updated. Represented as a string in ISO format. - */ - @JsonProperty("updated") - public String getUpdated() { - return updated; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetListSubscriptionsList && equalTo((GetListSubscriptionsList) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetListSubscriptionsList other) { - return id.equals(other.id) - && name.equals(other.name) - && created.equals(other.created) - && updated.equals(other.updated) - && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.name, this.created, this.updated, this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - NameStage id(String id); - - Builder from(GetListSubscriptionsList other); - } - - public interface NameStage { - CreatedStage name(String name); - } - - public interface CreatedStage { - UpdatedStage created(String created); - } - - public interface UpdatedStage { - _FinalStage updated(String updated); - } - - public interface _FinalStage { - GetListSubscriptionsList build(); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(RecipientPreferences preferences); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, CreatedStage, UpdatedStage, _FinalStage { - private String id; - - private String name; - - private String created; - - private String updated; - - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetListSubscriptionsList other) { - id(other.getId()); - name(other.getName()); - created(other.getCreated()); - updated(other.getUpdated()); - preferences(other.getPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public NameStage id(String id) { - this.id = id; - return this; - } - - /** - *

List name

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public CreatedStage name(String name) { - this.name = name; - return this; - } - - /** - *

The date/time of when the list was created. Represented as a string in ISO format.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created") - public UpdatedStage created(String created) { - this.created = created; - return this; - } - - /** - *

The date/time of when the list was updated. Represented as a string in ISO format.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated") - public _FinalStage updated(String updated) { - this.updated = updated; - return this; - } - - @java.lang.Override - public _FinalStage preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public GetListSubscriptionsList build() { - return new GetListSubscriptionsList(id, name, created, updated, preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsResponse.java b/src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsResponse.java deleted file mode 100644 index 60dbf9ad..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/GetListSubscriptionsResponse.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetListSubscriptionsResponse.Builder.class) -public final class GetListSubscriptionsResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private GetListSubscriptionsResponse( - Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - /** - * @return An array of lists - */ - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetListSubscriptionsResponse && equalTo((GetListSubscriptionsResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetListSubscriptionsResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(GetListSubscriptionsResponse other); - } - - public interface _FinalStage { - GetListSubscriptionsResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(GetListSubscriptionsList results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetListSubscriptionsResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - /** - *

An array of lists

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - /** - *

An array of lists

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addResults(GetListSubscriptionsList results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public GetListSubscriptionsResponse build() { - return new GetListSubscriptionsResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/IMsTeamsBaseProperties.java b/src/main/java/com/courier/api/resources/profiles/types/IMsTeamsBaseProperties.java deleted file mode 100644 index d47dcf27..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/IMsTeamsBaseProperties.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -public interface IMsTeamsBaseProperties { - String getTenantId(); - - String getServiceUrl(); -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/ISlackBaseProperties.java b/src/main/java/com/courier/api/resources/profiles/types/ISlackBaseProperties.java deleted file mode 100644 index fccb6eca..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/ISlackBaseProperties.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -public interface ISlackBaseProperties { - String getAccessToken(); -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Intercom.java b/src/main/java/com/courier/api/resources/profiles/types/Intercom.java deleted file mode 100644 index cf9f6400..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Intercom.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Intercom.Builder.class) -public final class Intercom { - private final String from; - - private final IntercomRecipient to; - - private final Map additionalProperties; - - private Intercom(String from, IntercomRecipient to, Map additionalProperties) { - this.from = from; - this.to = to; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("from") - public String getFrom() { - return from; - } - - @JsonProperty("to") - public IntercomRecipient getTo() { - return to; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Intercom && equalTo((Intercom) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Intercom other) { - return from.equals(other.from) && to.equals(other.to); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.from, this.to); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static FromStage builder() { - return new Builder(); - } - - public interface FromStage { - ToStage from(String from); - - Builder from(Intercom other); - } - - public interface ToStage { - _FinalStage to(IntercomRecipient to); - } - - public interface _FinalStage { - Intercom build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements FromStage, ToStage, _FinalStage { - private String from; - - private IntercomRecipient to; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Intercom other) { - from(other.getFrom()); - to(other.getTo()); - return this; - } - - @java.lang.Override - @JsonSetter("from") - public ToStage from(String from) { - this.from = from; - return this; - } - - @java.lang.Override - @JsonSetter("to") - public _FinalStage to(IntercomRecipient to) { - this.to = to; - return this; - } - - @java.lang.Override - public Intercom build() { - return new Intercom(from, to, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/IntercomRecipient.java b/src/main/java/com/courier/api/resources/profiles/types/IntercomRecipient.java deleted file mode 100644 index 6b45fd0c..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/IntercomRecipient.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = IntercomRecipient.Builder.class) -public final class IntercomRecipient { - private final String id; - - private final Map additionalProperties; - - private IntercomRecipient(String id, Map additionalProperties) { - this.id = id; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("id") - public String getId() { - return id; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IntercomRecipient && equalTo((IntercomRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(IntercomRecipient other) { - return id.equals(other.id); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - _FinalStage id(String id); - - Builder from(IntercomRecipient other); - } - - public interface _FinalStage { - IntercomRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, _FinalStage { - private String id; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(IntercomRecipient other) { - id(other.getId()); - return this; - } - - @java.lang.Override - @JsonSetter("id") - public _FinalStage id(String id) { - this.id = id; - return this; - } - - @java.lang.Override - public IntercomRecipient build() { - return new IntercomRecipient(id, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/MergeProfileResponse.java b/src/main/java/com/courier/api/resources/profiles/types/MergeProfileResponse.java deleted file mode 100644 index 5e23ffa1..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/MergeProfileResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MergeProfileResponse.Builder.class) -public final class MergeProfileResponse { - private final Map additionalProperties; - - private MergeProfileResponse(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public String getStatus() { - return "SUCCESS"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MergeProfileResponse; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MergeProfileResponse other) { - return this; - } - - public MergeProfileResponse build() { - return new MergeProfileResponse(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/MsTeams.java b/src/main/java/com/courier/api/resources/profiles/types/MsTeams.java deleted file mode 100644 index e9e6144a..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/MsTeams.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = MsTeams.Deserializer.class) -public final class MsTeams { - private final Object value; - - private final int type; - - private MsTeams(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SendToMsTeamsUserId) this.value); - } else if (this.type == 1) { - return visitor.visit((SendToMsTeamsEmail) this.value); - } else if (this.type == 2) { - return visitor.visit((SendToMsTeamsChannelId) this.value); - } else if (this.type == 3) { - return visitor.visit((SendToMsTeamsConversationId) this.value); - } else if (this.type == 4) { - return visitor.visit((SendToMsTeamsChannelName) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MsTeams && equalTo((MsTeams) other); - } - - private boolean equalTo(MsTeams other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MsTeams of(SendToMsTeamsUserId value) { - return new MsTeams(value, 0); - } - - public static MsTeams of(SendToMsTeamsEmail value) { - return new MsTeams(value, 1); - } - - public static MsTeams of(SendToMsTeamsChannelId value) { - return new MsTeams(value, 2); - } - - public static MsTeams of(SendToMsTeamsConversationId value) { - return new MsTeams(value, 3); - } - - public static MsTeams of(SendToMsTeamsChannelName value) { - return new MsTeams(value, 4); - } - - public interface Visitor { - T visit(SendToMsTeamsUserId value); - - T visit(SendToMsTeamsEmail value); - - T visit(SendToMsTeamsChannelId value); - - T visit(SendToMsTeamsConversationId value); - - T visit(SendToMsTeamsChannelName value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MsTeams.class); - } - - @java.lang.Override - public MsTeams deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToMsTeamsUserId.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToMsTeamsEmail.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToMsTeamsChannelId.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToMsTeamsConversationId.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToMsTeamsChannelName.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/MsTeamsBaseProperties.java b/src/main/java/com/courier/api/resources/profiles/types/MsTeamsBaseProperties.java deleted file mode 100644 index 4d77bef7..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/MsTeamsBaseProperties.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MsTeamsBaseProperties.Builder.class) -public final class MsTeamsBaseProperties implements IMsTeamsBaseProperties { - private final String tenantId; - - private final String serviceUrl; - - private final Map additionalProperties; - - private MsTeamsBaseProperties(String tenantId, String serviceUrl, Map additionalProperties) { - this.tenantId = tenantId; - this.serviceUrl = serviceUrl; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenant_id") - @java.lang.Override - public String getTenantId() { - return tenantId; - } - - @JsonProperty("service_url") - @java.lang.Override - public String getServiceUrl() { - return serviceUrl; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MsTeamsBaseProperties && equalTo((MsTeamsBaseProperties) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MsTeamsBaseProperties other) { - return tenantId.equals(other.tenantId) && serviceUrl.equals(other.serviceUrl); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.serviceUrl); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - ServiceUrlStage tenantId(String tenantId); - - Builder from(MsTeamsBaseProperties other); - } - - public interface ServiceUrlStage { - _FinalStage serviceUrl(String serviceUrl); - } - - public interface _FinalStage { - MsTeamsBaseProperties build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TenantIdStage, ServiceUrlStage, _FinalStage { - private String tenantId; - - private String serviceUrl; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MsTeamsBaseProperties other) { - tenantId(other.getTenantId()); - serviceUrl(other.getServiceUrl()); - return this; - } - - @java.lang.Override - @JsonSetter("tenant_id") - public ServiceUrlStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - @JsonSetter("service_url") - public _FinalStage serviceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - @java.lang.Override - public MsTeamsBaseProperties build() { - return new MsTeamsBaseProperties(tenantId, serviceUrl, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/MultipleTokens.java b/src/main/java/com/courier/api/resources/profiles/types/MultipleTokens.java deleted file mode 100644 index 667c31a2..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/MultipleTokens.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MultipleTokens.Builder.class) -public final class MultipleTokens { - private final List tokens; - - private final Map additionalProperties; - - private MultipleTokens(List tokens, Map additionalProperties) { - this.tokens = tokens; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tokens") - public List getTokens() { - return tokens; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MultipleTokens && equalTo((MultipleTokens) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MultipleTokens other) { - return tokens.equals(other.tokens); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tokens); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List tokens = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MultipleTokens other) { - tokens(other.getTokens()); - return this; - } - - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public Builder tokens(List tokens) { - this.tokens.clear(); - this.tokens.addAll(tokens); - return this; - } - - public Builder addTokens(Token tokens) { - this.tokens.add(tokens); - return this; - } - - public Builder addAllTokens(List tokens) { - this.tokens.addAll(tokens); - return this; - } - - public MultipleTokens build() { - return new MultipleTokens(tokens, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Pagerduty.java b/src/main/java/com/courier/api/resources/profiles/types/Pagerduty.java deleted file mode 100644 index aa9ef524..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Pagerduty.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Pagerduty.Builder.class) -public final class Pagerduty { - private final Optional routingKey; - - private final Optional eventAction; - - private final Optional severity; - - private final Optional source; - - private final Map additionalProperties; - - private Pagerduty( - Optional routingKey, - Optional eventAction, - Optional severity, - Optional source, - Map additionalProperties) { - this.routingKey = routingKey; - this.eventAction = eventAction; - this.severity = severity; - this.source = source; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("routing_key") - public Optional getRoutingKey() { - return routingKey; - } - - @JsonProperty("event_action") - public Optional getEventAction() { - return eventAction; - } - - @JsonProperty("severity") - public Optional getSeverity() { - return severity; - } - - @JsonProperty("source") - public Optional getSource() { - return source; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Pagerduty && equalTo((Pagerduty) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Pagerduty other) { - return routingKey.equals(other.routingKey) - && eventAction.equals(other.eventAction) - && severity.equals(other.severity) - && source.equals(other.source); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.routingKey, this.eventAction, this.severity, this.source); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional routingKey = Optional.empty(); - - private Optional eventAction = Optional.empty(); - - private Optional severity = Optional.empty(); - - private Optional source = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Pagerduty other) { - routingKey(other.getRoutingKey()); - eventAction(other.getEventAction()); - severity(other.getSeverity()); - source(other.getSource()); - return this; - } - - @JsonSetter(value = "routing_key", nulls = Nulls.SKIP) - public Builder routingKey(Optional routingKey) { - this.routingKey = routingKey; - return this; - } - - public Builder routingKey(String routingKey) { - this.routingKey = Optional.of(routingKey); - return this; - } - - @JsonSetter(value = "event_action", nulls = Nulls.SKIP) - public Builder eventAction(Optional eventAction) { - this.eventAction = eventAction; - return this; - } - - public Builder eventAction(String eventAction) { - this.eventAction = Optional.of(eventAction); - return this; - } - - @JsonSetter(value = "severity", nulls = Nulls.SKIP) - public Builder severity(Optional severity) { - this.severity = severity; - return this; - } - - public Builder severity(String severity) { - this.severity = Optional.of(severity); - return this; - } - - @JsonSetter(value = "source", nulls = Nulls.SKIP) - public Builder source(Optional source) { - this.source = source; - return this; - } - - public Builder source(String source) { - this.source = Optional.of(source); - return this; - } - - public Pagerduty build() { - return new Pagerduty(routingKey, eventAction, severity, source, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/ProfileGetParameters.java b/src/main/java/com/courier/api/resources/profiles/types/ProfileGetParameters.java deleted file mode 100644 index 3e4f6e34..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/ProfileGetParameters.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ProfileGetParameters.Builder.class) -public final class ProfileGetParameters { - private final String recipientId; - - private final Map additionalProperties; - - private ProfileGetParameters(String recipientId, Map additionalProperties) { - this.recipientId = recipientId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("recipientId") - public String getRecipientId() { - return recipientId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProfileGetParameters && equalTo((ProfileGetParameters) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProfileGetParameters other) { - return recipientId.equals(other.recipientId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.recipientId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RecipientIdStage builder() { - return new Builder(); - } - - public interface RecipientIdStage { - _FinalStage recipientId(String recipientId); - - Builder from(ProfileGetParameters other); - } - - public interface _FinalStage { - ProfileGetParameters build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RecipientIdStage, _FinalStage { - private String recipientId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ProfileGetParameters other) { - recipientId(other.getRecipientId()); - return this; - } - - @java.lang.Override - @JsonSetter("recipientId") - public _FinalStage recipientId(String recipientId) { - this.recipientId = recipientId; - return this; - } - - @java.lang.Override - public ProfileGetParameters build() { - return new ProfileGetParameters(recipientId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/ProfileGetResponse.java b/src/main/java/com/courier/api/resources/profiles/types/ProfileGetResponse.java deleted file mode 100644 index 352ca0ee..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/ProfileGetResponse.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ProfileGetResponse.Builder.class) -public final class ProfileGetResponse { - private final Map profile; - - private final Optional preferences; - - private final Map additionalProperties; - - private ProfileGetResponse( - Map profile, - Optional preferences, - Map additionalProperties) { - this.profile = profile; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("profile") - public Map getProfile() { - return profile; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProfileGetResponse && equalTo((ProfileGetResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProfileGetResponse other) { - return profile.equals(other.profile) && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.profile, this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Map profile = new LinkedHashMap<>(); - - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ProfileGetResponse other) { - profile(other.getProfile()); - preferences(other.getPreferences()); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Map profile) { - this.profile.clear(); - this.profile.putAll(profile); - return this; - } - - public Builder putAllProfile(Map profile) { - this.profile.putAll(profile); - return this; - } - - public Builder profile(String key, Object value) { - this.profile.put(key, value); - return this; - } - - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public Builder preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - public Builder preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - public ProfileGetResponse build() { - return new ProfileGetResponse(profile, preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/ProfileUpdateRequest.java b/src/main/java/com/courier/api/resources/profiles/types/ProfileUpdateRequest.java deleted file mode 100644 index a24faafb..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/ProfileUpdateRequest.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ProfileUpdateRequest.Builder.class) -public final class ProfileUpdateRequest { - private final List patch; - - private final Map additionalProperties; - - private ProfileUpdateRequest(List patch, Map additionalProperties) { - this.patch = patch; - this.additionalProperties = additionalProperties; - } - - /** - * @return List of patch operations to apply to the profile. - */ - @JsonProperty("patch") - public List getPatch() { - return patch; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ProfileUpdateRequest && equalTo((ProfileUpdateRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ProfileUpdateRequest other) { - return patch.equals(other.patch); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.patch); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List patch = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ProfileUpdateRequest other) { - patch(other.getPatch()); - return this; - } - - @JsonSetter(value = "patch", nulls = Nulls.SKIP) - public Builder patch(List patch) { - this.patch.clear(); - this.patch.addAll(patch); - return this; - } - - public Builder addPatch(UserProfilePatch patch) { - this.patch.add(patch); - return this; - } - - public Builder addAllPatch(List patch) { - this.patch.addAll(patch); - return this; - } - - public ProfileUpdateRequest build() { - return new ProfileUpdateRequest(patch, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/ReplaceProfileResponse.java b/src/main/java/com/courier/api/resources/profiles/types/ReplaceProfileResponse.java deleted file mode 100644 index 23772b11..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/ReplaceProfileResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ReplaceProfileResponse.Builder.class) -public final class ReplaceProfileResponse { - private final Map additionalProperties; - - private ReplaceProfileResponse(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public String getStatus() { - return "SUCCESS"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ReplaceProfileResponse; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ReplaceProfileResponse other) { - return this; - } - - public ReplaceProfileResponse build() { - return new ReplaceProfileResponse(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendDirectMessage.java b/src/main/java/com/courier/api/resources/profiles/types/SendDirectMessage.java deleted file mode 100644 index f9d4688b..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendDirectMessage.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendDirectMessage.Builder.class) -public final class SendDirectMessage { - private final String userId; - - private final Map additionalProperties; - - private SendDirectMessage(String userId, Map additionalProperties) { - this.userId = userId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendDirectMessage && equalTo((SendDirectMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendDirectMessage other) { - return userId.equals(other.userId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(SendDirectMessage other); - } - - public interface _FinalStage { - SendDirectMessage build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendDirectMessage other) { - userId(other.getUserId()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public SendDirectMessage build() { - return new SendDirectMessage(userId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToChannel.java b/src/main/java/com/courier/api/resources/profiles/types/SendToChannel.java deleted file mode 100644 index 2c93c13a..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToChannel.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToChannel.Builder.class) -public final class SendToChannel { - private final String channelId; - - private final Map additionalProperties; - - private SendToChannel(String channelId, Map additionalProperties) { - this.channelId = channelId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channel_id") - public String getChannelId() { - return channelId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToChannel && equalTo((SendToChannel) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToChannel other) { - return channelId.equals(other.channelId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channelId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ChannelIdStage builder() { - return new Builder(); - } - - public interface ChannelIdStage { - _FinalStage channelId(String channelId); - - Builder from(SendToChannel other); - } - - public interface _FinalStage { - SendToChannel build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ChannelIdStage, _FinalStage { - private String channelId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToChannel other) { - channelId(other.getChannelId()); - return this; - } - - @java.lang.Override - @JsonSetter("channel_id") - public _FinalStage channelId(String channelId) { - this.channelId = channelId; - return this; - } - - @java.lang.Override - public SendToChannel build() { - return new SendToChannel(channelId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelId.java b/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelId.java deleted file mode 100644 index 07aabbd9..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelId.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToMsTeamsChannelId.Builder.class) -public final class SendToMsTeamsChannelId implements IMsTeamsBaseProperties { - private final String tenantId; - - private final String serviceUrl; - - private final String channelId; - - private final Map additionalProperties; - - private SendToMsTeamsChannelId( - String tenantId, String serviceUrl, String channelId, Map additionalProperties) { - this.tenantId = tenantId; - this.serviceUrl = serviceUrl; - this.channelId = channelId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenant_id") - @java.lang.Override - public String getTenantId() { - return tenantId; - } - - @JsonProperty("service_url") - @java.lang.Override - public String getServiceUrl() { - return serviceUrl; - } - - @JsonProperty("channel_id") - public String getChannelId() { - return channelId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToMsTeamsChannelId && equalTo((SendToMsTeamsChannelId) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToMsTeamsChannelId other) { - return tenantId.equals(other.tenantId) - && serviceUrl.equals(other.serviceUrl) - && channelId.equals(other.channelId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.serviceUrl, this.channelId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - ServiceUrlStage tenantId(String tenantId); - - Builder from(SendToMsTeamsChannelId other); - } - - public interface ServiceUrlStage { - ChannelIdStage serviceUrl(String serviceUrl); - } - - public interface ChannelIdStage { - _FinalStage channelId(String channelId); - } - - public interface _FinalStage { - SendToMsTeamsChannelId build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TenantIdStage, ServiceUrlStage, ChannelIdStage, _FinalStage { - private String tenantId; - - private String serviceUrl; - - private String channelId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToMsTeamsChannelId other) { - tenantId(other.getTenantId()); - serviceUrl(other.getServiceUrl()); - channelId(other.getChannelId()); - return this; - } - - @java.lang.Override - @JsonSetter("tenant_id") - public ServiceUrlStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - @JsonSetter("service_url") - public ChannelIdStage serviceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - @java.lang.Override - @JsonSetter("channel_id") - public _FinalStage channelId(String channelId) { - this.channelId = channelId; - return this; - } - - @java.lang.Override - public SendToMsTeamsChannelId build() { - return new SendToMsTeamsChannelId(tenantId, serviceUrl, channelId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelName.java b/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelName.java deleted file mode 100644 index bc450eff..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsChannelName.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToMsTeamsChannelName.Builder.class) -public final class SendToMsTeamsChannelName implements IMsTeamsBaseProperties { - private final String tenantId; - - private final String serviceUrl; - - private final String channelName; - - private final String teamId; - - private final Map additionalProperties; - - private SendToMsTeamsChannelName( - String tenantId, - String serviceUrl, - String channelName, - String teamId, - Map additionalProperties) { - this.tenantId = tenantId; - this.serviceUrl = serviceUrl; - this.channelName = channelName; - this.teamId = teamId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenant_id") - @java.lang.Override - public String getTenantId() { - return tenantId; - } - - @JsonProperty("service_url") - @java.lang.Override - public String getServiceUrl() { - return serviceUrl; - } - - @JsonProperty("channel_name") - public String getChannelName() { - return channelName; - } - - @JsonProperty("team_id") - public String getTeamId() { - return teamId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToMsTeamsChannelName && equalTo((SendToMsTeamsChannelName) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToMsTeamsChannelName other) { - return tenantId.equals(other.tenantId) - && serviceUrl.equals(other.serviceUrl) - && channelName.equals(other.channelName) - && teamId.equals(other.teamId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.serviceUrl, this.channelName, this.teamId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - ServiceUrlStage tenantId(String tenantId); - - Builder from(SendToMsTeamsChannelName other); - } - - public interface ServiceUrlStage { - ChannelNameStage serviceUrl(String serviceUrl); - } - - public interface ChannelNameStage { - TeamIdStage channelName(String channelName); - } - - public interface TeamIdStage { - _FinalStage teamId(String teamId); - } - - public interface _FinalStage { - SendToMsTeamsChannelName build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements TenantIdStage, ServiceUrlStage, ChannelNameStage, TeamIdStage, _FinalStage { - private String tenantId; - - private String serviceUrl; - - private String channelName; - - private String teamId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToMsTeamsChannelName other) { - tenantId(other.getTenantId()); - serviceUrl(other.getServiceUrl()); - channelName(other.getChannelName()); - teamId(other.getTeamId()); - return this; - } - - @java.lang.Override - @JsonSetter("tenant_id") - public ServiceUrlStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - @JsonSetter("service_url") - public ChannelNameStage serviceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - @java.lang.Override - @JsonSetter("channel_name") - public TeamIdStage channelName(String channelName) { - this.channelName = channelName; - return this; - } - - @java.lang.Override - @JsonSetter("team_id") - public _FinalStage teamId(String teamId) { - this.teamId = teamId; - return this; - } - - @java.lang.Override - public SendToMsTeamsChannelName build() { - return new SendToMsTeamsChannelName(tenantId, serviceUrl, channelName, teamId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsConversationId.java b/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsConversationId.java deleted file mode 100644 index da57cde7..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsConversationId.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToMsTeamsConversationId.Builder.class) -public final class SendToMsTeamsConversationId implements IMsTeamsBaseProperties { - private final String tenantId; - - private final String serviceUrl; - - private final String conversationId; - - private final Map additionalProperties; - - private SendToMsTeamsConversationId( - String tenantId, String serviceUrl, String conversationId, Map additionalProperties) { - this.tenantId = tenantId; - this.serviceUrl = serviceUrl; - this.conversationId = conversationId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenant_id") - @java.lang.Override - public String getTenantId() { - return tenantId; - } - - @JsonProperty("service_url") - @java.lang.Override - public String getServiceUrl() { - return serviceUrl; - } - - @JsonProperty("conversation_id") - public String getConversationId() { - return conversationId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToMsTeamsConversationId && equalTo((SendToMsTeamsConversationId) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToMsTeamsConversationId other) { - return tenantId.equals(other.tenantId) - && serviceUrl.equals(other.serviceUrl) - && conversationId.equals(other.conversationId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.serviceUrl, this.conversationId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - ServiceUrlStage tenantId(String tenantId); - - Builder from(SendToMsTeamsConversationId other); - } - - public interface ServiceUrlStage { - ConversationIdStage serviceUrl(String serviceUrl); - } - - public interface ConversationIdStage { - _FinalStage conversationId(String conversationId); - } - - public interface _FinalStage { - SendToMsTeamsConversationId build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TenantIdStage, ServiceUrlStage, ConversationIdStage, _FinalStage { - private String tenantId; - - private String serviceUrl; - - private String conversationId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToMsTeamsConversationId other) { - tenantId(other.getTenantId()); - serviceUrl(other.getServiceUrl()); - conversationId(other.getConversationId()); - return this; - } - - @java.lang.Override - @JsonSetter("tenant_id") - public ServiceUrlStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - @JsonSetter("service_url") - public ConversationIdStage serviceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - @java.lang.Override - @JsonSetter("conversation_id") - public _FinalStage conversationId(String conversationId) { - this.conversationId = conversationId; - return this; - } - - @java.lang.Override - public SendToMsTeamsConversationId build() { - return new SendToMsTeamsConversationId(tenantId, serviceUrl, conversationId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsEmail.java b/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsEmail.java deleted file mode 100644 index 689dd460..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsEmail.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToMsTeamsEmail.Builder.class) -public final class SendToMsTeamsEmail implements IMsTeamsBaseProperties { - private final String tenantId; - - private final String serviceUrl; - - private final String email; - - private final Map additionalProperties; - - private SendToMsTeamsEmail( - String tenantId, String serviceUrl, String email, Map additionalProperties) { - this.tenantId = tenantId; - this.serviceUrl = serviceUrl; - this.email = email; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenant_id") - @java.lang.Override - public String getTenantId() { - return tenantId; - } - - @JsonProperty("service_url") - @java.lang.Override - public String getServiceUrl() { - return serviceUrl; - } - - @JsonProperty("email") - public String getEmail() { - return email; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToMsTeamsEmail && equalTo((SendToMsTeamsEmail) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToMsTeamsEmail other) { - return tenantId.equals(other.tenantId) && serviceUrl.equals(other.serviceUrl) && email.equals(other.email); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.serviceUrl, this.email); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - ServiceUrlStage tenantId(String tenantId); - - Builder from(SendToMsTeamsEmail other); - } - - public interface ServiceUrlStage { - EmailStage serviceUrl(String serviceUrl); - } - - public interface EmailStage { - _FinalStage email(String email); - } - - public interface _FinalStage { - SendToMsTeamsEmail build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TenantIdStage, ServiceUrlStage, EmailStage, _FinalStage { - private String tenantId; - - private String serviceUrl; - - private String email; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToMsTeamsEmail other) { - tenantId(other.getTenantId()); - serviceUrl(other.getServiceUrl()); - email(other.getEmail()); - return this; - } - - @java.lang.Override - @JsonSetter("tenant_id") - public ServiceUrlStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - @JsonSetter("service_url") - public EmailStage serviceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - @java.lang.Override - @JsonSetter("email") - public _FinalStage email(String email) { - this.email = email; - return this; - } - - @java.lang.Override - public SendToMsTeamsEmail build() { - return new SendToMsTeamsEmail(tenantId, serviceUrl, email, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsUserId.java b/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsUserId.java deleted file mode 100644 index d84f0d42..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToMsTeamsUserId.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToMsTeamsUserId.Builder.class) -public final class SendToMsTeamsUserId implements IMsTeamsBaseProperties { - private final String tenantId; - - private final String serviceUrl; - - private final String userId; - - private final Map additionalProperties; - - private SendToMsTeamsUserId( - String tenantId, String serviceUrl, String userId, Map additionalProperties) { - this.tenantId = tenantId; - this.serviceUrl = serviceUrl; - this.userId = userId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenant_id") - @java.lang.Override - public String getTenantId() { - return tenantId; - } - - @JsonProperty("service_url") - @java.lang.Override - public String getServiceUrl() { - return serviceUrl; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToMsTeamsUserId && equalTo((SendToMsTeamsUserId) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToMsTeamsUserId other) { - return tenantId.equals(other.tenantId) && serviceUrl.equals(other.serviceUrl) && userId.equals(other.userId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.serviceUrl, this.userId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TenantIdStage builder() { - return new Builder(); - } - - public interface TenantIdStage { - ServiceUrlStage tenantId(String tenantId); - - Builder from(SendToMsTeamsUserId other); - } - - public interface ServiceUrlStage { - UserIdStage serviceUrl(String serviceUrl); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - } - - public interface _FinalStage { - SendToMsTeamsUserId build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TenantIdStage, ServiceUrlStage, UserIdStage, _FinalStage { - private String tenantId; - - private String serviceUrl; - - private String userId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToMsTeamsUserId other) { - tenantId(other.getTenantId()); - serviceUrl(other.getServiceUrl()); - userId(other.getUserId()); - return this; - } - - @java.lang.Override - @JsonSetter("tenant_id") - public ServiceUrlStage tenantId(String tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - @JsonSetter("service_url") - public UserIdStage serviceUrl(String serviceUrl) { - this.serviceUrl = serviceUrl; - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public SendToMsTeamsUserId build() { - return new SendToMsTeamsUserId(tenantId, serviceUrl, userId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToSlackChannel.java b/src/main/java/com/courier/api/resources/profiles/types/SendToSlackChannel.java deleted file mode 100644 index af44c087..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToSlackChannel.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToSlackChannel.Builder.class) -public final class SendToSlackChannel implements ISlackBaseProperties { - private final String accessToken; - - private final String channel; - - private final Map additionalProperties; - - private SendToSlackChannel(String accessToken, String channel, Map additionalProperties) { - this.accessToken = accessToken; - this.channel = channel; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("access_token") - @java.lang.Override - public String getAccessToken() { - return accessToken; - } - - @JsonProperty("channel") - public String getChannel() { - return channel; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToSlackChannel && equalTo((SendToSlackChannel) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToSlackChannel other) { - return accessToken.equals(other.accessToken) && channel.equals(other.channel); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.accessToken, this.channel); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AccessTokenStage builder() { - return new Builder(); - } - - public interface AccessTokenStage { - ChannelStage accessToken(String accessToken); - - Builder from(SendToSlackChannel other); - } - - public interface ChannelStage { - _FinalStage channel(String channel); - } - - public interface _FinalStage { - SendToSlackChannel build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccessTokenStage, ChannelStage, _FinalStage { - private String accessToken; - - private String channel; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToSlackChannel other) { - accessToken(other.getAccessToken()); - channel(other.getChannel()); - return this; - } - - @java.lang.Override - @JsonSetter("access_token") - public ChannelStage accessToken(String accessToken) { - this.accessToken = accessToken; - return this; - } - - @java.lang.Override - @JsonSetter("channel") - public _FinalStage channel(String channel) { - this.channel = channel; - return this; - } - - @java.lang.Override - public SendToSlackChannel build() { - return new SendToSlackChannel(accessToken, channel, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToSlackEmail.java b/src/main/java/com/courier/api/resources/profiles/types/SendToSlackEmail.java deleted file mode 100644 index 3c4db6f8..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToSlackEmail.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToSlackEmail.Builder.class) -public final class SendToSlackEmail implements ISlackBaseProperties { - private final String accessToken; - - private final String email; - - private final Map additionalProperties; - - private SendToSlackEmail(String accessToken, String email, Map additionalProperties) { - this.accessToken = accessToken; - this.email = email; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("access_token") - @java.lang.Override - public String getAccessToken() { - return accessToken; - } - - @JsonProperty("email") - public String getEmail() { - return email; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToSlackEmail && equalTo((SendToSlackEmail) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToSlackEmail other) { - return accessToken.equals(other.accessToken) && email.equals(other.email); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.accessToken, this.email); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AccessTokenStage builder() { - return new Builder(); - } - - public interface AccessTokenStage { - EmailStage accessToken(String accessToken); - - Builder from(SendToSlackEmail other); - } - - public interface EmailStage { - _FinalStage email(String email); - } - - public interface _FinalStage { - SendToSlackEmail build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccessTokenStage, EmailStage, _FinalStage { - private String accessToken; - - private String email; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToSlackEmail other) { - accessToken(other.getAccessToken()); - email(other.getEmail()); - return this; - } - - @java.lang.Override - @JsonSetter("access_token") - public EmailStage accessToken(String accessToken) { - this.accessToken = accessToken; - return this; - } - - @java.lang.Override - @JsonSetter("email") - public _FinalStage email(String email) { - this.email = email; - return this; - } - - @java.lang.Override - public SendToSlackEmail build() { - return new SendToSlackEmail(accessToken, email, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SendToSlackUserId.java b/src/main/java/com/courier/api/resources/profiles/types/SendToSlackUserId.java deleted file mode 100644 index 9d0976a0..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SendToSlackUserId.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendToSlackUserId.Builder.class) -public final class SendToSlackUserId implements ISlackBaseProperties { - private final String accessToken; - - private final String userId; - - private final Map additionalProperties; - - private SendToSlackUserId(String accessToken, String userId, Map additionalProperties) { - this.accessToken = accessToken; - this.userId = userId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("access_token") - @java.lang.Override - public String getAccessToken() { - return accessToken; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendToSlackUserId && equalTo((SendToSlackUserId) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendToSlackUserId other) { - return accessToken.equals(other.accessToken) && userId.equals(other.userId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.accessToken, this.userId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AccessTokenStage builder() { - return new Builder(); - } - - public interface AccessTokenStage { - UserIdStage accessToken(String accessToken); - - Builder from(SendToSlackUserId other); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - } - - public interface _FinalStage { - SendToSlackUserId build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccessTokenStage, UserIdStage, _FinalStage { - private String accessToken; - - private String userId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendToSlackUserId other) { - accessToken(other.getAccessToken()); - userId(other.getUserId()); - return this; - } - - @java.lang.Override - @JsonSetter("access_token") - public UserIdStage accessToken(String accessToken) { - this.accessToken = accessToken; - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public SendToSlackUserId build() { - return new SendToSlackUserId(accessToken, userId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Slack.java b/src/main/java/com/courier/api/resources/profiles/types/Slack.java deleted file mode 100644 index e4e39813..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Slack.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Slack.Deserializer.class) -public final class Slack { - private final Object value; - - private final int type; - - private Slack(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((SendToSlackChannel) this.value); - } else if (this.type == 1) { - return visitor.visit((SendToSlackEmail) this.value); - } else if (this.type == 2) { - return visitor.visit((SendToSlackUserId) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Slack && equalTo((Slack) other); - } - - private boolean equalTo(Slack other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Slack of(SendToSlackChannel value) { - return new Slack(value, 0); - } - - public static Slack of(SendToSlackEmail value) { - return new Slack(value, 1); - } - - public static Slack of(SendToSlackUserId value) { - return new Slack(value, 2); - } - - public interface Visitor { - T visit(SendToSlackChannel value); - - T visit(SendToSlackEmail value); - - T visit(SendToSlackUserId value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Slack.class); - } - - @java.lang.Override - public Slack deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToSlackChannel.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToSlackEmail.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SendToSlackUserId.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SlackBaseProperties.java b/src/main/java/com/courier/api/resources/profiles/types/SlackBaseProperties.java deleted file mode 100644 index 0c161f6d..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SlackBaseProperties.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SlackBaseProperties.Builder.class) -public final class SlackBaseProperties implements ISlackBaseProperties { - private final String accessToken; - - private final Map additionalProperties; - - private SlackBaseProperties(String accessToken, Map additionalProperties) { - this.accessToken = accessToken; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("access_token") - @java.lang.Override - public String getAccessToken() { - return accessToken; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SlackBaseProperties && equalTo((SlackBaseProperties) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SlackBaseProperties other) { - return accessToken.equals(other.accessToken); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.accessToken); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AccessTokenStage builder() { - return new Builder(); - } - - public interface AccessTokenStage { - _FinalStage accessToken(String accessToken); - - Builder from(SlackBaseProperties other); - } - - public interface _FinalStage { - SlackBaseProperties build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AccessTokenStage, _FinalStage { - private String accessToken; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SlackBaseProperties other) { - accessToken(other.getAccessToken()); - return this; - } - - @java.lang.Override - @JsonSetter("access_token") - public _FinalStage accessToken(String accessToken) { - this.accessToken = accessToken; - return this; - } - - @java.lang.Override - public SlackBaseProperties build() { - return new SlackBaseProperties(accessToken, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SnoozeRule.java b/src/main/java/com/courier/api/resources/profiles/types/SnoozeRule.java deleted file mode 100644 index c3be0760..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SnoozeRule.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SnoozeRule.Builder.class) -public final class SnoozeRule { - private final SnoozeRuleType type; - - private final String start; - - private final String until; - - private final Map additionalProperties; - - private SnoozeRule(SnoozeRuleType type, String start, String until, Map additionalProperties) { - this.type = type; - this.start = start; - this.until = until; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("type") - public SnoozeRuleType getType() { - return type; - } - - @JsonProperty("start") - public String getStart() { - return start; - } - - @JsonProperty("until") - public String getUntil() { - return until; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SnoozeRule && equalTo((SnoozeRule) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SnoozeRule other) { - return type.equals(other.type) && start.equals(other.start) && until.equals(other.until); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.start, this.until); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TypeStage builder() { - return new Builder(); - } - - public interface TypeStage { - StartStage type(SnoozeRuleType type); - - Builder from(SnoozeRule other); - } - - public interface StartStage { - UntilStage start(String start); - } - - public interface UntilStage { - _FinalStage until(String until); - } - - public interface _FinalStage { - SnoozeRule build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TypeStage, StartStage, UntilStage, _FinalStage { - private SnoozeRuleType type; - - private String start; - - private String until; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SnoozeRule other) { - type(other.getType()); - start(other.getStart()); - until(other.getUntil()); - return this; - } - - @java.lang.Override - @JsonSetter("type") - public StartStage type(SnoozeRuleType type) { - this.type = type; - return this; - } - - @java.lang.Override - @JsonSetter("start") - public UntilStage start(String start) { - this.start = start; - return this; - } - - @java.lang.Override - @JsonSetter("until") - public _FinalStage until(String until) { - this.until = until; - return this; - } - - @java.lang.Override - public SnoozeRule build() { - return new SnoozeRule(type, start, until, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SnoozeRuleType.java b/src/main/java/com/courier/api/resources/profiles/types/SnoozeRuleType.java deleted file mode 100644 index f5b7f9a0..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SnoozeRuleType.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SnoozeRuleType { - SNOOZE("snooze"); - - private final String value; - - SnoozeRuleType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequest.java b/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequest.java deleted file mode 100644 index b0a1c0bc..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscribeToListsRequest.Builder.class) -public final class SubscribeToListsRequest { - private final List lists; - - private final Map additionalProperties; - - private SubscribeToListsRequest( - List lists, Map additionalProperties) { - this.lists = lists; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("lists") - public List getLists() { - return lists; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscribeToListsRequest && equalTo((SubscribeToListsRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubscribeToListsRequest other) { - return lists.equals(other.lists); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.lists); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List lists = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubscribeToListsRequest other) { - lists(other.getLists()); - return this; - } - - @JsonSetter(value = "lists", nulls = Nulls.SKIP) - public Builder lists(List lists) { - this.lists.clear(); - this.lists.addAll(lists); - return this; - } - - public Builder addLists(SubscribeToListsRequestListObject lists) { - this.lists.add(lists); - return this; - } - - public Builder addAllLists(List lists) { - this.lists.addAll(lists); - return this; - } - - public SubscribeToListsRequest build() { - return new SubscribeToListsRequest(lists, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequestListObject.java b/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequestListObject.java deleted file mode 100644 index 59d512b1..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsRequestListObject.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.RecipientPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscribeToListsRequestListObject.Builder.class) -public final class SubscribeToListsRequestListObject { - private final String listId; - - private final Optional preferences; - - private final Map additionalProperties; - - private SubscribeToListsRequestListObject( - String listId, Optional preferences, Map additionalProperties) { - this.listId = listId; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("listId") - public String getListId() { - return listId; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscribeToListsRequestListObject && equalTo((SubscribeToListsRequestListObject) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubscribeToListsRequestListObject other) { - return listId.equals(other.listId) && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.listId, this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ListIdStage builder() { - return new Builder(); - } - - public interface ListIdStage { - _FinalStage listId(String listId); - - Builder from(SubscribeToListsRequestListObject other); - } - - public interface _FinalStage { - SubscribeToListsRequestListObject build(); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(RecipientPreferences preferences); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ListIdStage, _FinalStage { - private String listId; - - private Optional preferences = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SubscribeToListsRequestListObject other) { - listId(other.getListId()); - preferences(other.getPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("listId") - public _FinalStage listId(String listId) { - this.listId = listId; - return this; - } - - @java.lang.Override - public _FinalStage preferences(RecipientPreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public SubscribeToListsRequestListObject build() { - return new SubscribeToListsRequestListObject(listId, preferences, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsResponse.java b/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsResponse.java deleted file mode 100644 index e8707af3..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/SubscribeToListsResponse.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscribeToListsResponse.Builder.class) -public final class SubscribeToListsResponse { - private final Map additionalProperties; - - private SubscribeToListsResponse(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public String getStatus() { - return "SUCCESS"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscribeToListsResponse; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(SubscribeToListsResponse other) { - return this; - } - - public SubscribeToListsResponse build() { - return new SubscribeToListsResponse(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/Token.java b/src/main/java/com/courier/api/resources/profiles/types/Token.java deleted file mode 100644 index b77b7709..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/Token.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Token.Builder.class) -public final class Token { - private final String token; - - private final Map additionalProperties; - - private Token(String token, Map additionalProperties) { - this.token = token; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("token") - public String getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Token && equalTo((Token) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Token other) { - return token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TokenStage builder() { - return new Builder(); - } - - public interface TokenStage { - _FinalStage token(String token); - - Builder from(Token other); - } - - public interface _FinalStage { - Token build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TokenStage, _FinalStage { - private String token; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Token other) { - token(other.getToken()); - return this; - } - - @java.lang.Override - @JsonSetter("token") - public _FinalStage token(String token) { - this.token = token; - return this; - } - - @java.lang.Override - public Token build() { - return new Token(token, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/UserProfile.java b/src/main/java/com/courier/api/resources/profiles/types/UserProfile.java deleted file mode 100644 index 9ffbeb8d..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/UserProfile.java +++ /dev/null @@ -1,925 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserProfile.Builder.class) -public final class UserProfile { - private final Address address; - - private final String birthdate; - - private final String email; - - private final boolean emailVerified; - - private final String familyName; - - private final String gender; - - private final String givenName; - - private final String locale; - - private final String middleName; - - private final String name; - - private final String nickname; - - private final String phoneNumber; - - private final boolean phoneNumberVerified; - - private final String picture; - - private final String preferredName; - - private final String profile; - - private final String sub; - - private final String updatedAt; - - private final String website; - - private final String zoneinfo; - - private final Object custom; - - private final AirshipProfile airship; - - private final String apn; - - private final String targetArn; - - private final Discord discord; - - private final Expo expo; - - private final String facebookPsid; - - private final UserProfileFirebaseToken firebaseToken; - - private final Intercom intercom; - - private final Slack slack; - - private final MsTeams msTeams; - - private final Map additionalProperties; - - private UserProfile( - Address address, - String birthdate, - String email, - boolean emailVerified, - String familyName, - String gender, - String givenName, - String locale, - String middleName, - String name, - String nickname, - String phoneNumber, - boolean phoneNumberVerified, - String picture, - String preferredName, - String profile, - String sub, - String updatedAt, - String website, - String zoneinfo, - Object custom, - AirshipProfile airship, - String apn, - String targetArn, - Discord discord, - Expo expo, - String facebookPsid, - UserProfileFirebaseToken firebaseToken, - Intercom intercom, - Slack slack, - MsTeams msTeams, - Map additionalProperties) { - this.address = address; - this.birthdate = birthdate; - this.email = email; - this.emailVerified = emailVerified; - this.familyName = familyName; - this.gender = gender; - this.givenName = givenName; - this.locale = locale; - this.middleName = middleName; - this.name = name; - this.nickname = nickname; - this.phoneNumber = phoneNumber; - this.phoneNumberVerified = phoneNumberVerified; - this.picture = picture; - this.preferredName = preferredName; - this.profile = profile; - this.sub = sub; - this.updatedAt = updatedAt; - this.website = website; - this.zoneinfo = zoneinfo; - this.custom = custom; - this.airship = airship; - this.apn = apn; - this.targetArn = targetArn; - this.discord = discord; - this.expo = expo; - this.facebookPsid = facebookPsid; - this.firebaseToken = firebaseToken; - this.intercom = intercom; - this.slack = slack; - this.msTeams = msTeams; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("address") - public Address getAddress() { - return address; - } - - @JsonProperty("birthdate") - public String getBirthdate() { - return birthdate; - } - - @JsonProperty("email") - public String getEmail() { - return email; - } - - @JsonProperty("email_verified") - public boolean getEmailVerified() { - return emailVerified; - } - - @JsonProperty("family_name") - public String getFamilyName() { - return familyName; - } - - @JsonProperty("gender") - public String getGender() { - return gender; - } - - @JsonProperty("given_name") - public String getGivenName() { - return givenName; - } - - @JsonProperty("locale") - public String getLocale() { - return locale; - } - - @JsonProperty("middle_name") - public String getMiddleName() { - return middleName; - } - - @JsonProperty("name") - public String getName() { - return name; - } - - @JsonProperty("nickname") - public String getNickname() { - return nickname; - } - - @JsonProperty("phone_number") - public String getPhoneNumber() { - return phoneNumber; - } - - @JsonProperty("phone_number_verified") - public boolean getPhoneNumberVerified() { - return phoneNumberVerified; - } - - @JsonProperty("picture") - public String getPicture() { - return picture; - } - - @JsonProperty("preferred_name") - public String getPreferredName() { - return preferredName; - } - - @JsonProperty("profile") - public String getProfile() { - return profile; - } - - @JsonProperty("sub") - public String getSub() { - return sub; - } - - @JsonProperty("updated_at") - public String getUpdatedAt() { - return updatedAt; - } - - @JsonProperty("website") - public String getWebsite() { - return website; - } - - @JsonProperty("zoneinfo") - public String getZoneinfo() { - return zoneinfo; - } - - /** - * @return A free form object. Due to a limitation of the API Explorer, you can only enter string key/values below, but this API accepts more complex object structures. - */ - @JsonProperty("custom") - public Object getCustom() { - return custom; - } - - @JsonProperty("airship") - public AirshipProfile getAirship() { - return airship; - } - - @JsonProperty("apn") - public String getApn() { - return apn; - } - - @JsonProperty("target_arn") - public String getTargetArn() { - return targetArn; - } - - @JsonProperty("discord") - public Discord getDiscord() { - return discord; - } - - @JsonProperty("expo") - public Expo getExpo() { - return expo; - } - - @JsonProperty("facebookPSID") - public String getFacebookPsid() { - return facebookPsid; - } - - @JsonProperty("firebaseToken") - public UserProfileFirebaseToken getFirebaseToken() { - return firebaseToken; - } - - @JsonProperty("intercom") - public Intercom getIntercom() { - return intercom; - } - - @JsonProperty("slack") - public Slack getSlack() { - return slack; - } - - @JsonProperty("ms_teams") - public MsTeams getMsTeams() { - return msTeams; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserProfile && equalTo((UserProfile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserProfile other) { - return address.equals(other.address) - && birthdate.equals(other.birthdate) - && email.equals(other.email) - && emailVerified == other.emailVerified - && familyName.equals(other.familyName) - && gender.equals(other.gender) - && givenName.equals(other.givenName) - && locale.equals(other.locale) - && middleName.equals(other.middleName) - && name.equals(other.name) - && nickname.equals(other.nickname) - && phoneNumber.equals(other.phoneNumber) - && phoneNumberVerified == other.phoneNumberVerified - && picture.equals(other.picture) - && preferredName.equals(other.preferredName) - && profile.equals(other.profile) - && sub.equals(other.sub) - && updatedAt.equals(other.updatedAt) - && website.equals(other.website) - && zoneinfo.equals(other.zoneinfo) - && custom.equals(other.custom) - && airship.equals(other.airship) - && apn.equals(other.apn) - && targetArn.equals(other.targetArn) - && discord.equals(other.discord) - && expo.equals(other.expo) - && facebookPsid.equals(other.facebookPsid) - && firebaseToken.equals(other.firebaseToken) - && intercom.equals(other.intercom) - && slack.equals(other.slack) - && msTeams.equals(other.msTeams); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.address, - this.birthdate, - this.email, - this.emailVerified, - this.familyName, - this.gender, - this.givenName, - this.locale, - this.middleName, - this.name, - this.nickname, - this.phoneNumber, - this.phoneNumberVerified, - this.picture, - this.preferredName, - this.profile, - this.sub, - this.updatedAt, - this.website, - this.zoneinfo, - this.custom, - this.airship, - this.apn, - this.targetArn, - this.discord, - this.expo, - this.facebookPsid, - this.firebaseToken, - this.intercom, - this.slack, - this.msTeams); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AddressStage builder() { - return new Builder(); - } - - public interface AddressStage { - BirthdateStage address(Address address); - - Builder from(UserProfile other); - } - - public interface BirthdateStage { - EmailStage birthdate(String birthdate); - } - - public interface EmailStage { - EmailVerifiedStage email(String email); - } - - public interface EmailVerifiedStage { - FamilyNameStage emailVerified(boolean emailVerified); - } - - public interface FamilyNameStage { - GenderStage familyName(String familyName); - } - - public interface GenderStage { - GivenNameStage gender(String gender); - } - - public interface GivenNameStage { - LocaleStage givenName(String givenName); - } - - public interface LocaleStage { - MiddleNameStage locale(String locale); - } - - public interface MiddleNameStage { - NameStage middleName(String middleName); - } - - public interface NameStage { - NicknameStage name(String name); - } - - public interface NicknameStage { - PhoneNumberStage nickname(String nickname); - } - - public interface PhoneNumberStage { - PhoneNumberVerifiedStage phoneNumber(String phoneNumber); - } - - public interface PhoneNumberVerifiedStage { - PictureStage phoneNumberVerified(boolean phoneNumberVerified); - } - - public interface PictureStage { - PreferredNameStage picture(String picture); - } - - public interface PreferredNameStage { - ProfileStage preferredName(String preferredName); - } - - public interface ProfileStage { - SubStage profile(String profile); - } - - public interface SubStage { - UpdatedAtStage sub(String sub); - } - - public interface UpdatedAtStage { - WebsiteStage updatedAt(String updatedAt); - } - - public interface WebsiteStage { - ZoneinfoStage website(String website); - } - - public interface ZoneinfoStage { - CustomStage zoneinfo(String zoneinfo); - } - - public interface CustomStage { - AirshipStage custom(Object custom); - } - - public interface AirshipStage { - ApnStage airship(AirshipProfile airship); - } - - public interface ApnStage { - TargetArnStage apn(String apn); - } - - public interface TargetArnStage { - DiscordStage targetArn(String targetArn); - } - - public interface DiscordStage { - ExpoStage discord(Discord discord); - } - - public interface ExpoStage { - FacebookPsidStage expo(Expo expo); - } - - public interface FacebookPsidStage { - FirebaseTokenStage facebookPsid(String facebookPsid); - } - - public interface FirebaseTokenStage { - IntercomStage firebaseToken(UserProfileFirebaseToken firebaseToken); - } - - public interface IntercomStage { - SlackStage intercom(Intercom intercom); - } - - public interface SlackStage { - MsTeamsStage slack(Slack slack); - } - - public interface MsTeamsStage { - _FinalStage msTeams(MsTeams msTeams); - } - - public interface _FinalStage { - UserProfile build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements AddressStage, - BirthdateStage, - EmailStage, - EmailVerifiedStage, - FamilyNameStage, - GenderStage, - GivenNameStage, - LocaleStage, - MiddleNameStage, - NameStage, - NicknameStage, - PhoneNumberStage, - PhoneNumberVerifiedStage, - PictureStage, - PreferredNameStage, - ProfileStage, - SubStage, - UpdatedAtStage, - WebsiteStage, - ZoneinfoStage, - CustomStage, - AirshipStage, - ApnStage, - TargetArnStage, - DiscordStage, - ExpoStage, - FacebookPsidStage, - FirebaseTokenStage, - IntercomStage, - SlackStage, - MsTeamsStage, - _FinalStage { - private Address address; - - private String birthdate; - - private String email; - - private boolean emailVerified; - - private String familyName; - - private String gender; - - private String givenName; - - private String locale; - - private String middleName; - - private String name; - - private String nickname; - - private String phoneNumber; - - private boolean phoneNumberVerified; - - private String picture; - - private String preferredName; - - private String profile; - - private String sub; - - private String updatedAt; - - private String website; - - private String zoneinfo; - - private Object custom; - - private AirshipProfile airship; - - private String apn; - - private String targetArn; - - private Discord discord; - - private Expo expo; - - private String facebookPsid; - - private UserProfileFirebaseToken firebaseToken; - - private Intercom intercom; - - private Slack slack; - - private MsTeams msTeams; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserProfile other) { - address(other.getAddress()); - birthdate(other.getBirthdate()); - email(other.getEmail()); - emailVerified(other.getEmailVerified()); - familyName(other.getFamilyName()); - gender(other.getGender()); - givenName(other.getGivenName()); - locale(other.getLocale()); - middleName(other.getMiddleName()); - name(other.getName()); - nickname(other.getNickname()); - phoneNumber(other.getPhoneNumber()); - phoneNumberVerified(other.getPhoneNumberVerified()); - picture(other.getPicture()); - preferredName(other.getPreferredName()); - profile(other.getProfile()); - sub(other.getSub()); - updatedAt(other.getUpdatedAt()); - website(other.getWebsite()); - zoneinfo(other.getZoneinfo()); - custom(other.getCustom()); - airship(other.getAirship()); - apn(other.getApn()); - targetArn(other.getTargetArn()); - discord(other.getDiscord()); - expo(other.getExpo()); - facebookPsid(other.getFacebookPsid()); - firebaseToken(other.getFirebaseToken()); - intercom(other.getIntercom()); - slack(other.getSlack()); - msTeams(other.getMsTeams()); - return this; - } - - @java.lang.Override - @JsonSetter("address") - public BirthdateStage address(Address address) { - this.address = address; - return this; - } - - @java.lang.Override - @JsonSetter("birthdate") - public EmailStage birthdate(String birthdate) { - this.birthdate = birthdate; - return this; - } - - @java.lang.Override - @JsonSetter("email") - public EmailVerifiedStage email(String email) { - this.email = email; - return this; - } - - @java.lang.Override - @JsonSetter("email_verified") - public FamilyNameStage emailVerified(boolean emailVerified) { - this.emailVerified = emailVerified; - return this; - } - - @java.lang.Override - @JsonSetter("family_name") - public GenderStage familyName(String familyName) { - this.familyName = familyName; - return this; - } - - @java.lang.Override - @JsonSetter("gender") - public GivenNameStage gender(String gender) { - this.gender = gender; - return this; - } - - @java.lang.Override - @JsonSetter("given_name") - public LocaleStage givenName(String givenName) { - this.givenName = givenName; - return this; - } - - @java.lang.Override - @JsonSetter("locale") - public MiddleNameStage locale(String locale) { - this.locale = locale; - return this; - } - - @java.lang.Override - @JsonSetter("middle_name") - public NameStage middleName(String middleName) { - this.middleName = middleName; - return this; - } - - @java.lang.Override - @JsonSetter("name") - public NicknameStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - @JsonSetter("nickname") - public PhoneNumberStage nickname(String nickname) { - this.nickname = nickname; - return this; - } - - @java.lang.Override - @JsonSetter("phone_number") - public PhoneNumberVerifiedStage phoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - - @java.lang.Override - @JsonSetter("phone_number_verified") - public PictureStage phoneNumberVerified(boolean phoneNumberVerified) { - this.phoneNumberVerified = phoneNumberVerified; - return this; - } - - @java.lang.Override - @JsonSetter("picture") - public PreferredNameStage picture(String picture) { - this.picture = picture; - return this; - } - - @java.lang.Override - @JsonSetter("preferred_name") - public ProfileStage preferredName(String preferredName) { - this.preferredName = preferredName; - return this; - } - - @java.lang.Override - @JsonSetter("profile") - public SubStage profile(String profile) { - this.profile = profile; - return this; - } - - @java.lang.Override - @JsonSetter("sub") - public UpdatedAtStage sub(String sub) { - this.sub = sub; - return this; - } - - @java.lang.Override - @JsonSetter("updated_at") - public WebsiteStage updatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @java.lang.Override - @JsonSetter("website") - public ZoneinfoStage website(String website) { - this.website = website; - return this; - } - - @java.lang.Override - @JsonSetter("zoneinfo") - public CustomStage zoneinfo(String zoneinfo) { - this.zoneinfo = zoneinfo; - return this; - } - - /** - *

A free form object. Due to a limitation of the API Explorer, you can only enter string key/values below, but this API accepts more complex object structures.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("custom") - public AirshipStage custom(Object custom) { - this.custom = custom; - return this; - } - - @java.lang.Override - @JsonSetter("airship") - public ApnStage airship(AirshipProfile airship) { - this.airship = airship; - return this; - } - - @java.lang.Override - @JsonSetter("apn") - public TargetArnStage apn(String apn) { - this.apn = apn; - return this; - } - - @java.lang.Override - @JsonSetter("target_arn") - public DiscordStage targetArn(String targetArn) { - this.targetArn = targetArn; - return this; - } - - @java.lang.Override - @JsonSetter("discord") - public ExpoStage discord(Discord discord) { - this.discord = discord; - return this; - } - - @java.lang.Override - @JsonSetter("expo") - public FacebookPsidStage expo(Expo expo) { - this.expo = expo; - return this; - } - - @java.lang.Override - @JsonSetter("facebookPSID") - public FirebaseTokenStage facebookPsid(String facebookPsid) { - this.facebookPsid = facebookPsid; - return this; - } - - @java.lang.Override - @JsonSetter("firebaseToken") - public IntercomStage firebaseToken(UserProfileFirebaseToken firebaseToken) { - this.firebaseToken = firebaseToken; - return this; - } - - @java.lang.Override - @JsonSetter("intercom") - public SlackStage intercom(Intercom intercom) { - this.intercom = intercom; - return this; - } - - @java.lang.Override - @JsonSetter("slack") - public MsTeamsStage slack(Slack slack) { - this.slack = slack; - return this; - } - - @java.lang.Override - @JsonSetter("ms_teams") - public _FinalStage msTeams(MsTeams msTeams) { - this.msTeams = msTeams; - return this; - } - - @java.lang.Override - public UserProfile build() { - return new UserProfile( - address, - birthdate, - email, - emailVerified, - familyName, - gender, - givenName, - locale, - middleName, - name, - nickname, - phoneNumber, - phoneNumberVerified, - picture, - preferredName, - profile, - sub, - updatedAt, - website, - zoneinfo, - custom, - airship, - apn, - targetArn, - discord, - expo, - facebookPsid, - firebaseToken, - intercom, - slack, - msTeams, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/UserProfileFirebaseToken.java b/src/main/java/com/courier/api/resources/profiles/types/UserProfileFirebaseToken.java deleted file mode 100644 index ac49d530..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/UserProfileFirebaseToken.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.List; -import java.util.Objects; - -@JsonDeserialize(using = UserProfileFirebaseToken.Deserializer.class) -public final class UserProfileFirebaseToken { - private final Object value; - - private final int type; - - private UserProfileFirebaseToken(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((List) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserProfileFirebaseToken && equalTo((UserProfileFirebaseToken) other); - } - - private boolean equalTo(UserProfileFirebaseToken other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static UserProfileFirebaseToken of(String value) { - return new UserProfileFirebaseToken(value, 0); - } - - public static UserProfileFirebaseToken of(List value) { - return new UserProfileFirebaseToken(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(List value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(UserProfileFirebaseToken.class); - } - - @java.lang.Override - public UserProfileFirebaseToken deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/UserProfilePatch.java b/src/main/java/com/courier/api/resources/profiles/types/UserProfilePatch.java deleted file mode 100644 index dabb61f7..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/UserProfilePatch.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserProfilePatch.Builder.class) -public final class UserProfilePatch { - private final String op; - - private final String path; - - private final String value; - - private final Map additionalProperties; - - private UserProfilePatch(String op, String path, String value, Map additionalProperties) { - this.op = op; - this.path = path; - this.value = value; - this.additionalProperties = additionalProperties; - } - - /** - * @return The operation to perform. - */ - @JsonProperty("op") - public String getOp() { - return op; - } - - /** - * @return The JSON path specifying the part of the profile to operate on. - */ - @JsonProperty("path") - public String getPath() { - return path; - } - - /** - * @return The value for the operation. - */ - @JsonProperty("value") - public String getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserProfilePatch && equalTo((UserProfilePatch) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserProfilePatch other) { - return op.equals(other.op) && path.equals(other.path) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.op, this.path, this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static OpStage builder() { - return new Builder(); - } - - public interface OpStage { - PathStage op(String op); - - Builder from(UserProfilePatch other); - } - - public interface PathStage { - ValueStage path(String path); - } - - public interface ValueStage { - _FinalStage value(String value); - } - - public interface _FinalStage { - UserProfilePatch build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements OpStage, PathStage, ValueStage, _FinalStage { - private String op; - - private String path; - - private String value; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserProfilePatch other) { - op(other.getOp()); - path(other.getPath()); - value(other.getValue()); - return this; - } - - /** - *

The operation to perform.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("op") - public PathStage op(String op) { - this.op = op; - return this; - } - - /** - *

The JSON path specifying the part of the profile to operate on.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("path") - public ValueStage path(String path) { - this.path = path; - return this; - } - - /** - *

The value for the operation.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(String value) { - this.value = value; - return this; - } - - @java.lang.Override - public UserProfilePatch build() { - return new UserProfilePatch(op, path, value, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/WebhookAuthMode.java b/src/main/java/com/courier/api/resources/profiles/types/WebhookAuthMode.java deleted file mode 100644 index 8134f7c9..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/WebhookAuthMode.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum WebhookAuthMode { - NONE("none"), - - BASIC("basic"), - - BEARER("bearer"); - - private final String value; - - WebhookAuthMode(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/WebhookAuthentication.java b/src/main/java/com/courier/api/resources/profiles/types/WebhookAuthentication.java deleted file mode 100644 index c17e6444..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/WebhookAuthentication.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = WebhookAuthentication.Builder.class) -public final class WebhookAuthentication { - private final WebhookAuthMode mode; - - private final Optional username; - - private final Optional password; - - private final Optional token; - - private final Map additionalProperties; - - private WebhookAuthentication( - WebhookAuthMode mode, - Optional username, - Optional password, - Optional token, - Map additionalProperties) { - this.mode = mode; - this.username = username; - this.password = password; - this.token = token; - this.additionalProperties = additionalProperties; - } - - /** - * @return The authentication mode to use. Defaults to 'none' if not specified. - */ - @JsonProperty("mode") - public WebhookAuthMode getMode() { - return mode; - } - - /** - * @return Username for basic authentication. - */ - @JsonProperty("username") - public Optional getUsername() { - return username; - } - - /** - * @return Password for basic authentication. - */ - @JsonProperty("password") - public Optional getPassword() { - return password; - } - - /** - * @return Token for bearer authentication. - */ - @JsonProperty("token") - public Optional getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof WebhookAuthentication && equalTo((WebhookAuthentication) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(WebhookAuthentication other) { - return mode.equals(other.mode) - && username.equals(other.username) - && password.equals(other.password) - && token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.mode, this.username, this.password, this.token); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ModeStage builder() { - return new Builder(); - } - - public interface ModeStage { - _FinalStage mode(WebhookAuthMode mode); - - Builder from(WebhookAuthentication other); - } - - public interface _FinalStage { - WebhookAuthentication build(); - - _FinalStage username(Optional username); - - _FinalStage username(String username); - - _FinalStage password(Optional password); - - _FinalStage password(String password); - - _FinalStage token(Optional token); - - _FinalStage token(String token); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ModeStage, _FinalStage { - private WebhookAuthMode mode; - - private Optional token = Optional.empty(); - - private Optional password = Optional.empty(); - - private Optional username = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(WebhookAuthentication other) { - mode(other.getMode()); - username(other.getUsername()); - password(other.getPassword()); - token(other.getToken()); - return this; - } - - /** - *

The authentication mode to use. Defaults to 'none' if not specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("mode") - public _FinalStage mode(WebhookAuthMode mode) { - this.mode = mode; - return this; - } - - /** - *

Token for bearer authentication.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage token(String token) { - this.token = Optional.of(token); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token", nulls = Nulls.SKIP) - public _FinalStage token(Optional token) { - this.token = token; - return this; - } - - /** - *

Password for basic authentication.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage password(String password) { - this.password = Optional.of(password); - return this; - } - - @java.lang.Override - @JsonSetter(value = "password", nulls = Nulls.SKIP) - public _FinalStage password(Optional password) { - this.password = password; - return this; - } - - /** - *

Username for basic authentication.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage username(String username) { - this.username = Optional.of(username); - return this; - } - - @java.lang.Override - @JsonSetter(value = "username", nulls = Nulls.SKIP) - public _FinalStage username(Optional username) { - this.username = username; - return this; - } - - @java.lang.Override - public WebhookAuthentication build() { - return new WebhookAuthentication(mode, username, password, token, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/WebhookMethod.java b/src/main/java/com/courier/api/resources/profiles/types/WebhookMethod.java deleted file mode 100644 index 6384e8f5..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/WebhookMethod.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum WebhookMethod { - POST("POST"), - - PUT("PUT"); - - private final String value; - - WebhookMethod(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/WebhookProfile.java b/src/main/java/com/courier/api/resources/profiles/types/WebhookProfile.java deleted file mode 100644 index f3cf81be..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/WebhookProfile.java +++ /dev/null @@ -1,260 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = WebhookProfile.Builder.class) -public final class WebhookProfile { - private final String url; - - private final Optional method; - - private final Optional> headers; - - private final Optional authentication; - - private final Optional profile; - - private final Map additionalProperties; - - private WebhookProfile( - String url, - Optional method, - Optional> headers, - Optional authentication, - Optional profile, - Map additionalProperties) { - this.url = url; - this.method = method; - this.headers = headers; - this.authentication = authentication; - this.profile = profile; - this.additionalProperties = additionalProperties; - } - - /** - * @return The URL to send the webhook request to. - */ - @JsonProperty("url") - public String getUrl() { - return url; - } - - /** - * @return The HTTP method to use for the webhook request. Defaults to POST if not specified. - */ - @JsonProperty("method") - public Optional getMethod() { - return method; - } - - /** - * @return Custom headers to include in the webhook request. - */ - @JsonProperty("headers") - public Optional> getHeaders() { - return headers; - } - - /** - * @return Authentication configuration for the webhook request. - */ - @JsonProperty("authentication") - public Optional getAuthentication() { - return authentication; - } - - /** - * @return Specifies what profile information is included in the request payload. Defaults to 'limited' if not specified. - */ - @JsonProperty("profile") - public Optional getProfile() { - return profile; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof WebhookProfile && equalTo((WebhookProfile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(WebhookProfile other) { - return url.equals(other.url) - && method.equals(other.method) - && headers.equals(other.headers) - && authentication.equals(other.authentication) - && profile.equals(other.profile); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.url, this.method, this.headers, this.authentication, this.profile); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UrlStage builder() { - return new Builder(); - } - - public interface UrlStage { - _FinalStage url(String url); - - Builder from(WebhookProfile other); - } - - public interface _FinalStage { - WebhookProfile build(); - - _FinalStage method(Optional method); - - _FinalStage method(WebhookMethod method); - - _FinalStage headers(Optional> headers); - - _FinalStage headers(Map headers); - - _FinalStage authentication(Optional authentication); - - _FinalStage authentication(WebhookAuthentication authentication); - - _FinalStage profile(Optional profile); - - _FinalStage profile(WebhookProfileType profile); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UrlStage, _FinalStage { - private String url; - - private Optional profile = Optional.empty(); - - private Optional authentication = Optional.empty(); - - private Optional> headers = Optional.empty(); - - private Optional method = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(WebhookProfile other) { - url(other.getUrl()); - method(other.getMethod()); - headers(other.getHeaders()); - authentication(other.getAuthentication()); - profile(other.getProfile()); - return this; - } - - /** - *

The URL to send the webhook request to.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - /** - *

Specifies what profile information is included in the request payload. Defaults to 'limited' if not specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage profile(WebhookProfileType profile) { - this.profile = Optional.of(profile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public _FinalStage profile(Optional profile) { - this.profile = profile; - return this; - } - - /** - *

Authentication configuration for the webhook request.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage authentication(WebhookAuthentication authentication) { - this.authentication = Optional.of(authentication); - return this; - } - - @java.lang.Override - @JsonSetter(value = "authentication", nulls = Nulls.SKIP) - public _FinalStage authentication(Optional authentication) { - this.authentication = authentication; - return this; - } - - /** - *

Custom headers to include in the webhook request.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage headers(Map headers) { - this.headers = Optional.of(headers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "headers", nulls = Nulls.SKIP) - public _FinalStage headers(Optional> headers) { - this.headers = headers; - return this; - } - - /** - *

The HTTP method to use for the webhook request. Defaults to POST if not specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage method(WebhookMethod method) { - this.method = Optional.of(method); - return this; - } - - @java.lang.Override - @JsonSetter(value = "method", nulls = Nulls.SKIP) - public _FinalStage method(Optional method) { - this.method = method; - return this; - } - - @java.lang.Override - public WebhookProfile build() { - return new WebhookProfile(url, method, headers, authentication, profile, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/profiles/types/WebhookProfileType.java b/src/main/java/com/courier/api/resources/profiles/types/WebhookProfileType.java deleted file mode 100644 index 6c140793..00000000 --- a/src/main/java/com/courier/api/resources/profiles/types/WebhookProfileType.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.profiles.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum WebhookProfileType { - LIMITED("limited"), - - EXPANDED("expanded"); - - private final String value; - - WebhookProfileType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/AudienceFilter.java b/src/main/java/com/courier/api/resources/send/types/AudienceFilter.java deleted file mode 100644 index 7430ce50..00000000 --- a/src/main/java/com/courier/api/resources/send/types/AudienceFilter.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceFilter.Builder.class) -public final class AudienceFilter { - private final String value; - - private final Map additionalProperties; - - private AudienceFilter(String value, Map additionalProperties) { - this.value = value; - this.additionalProperties = additionalProperties; - } - - /** - * @return Send to users only if they are member of the account - */ - @JsonProperty("operator") - public String getOperator() { - return "MEMBER_OF"; - } - - @JsonProperty("path") - public String getPath() { - return "account_id"; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceFilter && equalTo((AudienceFilter) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceFilter other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ValueStage builder() { - return new Builder(); - } - - public interface ValueStage { - _FinalStage value(String value); - - Builder from(AudienceFilter other); - } - - public interface _FinalStage { - AudienceFilter build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ValueStage, _FinalStage { - private String value; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceFilter other) { - value(other.getValue()); - return this; - } - - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(String value) { - this.value = value; - return this; - } - - @java.lang.Override - public AudienceFilter build() { - return new AudienceFilter(value, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/AudienceRecipient.java b/src/main/java/com/courier/api/resources/send/types/AudienceRecipient.java deleted file mode 100644 index e512136a..00000000 --- a/src/main/java/com/courier/api/resources/send/types/AudienceRecipient.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AudienceRecipient.Builder.class) -public final class AudienceRecipient { - private final String audienceId; - - private final Optional> data; - - private final Optional> filters; - - private final Map additionalProperties; - - private AudienceRecipient( - String audienceId, - Optional> data, - Optional> filters, - Map additionalProperties) { - this.audienceId = audienceId; - this.data = data; - this.filters = filters; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier associated with an Audience. A message will be sent to each user in the audience. - */ - @JsonProperty("audience_id") - public String getAudienceId() { - return audienceId; - } - - @JsonProperty("data") - public Optional> getData() { - return data; - } - - @JsonProperty("filters") - public Optional> getFilters() { - return filters; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AudienceRecipient && equalTo((AudienceRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AudienceRecipient other) { - return audienceId.equals(other.audienceId) && data.equals(other.data) && filters.equals(other.filters); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.audienceId, this.data, this.filters); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static AudienceIdStage builder() { - return new Builder(); - } - - public interface AudienceIdStage { - _FinalStage audienceId(String audienceId); - - Builder from(AudienceRecipient other); - } - - public interface _FinalStage { - AudienceRecipient build(); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage filters(Optional> filters); - - _FinalStage filters(List filters); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements AudienceIdStage, _FinalStage { - private String audienceId; - - private Optional> filters = Optional.empty(); - - private Optional> data = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AudienceRecipient other) { - audienceId(other.getAudienceId()); - data(other.getData()); - filters(other.getFilters()); - return this; - } - - /** - *

A unique identifier associated with an Audience. A message will be sent to each user in the audience.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("audience_id") - public _FinalStage audienceId(String audienceId) { - this.audienceId = audienceId; - return this; - } - - @java.lang.Override - public _FinalStage filters(List filters) { - this.filters = Optional.of(filters); - return this; - } - - @java.lang.Override - @JsonSetter(value = "filters", nulls = Nulls.SKIP) - public _FinalStage filters(Optional> filters) { - this.filters = filters; - return this; - } - - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public AudienceRecipient build() { - return new AudienceRecipient(audienceId, data, filters, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BaseMessage.java b/src/main/java/com/courier/api/resources/send/types/BaseMessage.java deleted file mode 100644 index 7094367b..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BaseMessage.java +++ /dev/null @@ -1,397 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseMessage.Builder.class) -public final class BaseMessage implements IBaseMessage { - private final Optional> data; - - private final Optional brandId; - - private final Optional> channels; - - private final Optional context; - - private final Optional metadata; - - private final Optional preferences; - - private final Optional> providers; - - private final Optional routing; - - private final Optional timeout; - - private final Optional delay; - - private final Optional expiry; - - private final Map additionalProperties; - - private BaseMessage( - Optional> data, - Optional brandId, - Optional> channels, - Optional context, - Optional metadata, - Optional preferences, - Optional> providers, - Optional routing, - Optional timeout, - Optional delay, - Optional expiry, - Map additionalProperties) { - this.data = data; - this.brandId = brandId; - this.channels = channels; - this.context = context; - this.metadata = metadata; - this.preferences = preferences; - this.providers = providers; - this.routing = routing; - this.timeout = timeout; - this.delay = delay; - this.expiry = expiry; - this.additionalProperties = additionalProperties; - } - - /** - * @return An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("brand_id") - @java.lang.Override - public Optional getBrandId() { - return brandId; - } - - /** - * @return "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - /** - * @return Context to load with this recipient. Will override any context set on message.context. - */ - @JsonProperty("context") - @java.lang.Override - public Optional getContext() { - return context; - } - - /** - * @return Metadata such as utm tracking attached with the notification through this channel. - */ - @JsonProperty("metadata") - @java.lang.Override - public Optional getMetadata() { - return metadata; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - /** - * @return An object whose keys are valid provider identifiers which map to an object. - */ - @JsonProperty("providers") - @java.lang.Override - public Optional> getProviders() { - return providers; - } - - @JsonProperty("routing") - @java.lang.Override - public Optional getRouting() { - return routing; - } - - /** - * @return Time in ms to attempt the channel before failing over to the next available channel. - */ - @JsonProperty("timeout") - @java.lang.Override - public Optional getTimeout() { - return timeout; - } - - /** - * @return Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm') - */ - @JsonProperty("delay") - @java.lang.Override - public Optional getDelay() { - return delay; - } - - /** - * @return "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - @JsonProperty("expiry") - @java.lang.Override - public Optional getExpiry() { - return expiry; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseMessage && equalTo((BaseMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseMessage other) { - return data.equals(other.data) - && brandId.equals(other.brandId) - && channels.equals(other.channels) - && context.equals(other.context) - && metadata.equals(other.metadata) - && preferences.equals(other.preferences) - && providers.equals(other.providers) - && routing.equals(other.routing) - && timeout.equals(other.timeout) - && delay.equals(other.delay) - && expiry.equals(other.expiry); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.data, - this.brandId, - this.channels, - this.context, - this.metadata, - this.preferences, - this.providers, - this.routing, - this.timeout, - this.delay, - this.expiry); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> data = Optional.empty(); - - private Optional brandId = Optional.empty(); - - private Optional> channels = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional metadata = Optional.empty(); - - private Optional preferences = Optional.empty(); - - private Optional> providers = Optional.empty(); - - private Optional routing = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private Optional delay = Optional.empty(); - - private Optional expiry = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BaseMessage other) { - data(other.getData()); - brandId(other.getBrandId()); - channels(other.getChannels()); - context(other.getContext()); - metadata(other.getMetadata()); - preferences(other.getPreferences()); - providers(other.getProviders()); - routing(other.getRouting()); - timeout(other.getTimeout()); - delay(other.getDelay()); - expiry(other.getExpiry()); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public Builder brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - public Builder brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public Builder channels(Optional> channels) { - this.channels = channels; - return this; - } - - public Builder channels(Map channels) { - this.channels = Optional.of(channels); - return this; - } - - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public Builder context(Optional context) { - this.context = context; - return this; - } - - public Builder context(MessageContext context) { - this.context = Optional.of(context); - return this; - } - - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public Builder metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - public Builder metadata(MessageMetadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public Builder preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - public Builder preferences(MessagePreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public Builder providers(Optional> providers) { - this.providers = providers; - return this; - } - - public Builder providers(Map providers) { - this.providers = Optional.of(providers); - return this; - } - - @JsonSetter(value = "routing", nulls = Nulls.SKIP) - public Builder routing(Optional routing) { - this.routing = routing; - return this; - } - - public Builder routing(Routing routing) { - this.routing = Optional.of(routing); - return this; - } - - @JsonSetter(value = "timeout", nulls = Nulls.SKIP) - public Builder timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - public Builder timeout(Timeout timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - @JsonSetter(value = "delay", nulls = Nulls.SKIP) - public Builder delay(Optional delay) { - this.delay = delay; - return this; - } - - public Builder delay(Delay delay) { - this.delay = Optional.of(delay); - return this; - } - - @JsonSetter(value = "expiry", nulls = Nulls.SKIP) - public Builder expiry(Optional expiry) { - this.expiry = expiry; - return this; - } - - public Builder expiry(Expiry expiry) { - this.expiry = Optional.of(expiry); - return this; - } - - public BaseMessage build() { - return new BaseMessage( - data, - brandId, - channels, - context, - metadata, - preferences, - providers, - routing, - timeout, - delay, - expiry, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BaseMessageSendTo.java b/src/main/java/com/courier/api/resources/send/types/BaseMessageSendTo.java deleted file mode 100644 index 3a4524e0..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BaseMessageSendTo.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseMessageSendTo.Builder.class) -public final class BaseMessageSendTo implements IBaseMessageSendTo { - private final Optional to; - - private final Map additionalProperties; - - private BaseMessageSendTo(Optional to, Map additionalProperties) { - this.to = to; - this.additionalProperties = additionalProperties; - } - - /** - * @return The recipient or a list of recipients of the message - */ - @JsonProperty("to") - @java.lang.Override - public Optional getTo() { - return to; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseMessageSendTo && equalTo((BaseMessageSendTo) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseMessageSendTo other) { - return to.equals(other.to); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.to); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional to = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BaseMessageSendTo other) { - to(other.getTo()); - return this; - } - - @JsonSetter(value = "to", nulls = Nulls.SKIP) - public Builder to(Optional to) { - this.to = to; - return this; - } - - public Builder to(MessageRecipient to) { - this.to = Optional.of(to); - return this; - } - - public BaseMessageSendTo build() { - return new BaseMessageSendTo(to, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BaseSocialPresence.java b/src/main/java/com/courier/api/resources/send/types/BaseSocialPresence.java deleted file mode 100644 index c9a24cbd..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BaseSocialPresence.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BaseSocialPresence.Builder.class) -public final class BaseSocialPresence { - private final String url; - - private final Map additionalProperties; - - private BaseSocialPresence(String url, Map additionalProperties) { - this.url = url; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("url") - public String getUrl() { - return url; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BaseSocialPresence && equalTo((BaseSocialPresence) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BaseSocialPresence other) { - return url.equals(other.url); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.url); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UrlStage builder() { - return new Builder(); - } - - public interface UrlStage { - _FinalStage url(String url); - - Builder from(BaseSocialPresence other); - } - - public interface _FinalStage { - BaseSocialPresence build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UrlStage, _FinalStage { - private String url; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BaseSocialPresence other) { - url(other.getUrl()); - return this; - } - - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - @java.lang.Override - public BaseSocialPresence build() { - return new BaseSocialPresence(url, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BrandSettingsEmail.java b/src/main/java/com/courier/api/resources/send/types/BrandSettingsEmail.java deleted file mode 100644 index c80f75bb..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BrandSettingsEmail.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandSettingsEmail.Builder.class) -public final class BrandSettingsEmail { - private final Optional templateOverride; - - private final Optional head; - - private final Optional footer; - - private final Optional header; - - private final Map additionalProperties; - - private BrandSettingsEmail( - Optional templateOverride, - Optional head, - Optional footer, - Optional header, - Map additionalProperties) { - this.templateOverride = templateOverride; - this.head = head; - this.footer = footer; - this.header = header; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("templateOverride") - public Optional getTemplateOverride() { - return templateOverride; - } - - @JsonProperty("head") - public Optional getHead() { - return head; - } - - @JsonProperty("footer") - public Optional getFooter() { - return footer; - } - - @JsonProperty("header") - public Optional getHeader() { - return header; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandSettingsEmail && equalTo((BrandSettingsEmail) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandSettingsEmail other) { - return templateOverride.equals(other.templateOverride) - && head.equals(other.head) - && footer.equals(other.footer) - && header.equals(other.header); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.templateOverride, this.head, this.footer, this.header); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional templateOverride = Optional.empty(); - - private Optional head = Optional.empty(); - - private Optional footer = Optional.empty(); - - private Optional header = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BrandSettingsEmail other) { - templateOverride(other.getTemplateOverride()); - head(other.getHead()); - footer(other.getFooter()); - header(other.getHeader()); - return this; - } - - @JsonSetter(value = "templateOverride", nulls = Nulls.SKIP) - public Builder templateOverride(Optional templateOverride) { - this.templateOverride = templateOverride; - return this; - } - - public Builder templateOverride(BrandTemplateOverride templateOverride) { - this.templateOverride = Optional.of(templateOverride); - return this; - } - - @JsonSetter(value = "head", nulls = Nulls.SKIP) - public Builder head(Optional head) { - this.head = head; - return this; - } - - public Builder head(EmailHead head) { - this.head = Optional.of(head); - return this; - } - - @JsonSetter(value = "footer", nulls = Nulls.SKIP) - public Builder footer(Optional footer) { - this.footer = footer; - return this; - } - - public Builder footer(EmailFooter footer) { - this.footer = Optional.of(footer); - return this; - } - - @JsonSetter(value = "header", nulls = Nulls.SKIP) - public Builder header(Optional header) { - this.header = header; - return this; - } - - public Builder header(EmailHeader header) { - this.header = Optional.of(header); - return this; - } - - public BrandSettingsEmail build() { - return new BrandSettingsEmail(templateOverride, head, footer, header, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BrandSettingsInApp.java b/src/main/java/com/courier/api/resources/send/types/BrandSettingsInApp.java deleted file mode 100644 index e8f019e2..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BrandSettingsInApp.java +++ /dev/null @@ -1,316 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.brands.types.BrandColors; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandSettingsInApp.Builder.class) -public final class BrandSettingsInApp { - private final Optional borderRadius; - - private final Optional disableMessageIcon; - - private final Optional fontFamily; - - private final Optional placement; - - private final WidgetBackground widgetBackground; - - private final BrandColors colors; - - private final Icons icons; - - private final Preferences preferences; - - private final Map additionalProperties; - - private BrandSettingsInApp( - Optional borderRadius, - Optional disableMessageIcon, - Optional fontFamily, - Optional placement, - WidgetBackground widgetBackground, - BrandColors colors, - Icons icons, - Preferences preferences, - Map additionalProperties) { - this.borderRadius = borderRadius; - this.disableMessageIcon = disableMessageIcon; - this.fontFamily = fontFamily; - this.placement = placement; - this.widgetBackground = widgetBackground; - this.colors = colors; - this.icons = icons; - this.preferences = preferences; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("borderRadius") - public Optional getBorderRadius() { - return borderRadius; - } - - @JsonProperty("disableMessageIcon") - public Optional getDisableMessageIcon() { - return disableMessageIcon; - } - - @JsonProperty("fontFamily") - public Optional getFontFamily() { - return fontFamily; - } - - @JsonProperty("placement") - public Optional getPlacement() { - return placement; - } - - @JsonProperty("widgetBackground") - public WidgetBackground getWidgetBackground() { - return widgetBackground; - } - - @JsonProperty("colors") - public BrandColors getColors() { - return colors; - } - - @JsonProperty("icons") - public Icons getIcons() { - return icons; - } - - @JsonProperty("preferences") - public Preferences getPreferences() { - return preferences; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandSettingsInApp && equalTo((BrandSettingsInApp) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandSettingsInApp other) { - return borderRadius.equals(other.borderRadius) - && disableMessageIcon.equals(other.disableMessageIcon) - && fontFamily.equals(other.fontFamily) - && placement.equals(other.placement) - && widgetBackground.equals(other.widgetBackground) - && colors.equals(other.colors) - && icons.equals(other.icons) - && preferences.equals(other.preferences); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.borderRadius, - this.disableMessageIcon, - this.fontFamily, - this.placement, - this.widgetBackground, - this.colors, - this.icons, - this.preferences); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static WidgetBackgroundStage builder() { - return new Builder(); - } - - public interface WidgetBackgroundStage { - ColorsStage widgetBackground(WidgetBackground widgetBackground); - - Builder from(BrandSettingsInApp other); - } - - public interface ColorsStage { - IconsStage colors(BrandColors colors); - } - - public interface IconsStage { - PreferencesStage icons(Icons icons); - } - - public interface PreferencesStage { - _FinalStage preferences(Preferences preferences); - } - - public interface _FinalStage { - BrandSettingsInApp build(); - - _FinalStage borderRadius(Optional borderRadius); - - _FinalStage borderRadius(String borderRadius); - - _FinalStage disableMessageIcon(Optional disableMessageIcon); - - _FinalStage disableMessageIcon(Boolean disableMessageIcon); - - _FinalStage fontFamily(Optional fontFamily); - - _FinalStage fontFamily(String fontFamily); - - _FinalStage placement(Optional placement); - - _FinalStage placement(InAppPlacement placement); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements WidgetBackgroundStage, ColorsStage, IconsStage, PreferencesStage, _FinalStage { - private WidgetBackground widgetBackground; - - private BrandColors colors; - - private Icons icons; - - private Preferences preferences; - - private Optional placement = Optional.empty(); - - private Optional fontFamily = Optional.empty(); - - private Optional disableMessageIcon = Optional.empty(); - - private Optional borderRadius = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandSettingsInApp other) { - borderRadius(other.getBorderRadius()); - disableMessageIcon(other.getDisableMessageIcon()); - fontFamily(other.getFontFamily()); - placement(other.getPlacement()); - widgetBackground(other.getWidgetBackground()); - colors(other.getColors()); - icons(other.getIcons()); - preferences(other.getPreferences()); - return this; - } - - @java.lang.Override - @JsonSetter("widgetBackground") - public ColorsStage widgetBackground(WidgetBackground widgetBackground) { - this.widgetBackground = widgetBackground; - return this; - } - - @java.lang.Override - @JsonSetter("colors") - public IconsStage colors(BrandColors colors) { - this.colors = colors; - return this; - } - - @java.lang.Override - @JsonSetter("icons") - public PreferencesStage icons(Icons icons) { - this.icons = icons; - return this; - } - - @java.lang.Override - @JsonSetter("preferences") - public _FinalStage preferences(Preferences preferences) { - this.preferences = preferences; - return this; - } - - @java.lang.Override - public _FinalStage placement(InAppPlacement placement) { - this.placement = Optional.of(placement); - return this; - } - - @java.lang.Override - @JsonSetter(value = "placement", nulls = Nulls.SKIP) - public _FinalStage placement(Optional placement) { - this.placement = placement; - return this; - } - - @java.lang.Override - public _FinalStage fontFamily(String fontFamily) { - this.fontFamily = Optional.of(fontFamily); - return this; - } - - @java.lang.Override - @JsonSetter(value = "fontFamily", nulls = Nulls.SKIP) - public _FinalStage fontFamily(Optional fontFamily) { - this.fontFamily = fontFamily; - return this; - } - - @java.lang.Override - public _FinalStage disableMessageIcon(Boolean disableMessageIcon) { - this.disableMessageIcon = Optional.of(disableMessageIcon); - return this; - } - - @java.lang.Override - @JsonSetter(value = "disableMessageIcon", nulls = Nulls.SKIP) - public _FinalStage disableMessageIcon(Optional disableMessageIcon) { - this.disableMessageIcon = disableMessageIcon; - return this; - } - - @java.lang.Override - public _FinalStage borderRadius(String borderRadius) { - this.borderRadius = Optional.of(borderRadius); - return this; - } - - @java.lang.Override - @JsonSetter(value = "borderRadius", nulls = Nulls.SKIP) - public _FinalStage borderRadius(Optional borderRadius) { - this.borderRadius = borderRadius; - return this; - } - - @java.lang.Override - public BrandSettingsInApp build() { - return new BrandSettingsInApp( - borderRadius, - disableMessageIcon, - fontFamily, - placement, - widgetBackground, - colors, - icons, - preferences, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BrandSettingsSocialPresence.java b/src/main/java/com/courier/api/resources/send/types/BrandSettingsSocialPresence.java deleted file mode 100644 index b924f649..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BrandSettingsSocialPresence.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandSettingsSocialPresence.Builder.class) -public final class BrandSettingsSocialPresence { - private final Optional inheritDefault; - - private final Optional facebook; - - private final Optional instagram; - - private final Optional linkedin; - - private final Optional medium; - - private final Optional twitter; - - private final Map additionalProperties; - - private BrandSettingsSocialPresence( - Optional inheritDefault, - Optional facebook, - Optional instagram, - Optional linkedin, - Optional medium, - Optional twitter, - Map additionalProperties) { - this.inheritDefault = inheritDefault; - this.facebook = facebook; - this.instagram = instagram; - this.linkedin = linkedin; - this.medium = medium; - this.twitter = twitter; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("inheritDefault") - public Optional getInheritDefault() { - return inheritDefault; - } - - @JsonProperty("facebook") - public Optional getFacebook() { - return facebook; - } - - @JsonProperty("instagram") - public Optional getInstagram() { - return instagram; - } - - @JsonProperty("linkedin") - public Optional getLinkedin() { - return linkedin; - } - - @JsonProperty("medium") - public Optional getMedium() { - return medium; - } - - @JsonProperty("twitter") - public Optional getTwitter() { - return twitter; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandSettingsSocialPresence && equalTo((BrandSettingsSocialPresence) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandSettingsSocialPresence other) { - return inheritDefault.equals(other.inheritDefault) - && facebook.equals(other.facebook) - && instagram.equals(other.instagram) - && linkedin.equals(other.linkedin) - && medium.equals(other.medium) - && twitter.equals(other.twitter); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.inheritDefault, this.facebook, this.instagram, this.linkedin, this.medium, this.twitter); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional inheritDefault = Optional.empty(); - - private Optional facebook = Optional.empty(); - - private Optional instagram = Optional.empty(); - - private Optional linkedin = Optional.empty(); - - private Optional medium = Optional.empty(); - - private Optional twitter = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(BrandSettingsSocialPresence other) { - inheritDefault(other.getInheritDefault()); - facebook(other.getFacebook()); - instagram(other.getInstagram()); - linkedin(other.getLinkedin()); - medium(other.getMedium()); - twitter(other.getTwitter()); - return this; - } - - @JsonSetter(value = "inheritDefault", nulls = Nulls.SKIP) - public Builder inheritDefault(Optional inheritDefault) { - this.inheritDefault = inheritDefault; - return this; - } - - public Builder inheritDefault(Boolean inheritDefault) { - this.inheritDefault = Optional.of(inheritDefault); - return this; - } - - @JsonSetter(value = "facebook", nulls = Nulls.SKIP) - public Builder facebook(Optional facebook) { - this.facebook = facebook; - return this; - } - - public Builder facebook(BaseSocialPresence facebook) { - this.facebook = Optional.of(facebook); - return this; - } - - @JsonSetter(value = "instagram", nulls = Nulls.SKIP) - public Builder instagram(Optional instagram) { - this.instagram = instagram; - return this; - } - - public Builder instagram(BaseSocialPresence instagram) { - this.instagram = Optional.of(instagram); - return this; - } - - @JsonSetter(value = "linkedin", nulls = Nulls.SKIP) - public Builder linkedin(Optional linkedin) { - this.linkedin = linkedin; - return this; - } - - public Builder linkedin(BaseSocialPresence linkedin) { - this.linkedin = Optional.of(linkedin); - return this; - } - - @JsonSetter(value = "medium", nulls = Nulls.SKIP) - public Builder medium(Optional medium) { - this.medium = medium; - return this; - } - - public Builder medium(BaseSocialPresence medium) { - this.medium = Optional.of(medium); - return this; - } - - @JsonSetter(value = "twitter", nulls = Nulls.SKIP) - public Builder twitter(Optional twitter) { - this.twitter = twitter; - return this; - } - - public Builder twitter(BaseSocialPresence twitter) { - this.twitter = Optional.of(twitter); - return this; - } - - public BrandSettingsSocialPresence build() { - return new BrandSettingsSocialPresence( - inheritDefault, facebook, instagram, linkedin, medium, twitter, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BrandTemplate.java b/src/main/java/com/courier/api/resources/send/types/BrandTemplate.java deleted file mode 100644 index 47c50aa5..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BrandTemplate.java +++ /dev/null @@ -1,300 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandTemplate.Builder.class) -public final class BrandTemplate implements IBrandTemplate { - private final Optional backgroundColor; - - private final Optional blocksBackgroundColor; - - private final boolean enabled; - - private final Optional footer; - - private final Optional head; - - private final Optional header; - - private final Optional width; - - private final Map additionalProperties; - - private BrandTemplate( - Optional backgroundColor, - Optional blocksBackgroundColor, - boolean enabled, - Optional footer, - Optional head, - Optional header, - Optional width, - Map additionalProperties) { - this.backgroundColor = backgroundColor; - this.blocksBackgroundColor = blocksBackgroundColor; - this.enabled = enabled; - this.footer = footer; - this.head = head; - this.header = header; - this.width = width; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("backgroundColor") - @java.lang.Override - public Optional getBackgroundColor() { - return backgroundColor; - } - - @JsonProperty("blocksBackgroundColor") - @java.lang.Override - public Optional getBlocksBackgroundColor() { - return blocksBackgroundColor; - } - - @JsonProperty("enabled") - @java.lang.Override - public boolean getEnabled() { - return enabled; - } - - @JsonProperty("footer") - @java.lang.Override - public Optional getFooter() { - return footer; - } - - @JsonProperty("head") - @java.lang.Override - public Optional getHead() { - return head; - } - - @JsonProperty("header") - @java.lang.Override - public Optional getHeader() { - return header; - } - - @JsonProperty("width") - @java.lang.Override - public Optional getWidth() { - return width; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandTemplate && equalTo((BrandTemplate) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandTemplate other) { - return backgroundColor.equals(other.backgroundColor) - && blocksBackgroundColor.equals(other.blocksBackgroundColor) - && enabled == other.enabled - && footer.equals(other.footer) - && head.equals(other.head) - && header.equals(other.header) - && width.equals(other.width); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.backgroundColor, - this.blocksBackgroundColor, - this.enabled, - this.footer, - this.head, - this.header, - this.width); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static EnabledStage builder() { - return new Builder(); - } - - public interface EnabledStage { - _FinalStage enabled(boolean enabled); - - Builder from(BrandTemplate other); - } - - public interface _FinalStage { - BrandTemplate build(); - - _FinalStage backgroundColor(Optional backgroundColor); - - _FinalStage backgroundColor(String backgroundColor); - - _FinalStage blocksBackgroundColor(Optional blocksBackgroundColor); - - _FinalStage blocksBackgroundColor(String blocksBackgroundColor); - - _FinalStage footer(Optional footer); - - _FinalStage footer(String footer); - - _FinalStage head(Optional head); - - _FinalStage head(String head); - - _FinalStage header(Optional header); - - _FinalStage header(String header); - - _FinalStage width(Optional width); - - _FinalStage width(String width); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements EnabledStage, _FinalStage { - private boolean enabled; - - private Optional width = Optional.empty(); - - private Optional header = Optional.empty(); - - private Optional head = Optional.empty(); - - private Optional footer = Optional.empty(); - - private Optional blocksBackgroundColor = Optional.empty(); - - private Optional backgroundColor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandTemplate other) { - backgroundColor(other.getBackgroundColor()); - blocksBackgroundColor(other.getBlocksBackgroundColor()); - enabled(other.getEnabled()); - footer(other.getFooter()); - head(other.getHead()); - header(other.getHeader()); - width(other.getWidth()); - return this; - } - - @java.lang.Override - @JsonSetter("enabled") - public _FinalStage enabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - @java.lang.Override - public _FinalStage width(String width) { - this.width = Optional.of(width); - return this; - } - - @java.lang.Override - @JsonSetter(value = "width", nulls = Nulls.SKIP) - public _FinalStage width(Optional width) { - this.width = width; - return this; - } - - @java.lang.Override - public _FinalStage header(String header) { - this.header = Optional.of(header); - return this; - } - - @java.lang.Override - @JsonSetter(value = "header", nulls = Nulls.SKIP) - public _FinalStage header(Optional header) { - this.header = header; - return this; - } - - @java.lang.Override - public _FinalStage head(String head) { - this.head = Optional.of(head); - return this; - } - - @java.lang.Override - @JsonSetter(value = "head", nulls = Nulls.SKIP) - public _FinalStage head(Optional head) { - this.head = head; - return this; - } - - @java.lang.Override - public _FinalStage footer(String footer) { - this.footer = Optional.of(footer); - return this; - } - - @java.lang.Override - @JsonSetter(value = "footer", nulls = Nulls.SKIP) - public _FinalStage footer(Optional footer) { - this.footer = footer; - return this; - } - - @java.lang.Override - public _FinalStage blocksBackgroundColor(String blocksBackgroundColor) { - this.blocksBackgroundColor = Optional.of(blocksBackgroundColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "blocksBackgroundColor", nulls = Nulls.SKIP) - public _FinalStage blocksBackgroundColor(Optional blocksBackgroundColor) { - this.blocksBackgroundColor = blocksBackgroundColor; - return this; - } - - @java.lang.Override - public _FinalStage backgroundColor(String backgroundColor) { - this.backgroundColor = Optional.of(backgroundColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "backgroundColor", nulls = Nulls.SKIP) - public _FinalStage backgroundColor(Optional backgroundColor) { - this.backgroundColor = backgroundColor; - return this; - } - - @java.lang.Override - public BrandTemplate build() { - return new BrandTemplate( - backgroundColor, blocksBackgroundColor, enabled, footer, head, header, width, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/BrandTemplateOverride.java b/src/main/java/com/courier/api/resources/send/types/BrandTemplateOverride.java deleted file mode 100644 index 6c641ed5..00000000 --- a/src/main/java/com/courier/api/resources/send/types/BrandTemplateOverride.java +++ /dev/null @@ -1,397 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = BrandTemplateOverride.Builder.class) -public final class BrandTemplateOverride implements IBrandTemplate { - private final Optional backgroundColor; - - private final Optional blocksBackgroundColor; - - private final boolean enabled; - - private final Optional footer; - - private final Optional head; - - private final Optional header; - - private final Optional width; - - private final BrandTemplate mjml; - - private final Optional footerBackgroundColor; - - private final Optional footerFullWidth; - - private final Map additionalProperties; - - private BrandTemplateOverride( - Optional backgroundColor, - Optional blocksBackgroundColor, - boolean enabled, - Optional footer, - Optional head, - Optional header, - Optional width, - BrandTemplate mjml, - Optional footerBackgroundColor, - Optional footerFullWidth, - Map additionalProperties) { - this.backgroundColor = backgroundColor; - this.blocksBackgroundColor = blocksBackgroundColor; - this.enabled = enabled; - this.footer = footer; - this.head = head; - this.header = header; - this.width = width; - this.mjml = mjml; - this.footerBackgroundColor = footerBackgroundColor; - this.footerFullWidth = footerFullWidth; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("backgroundColor") - @java.lang.Override - public Optional getBackgroundColor() { - return backgroundColor; - } - - @JsonProperty("blocksBackgroundColor") - @java.lang.Override - public Optional getBlocksBackgroundColor() { - return blocksBackgroundColor; - } - - @JsonProperty("enabled") - @java.lang.Override - public boolean getEnabled() { - return enabled; - } - - @JsonProperty("footer") - @java.lang.Override - public Optional getFooter() { - return footer; - } - - @JsonProperty("head") - @java.lang.Override - public Optional getHead() { - return head; - } - - @JsonProperty("header") - @java.lang.Override - public Optional getHeader() { - return header; - } - - @JsonProperty("width") - @java.lang.Override - public Optional getWidth() { - return width; - } - - @JsonProperty("mjml") - public BrandTemplate getMjml() { - return mjml; - } - - @JsonProperty("footerBackgroundColor") - public Optional getFooterBackgroundColor() { - return footerBackgroundColor; - } - - @JsonProperty("footerFullWidth") - public Optional getFooterFullWidth() { - return footerFullWidth; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof BrandTemplateOverride && equalTo((BrandTemplateOverride) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(BrandTemplateOverride other) { - return backgroundColor.equals(other.backgroundColor) - && blocksBackgroundColor.equals(other.blocksBackgroundColor) - && enabled == other.enabled - && footer.equals(other.footer) - && head.equals(other.head) - && header.equals(other.header) - && width.equals(other.width) - && mjml.equals(other.mjml) - && footerBackgroundColor.equals(other.footerBackgroundColor) - && footerFullWidth.equals(other.footerFullWidth); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.backgroundColor, - this.blocksBackgroundColor, - this.enabled, - this.footer, - this.head, - this.header, - this.width, - this.mjml, - this.footerBackgroundColor, - this.footerFullWidth); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static EnabledStage builder() { - return new Builder(); - } - - public interface EnabledStage { - MjmlStage enabled(boolean enabled); - - Builder from(BrandTemplateOverride other); - } - - public interface MjmlStage { - _FinalStage mjml(BrandTemplate mjml); - } - - public interface _FinalStage { - BrandTemplateOverride build(); - - _FinalStage backgroundColor(Optional backgroundColor); - - _FinalStage backgroundColor(String backgroundColor); - - _FinalStage blocksBackgroundColor(Optional blocksBackgroundColor); - - _FinalStage blocksBackgroundColor(String blocksBackgroundColor); - - _FinalStage footer(Optional footer); - - _FinalStage footer(String footer); - - _FinalStage head(Optional head); - - _FinalStage head(String head); - - _FinalStage header(Optional header); - - _FinalStage header(String header); - - _FinalStage width(Optional width); - - _FinalStage width(String width); - - _FinalStage footerBackgroundColor(Optional footerBackgroundColor); - - _FinalStage footerBackgroundColor(String footerBackgroundColor); - - _FinalStage footerFullWidth(Optional footerFullWidth); - - _FinalStage footerFullWidth(Boolean footerFullWidth); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements EnabledStage, MjmlStage, _FinalStage { - private boolean enabled; - - private BrandTemplate mjml; - - private Optional footerFullWidth = Optional.empty(); - - private Optional footerBackgroundColor = Optional.empty(); - - private Optional width = Optional.empty(); - - private Optional header = Optional.empty(); - - private Optional head = Optional.empty(); - - private Optional footer = Optional.empty(); - - private Optional blocksBackgroundColor = Optional.empty(); - - private Optional backgroundColor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(BrandTemplateOverride other) { - backgroundColor(other.getBackgroundColor()); - blocksBackgroundColor(other.getBlocksBackgroundColor()); - enabled(other.getEnabled()); - footer(other.getFooter()); - head(other.getHead()); - header(other.getHeader()); - width(other.getWidth()); - mjml(other.getMjml()); - footerBackgroundColor(other.getFooterBackgroundColor()); - footerFullWidth(other.getFooterFullWidth()); - return this; - } - - @java.lang.Override - @JsonSetter("enabled") - public MjmlStage enabled(boolean enabled) { - this.enabled = enabled; - return this; - } - - @java.lang.Override - @JsonSetter("mjml") - public _FinalStage mjml(BrandTemplate mjml) { - this.mjml = mjml; - return this; - } - - @java.lang.Override - public _FinalStage footerFullWidth(Boolean footerFullWidth) { - this.footerFullWidth = Optional.of(footerFullWidth); - return this; - } - - @java.lang.Override - @JsonSetter(value = "footerFullWidth", nulls = Nulls.SKIP) - public _FinalStage footerFullWidth(Optional footerFullWidth) { - this.footerFullWidth = footerFullWidth; - return this; - } - - @java.lang.Override - public _FinalStage footerBackgroundColor(String footerBackgroundColor) { - this.footerBackgroundColor = Optional.of(footerBackgroundColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "footerBackgroundColor", nulls = Nulls.SKIP) - public _FinalStage footerBackgroundColor(Optional footerBackgroundColor) { - this.footerBackgroundColor = footerBackgroundColor; - return this; - } - - @java.lang.Override - public _FinalStage width(String width) { - this.width = Optional.of(width); - return this; - } - - @java.lang.Override - @JsonSetter(value = "width", nulls = Nulls.SKIP) - public _FinalStage width(Optional width) { - this.width = width; - return this; - } - - @java.lang.Override - public _FinalStage header(String header) { - this.header = Optional.of(header); - return this; - } - - @java.lang.Override - @JsonSetter(value = "header", nulls = Nulls.SKIP) - public _FinalStage header(Optional header) { - this.header = header; - return this; - } - - @java.lang.Override - public _FinalStage head(String head) { - this.head = Optional.of(head); - return this; - } - - @java.lang.Override - @JsonSetter(value = "head", nulls = Nulls.SKIP) - public _FinalStage head(Optional head) { - this.head = head; - return this; - } - - @java.lang.Override - public _FinalStage footer(String footer) { - this.footer = Optional.of(footer); - return this; - } - - @java.lang.Override - @JsonSetter(value = "footer", nulls = Nulls.SKIP) - public _FinalStage footer(Optional footer) { - this.footer = footer; - return this; - } - - @java.lang.Override - public _FinalStage blocksBackgroundColor(String blocksBackgroundColor) { - this.blocksBackgroundColor = Optional.of(blocksBackgroundColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "blocksBackgroundColor", nulls = Nulls.SKIP) - public _FinalStage blocksBackgroundColor(Optional blocksBackgroundColor) { - this.blocksBackgroundColor = blocksBackgroundColor; - return this; - } - - @java.lang.Override - public _FinalStage backgroundColor(String backgroundColor) { - this.backgroundColor = Optional.of(backgroundColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "backgroundColor", nulls = Nulls.SKIP) - public _FinalStage backgroundColor(Optional backgroundColor) { - this.backgroundColor = backgroundColor; - return this; - } - - @java.lang.Override - public BrandTemplateOverride build() { - return new BrandTemplateOverride( - backgroundColor, - blocksBackgroundColor, - enabled, - footer, - head, - header, - width, - mjml, - footerBackgroundColor, - footerFullWidth, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Channel.java b/src/main/java/com/courier/api/resources/send/types/Channel.java deleted file mode 100644 index 6dd26f4a..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Channel.java +++ /dev/null @@ -1,272 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Channel.Builder.class) -public final class Channel { - private final Optional brandId; - - private final Optional> providers; - - private final Optional routingMethod; - - private final Optional if_; - - private final Optional timeouts; - - private final Optional> override; - - private final Optional metadata; - - private final Map additionalProperties; - - private Channel( - Optional brandId, - Optional> providers, - Optional routingMethod, - Optional if_, - Optional timeouts, - Optional> override, - Optional metadata, - Map additionalProperties) { - this.brandId = brandId; - this.providers = providers; - this.routingMethod = routingMethod; - this.if_ = if_; - this.timeouts = timeouts; - this.override = override; - this.metadata = metadata; - this.additionalProperties = additionalProperties; - } - - /** - * @return Id of the brand that should be used for rendering the message. - * If not specified, the brand configured as default brand will be used. - */ - @JsonProperty("brand_id") - public Optional getBrandId() { - return brandId; - } - - /** - * @return A list of providers enabled for this channel. Courier will select - * one provider to send through unless routing_method is set to all. - */ - @JsonProperty("providers") - public Optional> getProviders() { - return providers; - } - - /** - * @return The method for selecting the providers to send the message with. - * Single will send to one of the available providers for this channel, - * all will send the message through all channels. Defaults to single. - */ - @JsonProperty("routing_method") - public Optional getRoutingMethod() { - return routingMethod; - } - - /** - * @return A JavaScript conditional expression to determine if the message should - * be sent through the channel. Has access to the data and profile object. - * Only applies when a custom routing strategy is defined. - * For example, data.name === profile.name - */ - @JsonProperty("if") - public Optional getIf() { - return if_; - } - - @JsonProperty("timeouts") - public Optional getTimeouts() { - return timeouts; - } - - /** - * @return Channel specific overrides. - */ - @JsonProperty("override") - public Optional> getOverride() { - return override; - } - - @JsonProperty("metadata") - public Optional getMetadata() { - return metadata; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Channel && equalTo((Channel) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Channel other) { - return brandId.equals(other.brandId) - && providers.equals(other.providers) - && routingMethod.equals(other.routingMethod) - && if_.equals(other.if_) - && timeouts.equals(other.timeouts) - && override.equals(other.override) - && metadata.equals(other.metadata); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.brandId, - this.providers, - this.routingMethod, - this.if_, - this.timeouts, - this.override, - this.metadata); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional brandId = Optional.empty(); - - private Optional> providers = Optional.empty(); - - private Optional routingMethod = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional timeouts = Optional.empty(); - - private Optional> override = Optional.empty(); - - private Optional metadata = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Channel other) { - brandId(other.getBrandId()); - providers(other.getProviders()); - routingMethod(other.getRoutingMethod()); - if_(other.getIf()); - timeouts(other.getTimeouts()); - override(other.getOverride()); - metadata(other.getMetadata()); - return this; - } - - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public Builder brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - public Builder brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public Builder providers(Optional> providers) { - this.providers = providers; - return this; - } - - public Builder providers(List providers) { - this.providers = Optional.of(providers); - return this; - } - - @JsonSetter(value = "routing_method", nulls = Nulls.SKIP) - public Builder routingMethod(Optional routingMethod) { - this.routingMethod = routingMethod; - return this; - } - - public Builder routingMethod(RoutingMethod routingMethod) { - this.routingMethod = Optional.of(routingMethod); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "timeouts", nulls = Nulls.SKIP) - public Builder timeouts(Optional timeouts) { - this.timeouts = timeouts; - return this; - } - - public Builder timeouts(Timeouts timeouts) { - this.timeouts = Optional.of(timeouts); - return this; - } - - @JsonSetter(value = "override", nulls = Nulls.SKIP) - public Builder override(Optional> override) { - this.override = override; - return this; - } - - public Builder override(Map override) { - this.override = Optional.of(override); - return this; - } - - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public Builder metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - public Builder metadata(ChannelMetadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - public Channel build() { - return new Channel( - brandId, providers, routingMethod, if_, timeouts, override, metadata, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ChannelMetadata.java b/src/main/java/com/courier/api/resources/send/types/ChannelMetadata.java deleted file mode 100644 index 5593855c..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ChannelMetadata.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ChannelMetadata.Builder.class) -public final class ChannelMetadata { - private final Optional utm; - - private final Map additionalProperties; - - private ChannelMetadata(Optional utm, Map additionalProperties) { - this.utm = utm; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("utm") - public Optional getUtm() { - return utm; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChannelMetadata && equalTo((ChannelMetadata) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ChannelMetadata other) { - return utm.equals(other.utm); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.utm); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional utm = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ChannelMetadata other) { - utm(other.getUtm()); - return this; - } - - @JsonSetter(value = "utm", nulls = Nulls.SKIP) - public Builder utm(Optional utm) { - this.utm = utm; - return this; - } - - public Builder utm(Utm utm) { - this.utm = Optional.of(utm); - return this; - } - - public ChannelMetadata build() { - return new ChannelMetadata(utm, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ChannelSource.java b/src/main/java/com/courier/api/resources/send/types/ChannelSource.java deleted file mode 100644 index cac19679..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ChannelSource.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ChannelSource { - SUBSCRIPTION("subscription"), - - LIST("list"), - - RECIPIENT("recipient"); - - private final String value; - - ChannelSource(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Content.java b/src/main/java/com/courier/api/resources/send/types/Content.java deleted file mode 100644 index aa337eda..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Content.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Content.Deserializer.class) -public final class Content { - private final Object value; - - private final int type; - - private Content(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ElementalContent) this.value); - } else if (this.type == 1) { - return visitor.visit((ElementalContentSugar) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Content && equalTo((Content) other); - } - - private boolean equalTo(Content other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Content of(ElementalContent value) { - return new Content(value, 0); - } - - public static Content of(ElementalContentSugar value) { - return new Content(value, 1); - } - - public interface Visitor { - T visit(ElementalContent value); - - T visit(ElementalContentSugar value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Content.class); - } - - @java.lang.Override - public Content deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ElementalContent.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ElementalContentSugar.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ContentMessage.java b/src/main/java/com/courier/api/resources/send/types/ContentMessage.java deleted file mode 100644 index 12dae4ce..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ContentMessage.java +++ /dev/null @@ -1,580 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ContentMessage.Builder.class) -public final class ContentMessage implements IBaseMessage, IBaseMessageSendTo { - private final Optional> data; - - private final Optional brandId; - - private final Optional> channels; - - private final Optional context; - - private final Optional metadata; - - private final Optional preferences; - - private final Optional> providers; - - private final Optional routing; - - private final Optional timeout; - - private final Optional delay; - - private final Optional expiry; - - private final Optional to; - - private final Content content; - - private final Map additionalProperties; - - private ContentMessage( - Optional> data, - Optional brandId, - Optional> channels, - Optional context, - Optional metadata, - Optional preferences, - Optional> providers, - Optional routing, - Optional timeout, - Optional delay, - Optional expiry, - Optional to, - Content content, - Map additionalProperties) { - this.data = data; - this.brandId = brandId; - this.channels = channels; - this.context = context; - this.metadata = metadata; - this.preferences = preferences; - this.providers = providers; - this.routing = routing; - this.timeout = timeout; - this.delay = delay; - this.expiry = expiry; - this.to = to; - this.content = content; - this.additionalProperties = additionalProperties; - } - - /** - * @return An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("brand_id") - @java.lang.Override - public Optional getBrandId() { - return brandId; - } - - /** - * @return "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - /** - * @return Context to load with this recipient. Will override any context set on message.context. - */ - @JsonProperty("context") - @java.lang.Override - public Optional getContext() { - return context; - } - - /** - * @return Metadata such as utm tracking attached with the notification through this channel. - */ - @JsonProperty("metadata") - @java.lang.Override - public Optional getMetadata() { - return metadata; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - /** - * @return An object whose keys are valid provider identifiers which map to an object. - */ - @JsonProperty("providers") - @java.lang.Override - public Optional> getProviders() { - return providers; - } - - @JsonProperty("routing") - @java.lang.Override - public Optional getRouting() { - return routing; - } - - /** - * @return Time in ms to attempt the channel before failing over to the next available channel. - */ - @JsonProperty("timeout") - @java.lang.Override - public Optional getTimeout() { - return timeout; - } - - /** - * @return Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm') - */ - @JsonProperty("delay") - @java.lang.Override - public Optional getDelay() { - return delay; - } - - /** - * @return "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - @JsonProperty("expiry") - @java.lang.Override - public Optional getExpiry() { - return expiry; - } - - /** - * @return The recipient or a list of recipients of the message - */ - @JsonProperty("to") - @java.lang.Override - public Optional getTo() { - return to; - } - - /** - * @return Describes the content of the message in a way that will work for email, push, - * chat, or any channel. Either this or template must be specified. - */ - @JsonProperty("content") - public Content getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ContentMessage && equalTo((ContentMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ContentMessage other) { - return data.equals(other.data) - && brandId.equals(other.brandId) - && channels.equals(other.channels) - && context.equals(other.context) - && metadata.equals(other.metadata) - && preferences.equals(other.preferences) - && providers.equals(other.providers) - && routing.equals(other.routing) - && timeout.equals(other.timeout) - && delay.equals(other.delay) - && expiry.equals(other.expiry) - && to.equals(other.to) - && content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.data, - this.brandId, - this.channels, - this.context, - this.metadata, - this.preferences, - this.providers, - this.routing, - this.timeout, - this.delay, - this.expiry, - this.to, - this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ContentStage builder() { - return new Builder(); - } - - public interface ContentStage { - _FinalStage content(Content content); - - Builder from(ContentMessage other); - } - - public interface _FinalStage { - ContentMessage build(); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage brandId(Optional brandId); - - _FinalStage brandId(String brandId); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(Map channels); - - _FinalStage context(Optional context); - - _FinalStage context(MessageContext context); - - _FinalStage metadata(Optional metadata); - - _FinalStage metadata(MessageMetadata metadata); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(MessagePreferences preferences); - - _FinalStage providers(Optional> providers); - - _FinalStage providers(Map providers); - - _FinalStage routing(Optional routing); - - _FinalStage routing(Routing routing); - - _FinalStage timeout(Optional timeout); - - _FinalStage timeout(Timeout timeout); - - _FinalStage delay(Optional delay); - - _FinalStage delay(Delay delay); - - _FinalStage expiry(Optional expiry); - - _FinalStage expiry(Expiry expiry); - - _FinalStage to(Optional to); - - _FinalStage to(MessageRecipient to); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ContentStage, _FinalStage { - private Content content; - - private Optional to = Optional.empty(); - - private Optional expiry = Optional.empty(); - - private Optional delay = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private Optional routing = Optional.empty(); - - private Optional> providers = Optional.empty(); - - private Optional preferences = Optional.empty(); - - private Optional metadata = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional> channels = Optional.empty(); - - private Optional brandId = Optional.empty(); - - private Optional> data = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ContentMessage other) { - data(other.getData()); - brandId(other.getBrandId()); - channels(other.getChannels()); - context(other.getContext()); - metadata(other.getMetadata()); - preferences(other.getPreferences()); - providers(other.getProviders()); - routing(other.getRouting()); - timeout(other.getTimeout()); - delay(other.getDelay()); - expiry(other.getExpiry()); - to(other.getTo()); - content(other.getContent()); - return this; - } - - /** - *

Describes the content of the message in a way that will work for email, push, - * chat, or any channel. Either this or template must be specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(Content content) { - this.content = content; - return this; - } - - /** - *

The recipient or a list of recipients of the message

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage to(MessageRecipient to) { - this.to = Optional.of(to); - return this; - } - - @java.lang.Override - @JsonSetter(value = "to", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { - this.to = to; - return this; - } - - /** - *

"Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiry(Expiry expiry) { - this.expiry = Optional.of(expiry); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expiry", nulls = Nulls.SKIP) - public _FinalStage expiry(Optional expiry) { - this.expiry = expiry; - return this; - } - - /** - *

Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm')

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage delay(Delay delay) { - this.delay = Optional.of(delay); - return this; - } - - @java.lang.Override - @JsonSetter(value = "delay", nulls = Nulls.SKIP) - public _FinalStage delay(Optional delay) { - this.delay = delay; - return this; - } - - /** - *

Time in ms to attempt the channel before failing over to the next available channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage timeout(Timeout timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - @java.lang.Override - @JsonSetter(value = "timeout", nulls = Nulls.SKIP) - public _FinalStage timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - @java.lang.Override - public _FinalStage routing(Routing routing) { - this.routing = Optional.of(routing); - return this; - } - - @java.lang.Override - @JsonSetter(value = "routing", nulls = Nulls.SKIP) - public _FinalStage routing(Optional routing) { - this.routing = routing; - return this; - } - - /** - *

An object whose keys are valid provider identifiers which map to an object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage providers(Map providers) { - this.providers = Optional.of(providers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public _FinalStage providers(Optional> providers) { - this.providers = providers; - return this; - } - - @java.lang.Override - public _FinalStage preferences(MessagePreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - /** - *

Metadata such as utm tracking attached with the notification through this channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage metadata(MessageMetadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - @java.lang.Override - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public _FinalStage metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - /** - *

Context to load with this recipient. Will override any context set on message.context.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage context(MessageContext context) { - this.context = Optional.of(context); - return this; - } - - @java.lang.Override - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public _FinalStage context(Optional context) { - this.context = context; - return this; - } - - /** - *

"Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage channels(Map channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public _FinalStage brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public _FinalStage brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - /** - *

An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public ContentMessage build() { - return new ContentMessage( - data, - brandId, - channels, - context, - metadata, - preferences, - providers, - routing, - timeout, - delay, - expiry, - to, - content, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Criteria.java b/src/main/java/com/courier/api/resources/send/types/Criteria.java deleted file mode 100644 index 5a2e6f2f..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Criteria.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum Criteria { - NO_ESCALATION("no-escalation"), - - DELIVERED("delivered"), - - VIEWED("viewed"), - - ENGAGED("engaged"); - - private final String value; - - Criteria(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Delay.java b/src/main/java/com/courier/api/resources/send/types/Delay.java deleted file mode 100644 index 22c46af3..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Delay.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Delay.Builder.class) -public final class Delay { - private final Optional duration; - - private final Optional until; - - private final Map additionalProperties; - - private Delay(Optional duration, Optional until, Map additionalProperties) { - this.duration = duration; - this.until = until; - this.additionalProperties = additionalProperties; - } - - /** - * @return The duration of the delay in milliseconds. - */ - @JsonProperty("duration") - public Optional getDuration() { - return duration; - } - - /** - * @return An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm') - */ - @JsonProperty("until") - public Optional getUntil() { - return until; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Delay && equalTo((Delay) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Delay other) { - return duration.equals(other.duration) && until.equals(other.until); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.duration, this.until); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional duration = Optional.empty(); - - private Optional until = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Delay other) { - duration(other.getDuration()); - until(other.getUntil()); - return this; - } - - @JsonSetter(value = "duration", nulls = Nulls.SKIP) - public Builder duration(Optional duration) { - this.duration = duration; - return this; - } - - public Builder duration(Integer duration) { - this.duration = Optional.of(duration); - return this; - } - - @JsonSetter(value = "until", nulls = Nulls.SKIP) - public Builder until(Optional until) { - this.until = until; - return this; - } - - public Builder until(String until) { - this.until = Optional.of(until); - return this; - } - - public Delay build() { - return new Delay(duration, until, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalActionNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalActionNode.java deleted file mode 100644 index ce665d96..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalActionNode.java +++ /dev/null @@ -1,476 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalActionNode.Builder.class) -public final class ElementalActionNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final String content; - - private final String href; - - private final Optional actionId; - - private final Optional align; - - private final Optional backgroundColor; - - private final Optional style; - - private final Optional> locales; - - private final Map additionalProperties; - - private ElementalActionNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - String content, - String href, - Optional actionId, - Optional align, - Optional backgroundColor, - Optional style, - Optional> locales, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.content = content; - this.href = href; - this.actionId = actionId; - this.align = align; - this.backgroundColor = backgroundColor; - this.style = style; - this.locales = locales; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The text content of the action shown to the user. - */ - @JsonProperty("content") - public String getContent() { - return content; - } - - /** - * @return The target URL of the action. - */ - @JsonProperty("href") - public String getHref() { - return href; - } - - /** - * @return A unique id used to identify the action when it is executed. - */ - @JsonProperty("action_id") - public Optional getActionId() { - return actionId; - } - - /** - * @return The alignment of the action button. Defaults to "center". - */ - @JsonProperty("align") - public Optional getAlign() { - return align; - } - - /** - * @return The background color of the action button. - */ - @JsonProperty("background_color") - public Optional getBackgroundColor() { - return backgroundColor; - } - - /** - * @return Defaults to button. - */ - @JsonProperty("style") - public Optional getStyle() { - return style; - } - - /** - * @return Region specific content. See locales docs for more details. - */ - @JsonProperty("locales") - public Optional> getLocales() { - return locales; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalActionNode && equalTo((ElementalActionNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalActionNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && content.equals(other.content) - && href.equals(other.href) - && actionId.equals(other.actionId) - && align.equals(other.align) - && backgroundColor.equals(other.backgroundColor) - && style.equals(other.style) - && locales.equals(other.locales); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.channels, - this.ref, - this.if_, - this.loop, - this.content, - this.href, - this.actionId, - this.align, - this.backgroundColor, - this.style, - this.locales); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ContentStage builder() { - return new Builder(); - } - - public interface ContentStage { - HrefStage content(String content); - - Builder from(ElementalActionNode other); - } - - public interface HrefStage { - _FinalStage href(String href); - } - - public interface _FinalStage { - ElementalActionNode build(); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(List channels); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage loop(Optional loop); - - _FinalStage loop(String loop); - - _FinalStage actionId(Optional actionId); - - _FinalStage actionId(String actionId); - - _FinalStage align(Optional align); - - _FinalStage align(IAlignment align); - - _FinalStage backgroundColor(Optional backgroundColor); - - _FinalStage backgroundColor(String backgroundColor); - - _FinalStage style(Optional style); - - _FinalStage style(IActionButtonStyle style); - - _FinalStage locales(Optional> locales); - - _FinalStage locales(Map locales); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ContentStage, HrefStage, _FinalStage { - private String content; - - private String href; - - private Optional> locales = Optional.empty(); - - private Optional style = Optional.empty(); - - private Optional backgroundColor = Optional.empty(); - - private Optional align = Optional.empty(); - - private Optional actionId = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional> channels = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalActionNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - content(other.getContent()); - href(other.getHref()); - actionId(other.getActionId()); - align(other.getAlign()); - backgroundColor(other.getBackgroundColor()); - style(other.getStyle()); - locales(other.getLocales()); - return this; - } - - /** - *

The text content of the action shown to the user.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public HrefStage content(String content) { - this.content = content; - return this; - } - - /** - *

The target URL of the action.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("href") - public _FinalStage href(String href) { - this.href = href; - return this; - } - - /** - *

Region specific content. See locales docs for more details.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage locales(Map locales) { - this.locales = Optional.of(locales); - return this; - } - - @java.lang.Override - @JsonSetter(value = "locales", nulls = Nulls.SKIP) - public _FinalStage locales(Optional> locales) { - this.locales = locales; - return this; - } - - /** - *

Defaults to button.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage style(IActionButtonStyle style) { - this.style = Optional.of(style); - return this; - } - - @java.lang.Override - @JsonSetter(value = "style", nulls = Nulls.SKIP) - public _FinalStage style(Optional style) { - this.style = style; - return this; - } - - /** - *

The background color of the action button.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage backgroundColor(String backgroundColor) { - this.backgroundColor = Optional.of(backgroundColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "background_color", nulls = Nulls.SKIP) - public _FinalStage backgroundColor(Optional backgroundColor) { - this.backgroundColor = backgroundColor; - return this; - } - - /** - *

The alignment of the action button. Defaults to "center".

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage align(IAlignment align) { - this.align = Optional.of(align); - return this; - } - - @java.lang.Override - @JsonSetter(value = "align", nulls = Nulls.SKIP) - public _FinalStage align(Optional align) { - this.align = align; - return this; - } - - /** - *

A unique id used to identify the action when it is executed.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage actionId(String actionId) { - this.actionId = Optional.of(actionId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "action_id", nulls = Nulls.SKIP) - public _FinalStage actionId(Optional actionId) { - this.actionId = actionId; - return this; - } - - @java.lang.Override - public _FinalStage loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @java.lang.Override - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public _FinalStage loop(Optional loop) { - this.loop = loop; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public ElementalActionNode build() { - return new ElementalActionNode( - channels, - ref, - if_, - loop, - content, - href, - actionId, - align, - backgroundColor, - style, - locales, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalBaseNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalBaseNode.java deleted file mode 100644 index c4ec4bee..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalBaseNode.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalBaseNode.Builder.class) -public final class ElementalBaseNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final Map additionalProperties; - - private ElementalBaseNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalBaseNode && equalTo((ElementalBaseNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalBaseNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channels, this.ref, this.if_, this.loop); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> channels = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional loop = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ElementalBaseNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - return this; - } - - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public Builder channels(Optional> channels) { - this.channels = channels; - return this; - } - - public Builder channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public Builder loop(Optional loop) { - this.loop = loop; - return this; - } - - public Builder loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - public ElementalBaseNode build() { - return new ElementalBaseNode(channels, ref, if_, loop, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalChannelNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalChannelNode.java deleted file mode 100644 index 8eea6f4f..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalChannelNode.java +++ /dev/null @@ -1,317 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalChannelNode.Builder.class) -public final class ElementalChannelNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final String channel; - - private final Optional> elements; - - private final Optional> raw; - - private final Map additionalProperties; - - private ElementalChannelNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - String channel, - Optional> elements, - Optional> raw, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.channel = channel; - this.elements = elements; - this.raw = raw; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The channel the contents of this element should be applied to. Can be email, - * push, direct_message, sms or a provider such as slack - */ - @JsonProperty("channel") - public String getChannel() { - return channel; - } - - /** - * @return An array of elements to apply to the channel. If raw has not been - * specified, elements is required. - */ - @JsonProperty("elements") - public Optional> getElements() { - return elements; - } - - /** - * @return Raw data to apply to the channel. If elements has not been - * specified, raw is required. - */ - @JsonProperty("raw") - public Optional> getRaw() { - return raw; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalChannelNode && equalTo((ElementalChannelNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalChannelNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && channel.equals(other.channel) - && elements.equals(other.elements) - && raw.equals(other.raw); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channels, this.ref, this.if_, this.loop, this.channel, this.elements, this.raw); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ChannelStage builder() { - return new Builder(); - } - - public interface ChannelStage { - _FinalStage channel(String channel); - - Builder from(ElementalChannelNode other); - } - - public interface _FinalStage { - ElementalChannelNode build(); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(List channels); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage loop(Optional loop); - - _FinalStage loop(String loop); - - _FinalStage elements(Optional> elements); - - _FinalStage elements(List elements); - - _FinalStage raw(Optional> raw); - - _FinalStage raw(Map raw); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ChannelStage, _FinalStage { - private String channel; - - private Optional> raw = Optional.empty(); - - private Optional> elements = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional> channels = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalChannelNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - channel(other.getChannel()); - elements(other.getElements()); - raw(other.getRaw()); - return this; - } - - /** - *

The channel the contents of this element should be applied to. Can be email, - * push, direct_message, sms or a provider such as slack

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("channel") - public _FinalStage channel(String channel) { - this.channel = channel; - return this; - } - - /** - *

Raw data to apply to the channel. If elements has not been - * specified, raw is required.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage raw(Map raw) { - this.raw = Optional.of(raw); - return this; - } - - @java.lang.Override - @JsonSetter(value = "raw", nulls = Nulls.SKIP) - public _FinalStage raw(Optional> raw) { - this.raw = raw; - return this; - } - - /** - *

An array of elements to apply to the channel. If raw has not been - * specified, elements is required.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage elements(List elements) { - this.elements = Optional.of(elements); - return this; - } - - @java.lang.Override - @JsonSetter(value = "elements", nulls = Nulls.SKIP) - public _FinalStage elements(Optional> elements) { - this.elements = elements; - return this; - } - - @java.lang.Override - public _FinalStage loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @java.lang.Override - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public _FinalStage loop(Optional loop) { - this.loop = loop; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public ElementalChannelNode build() { - return new ElementalChannelNode(channels, ref, if_, loop, channel, elements, raw, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalContent.java b/src/main/java/com/courier/api/resources/send/types/ElementalContent.java deleted file mode 100644 index e7d4118f..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalContent.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalContent.Builder.class) -public final class ElementalContent { - private final String version; - - private final Optional brand; - - private final List elements; - - private final Map additionalProperties; - - private ElementalContent( - String version, - Optional brand, - List elements, - Map additionalProperties) { - this.version = version; - this.brand = brand; - this.elements = elements; - this.additionalProperties = additionalProperties; - } - - /** - * @return For example, "2022-01-01" - */ - @JsonProperty("version") - public String getVersion() { - return version; - } - - @JsonProperty("brand") - public Optional getBrand() { - return brand; - } - - @JsonProperty("elements") - public List getElements() { - return elements; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalContent && equalTo((ElementalContent) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalContent other) { - return version.equals(other.version) && brand.equals(other.brand) && elements.equals(other.elements); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.version, this.brand, this.elements); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static VersionStage builder() { - return new Builder(); - } - - public interface VersionStage { - _FinalStage version(String version); - - Builder from(ElementalContent other); - } - - public interface _FinalStage { - ElementalContent build(); - - _FinalStage brand(Optional brand); - - _FinalStage brand(Object brand); - - _FinalStage elements(List elements); - - _FinalStage addElements(ElementalNode elements); - - _FinalStage addAllElements(List elements); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements VersionStage, _FinalStage { - private String version; - - private List elements = new ArrayList<>(); - - private Optional brand = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalContent other) { - version(other.getVersion()); - brand(other.getBrand()); - elements(other.getElements()); - return this; - } - - /** - *

For example, "2022-01-01"

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("version") - public _FinalStage version(String version) { - this.version = version; - return this; - } - - @java.lang.Override - public _FinalStage addAllElements(List elements) { - this.elements.addAll(elements); - return this; - } - - @java.lang.Override - public _FinalStage addElements(ElementalNode elements) { - this.elements.add(elements); - return this; - } - - @java.lang.Override - @JsonSetter(value = "elements", nulls = Nulls.SKIP) - public _FinalStage elements(List elements) { - this.elements.clear(); - this.elements.addAll(elements); - return this; - } - - @java.lang.Override - public _FinalStage brand(Object brand) { - this.brand = Optional.of(brand); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand", nulls = Nulls.SKIP) - public _FinalStage brand(Optional brand) { - this.brand = brand; - return this; - } - - @java.lang.Override - public ElementalContent build() { - return new ElementalContent(version, brand, elements, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalContentSugar.java b/src/main/java/com/courier/api/resources/send/types/ElementalContentSugar.java deleted file mode 100644 index 2a24fcb6..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalContentSugar.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalContentSugar.Builder.class) -public final class ElementalContentSugar { - private final String title; - - private final String body; - - private final Map additionalProperties; - - private ElementalContentSugar(String title, String body, Map additionalProperties) { - this.title = title; - this.body = body; - this.additionalProperties = additionalProperties; - } - - /** - * @return The title to be displayed by supported channels i.e. push, email (as subject) - */ - @JsonProperty("title") - public String getTitle() { - return title; - } - - /** - * @return The text content displayed in the notification. - */ - @JsonProperty("body") - public String getBody() { - return body; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalContentSugar && equalTo((ElementalContentSugar) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalContentSugar other) { - return title.equals(other.title) && body.equals(other.body); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.title, this.body); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TitleStage builder() { - return new Builder(); - } - - public interface TitleStage { - BodyStage title(String title); - - Builder from(ElementalContentSugar other); - } - - public interface BodyStage { - _FinalStage body(String body); - } - - public interface _FinalStage { - ElementalContentSugar build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TitleStage, BodyStage, _FinalStage { - private String title; - - private String body; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalContentSugar other) { - title(other.getTitle()); - body(other.getBody()); - return this; - } - - /** - *

The title to be displayed by supported channels i.e. push, email (as subject)

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("title") - public BodyStage title(String title) { - this.title = title; - return this; - } - - /** - *

The text content displayed in the notification.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("body") - public _FinalStage body(String body) { - this.body = body; - return this; - } - - @java.lang.Override - public ElementalContentSugar build() { - return new ElementalContentSugar(title, body, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalDividerNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalDividerNode.java deleted file mode 100644 index 3660088d..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalDividerNode.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalDividerNode.Builder.class) -public final class ElementalDividerNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final Optional color; - - private final Map additionalProperties; - - private ElementalDividerNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - Optional color, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.color = color; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The CSS color to render the line with. For example, #fff - */ - @JsonProperty("color") - public Optional getColor() { - return color; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalDividerNode && equalTo((ElementalDividerNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalDividerNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && color.equals(other.color); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channels, this.ref, this.if_, this.loop, this.color); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> channels = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional color = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ElementalDividerNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - color(other.getColor()); - return this; - } - - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public Builder channels(Optional> channels) { - this.channels = channels; - return this; - } - - public Builder channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public Builder loop(Optional loop) { - this.loop = loop; - return this; - } - - public Builder loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @JsonSetter(value = "color", nulls = Nulls.SKIP) - public Builder color(Optional color) { - this.color = color; - return this; - } - - public Builder color(String color) { - this.color = Optional.of(color); - return this; - } - - public ElementalDividerNode build() { - return new ElementalDividerNode(channels, ref, if_, loop, color, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalGroupNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalGroupNode.java deleted file mode 100644 index 7190b5a0..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalGroupNode.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalGroupNode.Builder.class) -public final class ElementalGroupNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final List elements; - - private final Map additionalProperties; - - private ElementalGroupNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - List elements, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.elements = elements; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return Sub elements to render. - */ - @JsonProperty("elements") - public List getElements() { - return elements; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalGroupNode && equalTo((ElementalGroupNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalGroupNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && elements.equals(other.elements); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channels, this.ref, this.if_, this.loop, this.elements); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> channels = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional loop = Optional.empty(); - - private List elements = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ElementalGroupNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - elements(other.getElements()); - return this; - } - - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public Builder channels(Optional> channels) { - this.channels = channels; - return this; - } - - public Builder channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public Builder loop(Optional loop) { - this.loop = loop; - return this; - } - - public Builder loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @JsonSetter(value = "elements", nulls = Nulls.SKIP) - public Builder elements(List elements) { - this.elements.clear(); - this.elements.addAll(elements); - return this; - } - - public Builder addElements(ElementalNode elements) { - this.elements.add(elements); - return this; - } - - public Builder addAllElements(List elements) { - this.elements.addAll(elements); - return this; - } - - public ElementalGroupNode build() { - return new ElementalGroupNode(channels, ref, if_, loop, elements, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalImageNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalImageNode.java deleted file mode 100644 index abd510b7..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalImageNode.java +++ /dev/null @@ -1,395 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalImageNode.Builder.class) -public final class ElementalImageNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final String src; - - private final Optional href; - - private final Optional align; - - private final Optional altText; - - private final Optional width; - - private final Map additionalProperties; - - private ElementalImageNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - String src, - Optional href, - Optional align, - Optional altText, - Optional width, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.src = src; - this.href = href; - this.align = align; - this.altText = altText; - this.width = width; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The source of the image. - */ - @JsonProperty("src") - public String getSrc() { - return src; - } - - /** - * @return A URL to link to when the image is clicked. - */ - @JsonProperty("href") - public Optional getHref() { - return href; - } - - /** - * @return The alignment of the image. - */ - @JsonProperty("align") - public Optional getAlign() { - return align; - } - - /** - * @return Alternate text for the image. - */ - @JsonProperty("altText") - public Optional getAltText() { - return altText; - } - - /** - * @return CSS width properties to apply to the image. For example, 50px - */ - @JsonProperty("width") - public Optional getWidth() { - return width; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalImageNode && equalTo((ElementalImageNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalImageNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && src.equals(other.src) - && href.equals(other.href) - && align.equals(other.align) - && altText.equals(other.altText) - && width.equals(other.width); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.channels, - this.ref, - this.if_, - this.loop, - this.src, - this.href, - this.align, - this.altText, - this.width); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static SrcStage builder() { - return new Builder(); - } - - public interface SrcStage { - _FinalStage src(String src); - - Builder from(ElementalImageNode other); - } - - public interface _FinalStage { - ElementalImageNode build(); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(List channels); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage loop(Optional loop); - - _FinalStage loop(String loop); - - _FinalStage href(Optional href); - - _FinalStage href(String href); - - _FinalStage align(Optional align); - - _FinalStage align(IAlignment align); - - _FinalStage altText(Optional altText); - - _FinalStage altText(String altText); - - _FinalStage width(Optional width); - - _FinalStage width(String width); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SrcStage, _FinalStage { - private String src; - - private Optional width = Optional.empty(); - - private Optional altText = Optional.empty(); - - private Optional align = Optional.empty(); - - private Optional href = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional> channels = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalImageNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - src(other.getSrc()); - href(other.getHref()); - align(other.getAlign()); - altText(other.getAltText()); - width(other.getWidth()); - return this; - } - - /** - *

The source of the image.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("src") - public _FinalStage src(String src) { - this.src = src; - return this; - } - - /** - *

CSS width properties to apply to the image. For example, 50px

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage width(String width) { - this.width = Optional.of(width); - return this; - } - - @java.lang.Override - @JsonSetter(value = "width", nulls = Nulls.SKIP) - public _FinalStage width(Optional width) { - this.width = width; - return this; - } - - /** - *

Alternate text for the image.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage altText(String altText) { - this.altText = Optional.of(altText); - return this; - } - - @java.lang.Override - @JsonSetter(value = "altText", nulls = Nulls.SKIP) - public _FinalStage altText(Optional altText) { - this.altText = altText; - return this; - } - - /** - *

The alignment of the image.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage align(IAlignment align) { - this.align = Optional.of(align); - return this; - } - - @java.lang.Override - @JsonSetter(value = "align", nulls = Nulls.SKIP) - public _FinalStage align(Optional align) { - this.align = align; - return this; - } - - /** - *

A URL to link to when the image is clicked.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage href(String href) { - this.href = Optional.of(href); - return this; - } - - @java.lang.Override - @JsonSetter(value = "href", nulls = Nulls.SKIP) - public _FinalStage href(Optional href) { - this.href = href; - return this; - } - - @java.lang.Override - public _FinalStage loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @java.lang.Override - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public _FinalStage loop(Optional loop) { - this.loop = loop; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public ElementalImageNode build() { - return new ElementalImageNode( - channels, ref, if_, loop, src, href, align, altText, width, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalMetaNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalMetaNode.java deleted file mode 100644 index 32974227..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalMetaNode.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalMetaNode.Builder.class) -public final class ElementalMetaNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final Optional title; - - private final Map additionalProperties; - - private ElementalMetaNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - Optional title, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.title = title; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The title to be displayed by supported channels. For example, the email subject. - */ - @JsonProperty("title") - public Optional getTitle() { - return title; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalMetaNode && equalTo((ElementalMetaNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalMetaNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && title.equals(other.title); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.channels, this.ref, this.if_, this.loop, this.title); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> channels = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional title = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ElementalMetaNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - title(other.getTitle()); - return this; - } - - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public Builder channels(Optional> channels) { - this.channels = channels; - return this; - } - - public Builder channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public Builder ref(Optional ref) { - this.ref = ref; - return this; - } - - public Builder ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public Builder loop(Optional loop) { - this.loop = loop; - return this; - } - - public Builder loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @JsonSetter(value = "title", nulls = Nulls.SKIP) - public Builder title(Optional title) { - this.title = title; - return this; - } - - public Builder title(String title) { - this.title = Optional.of(title); - return this; - } - - public ElementalMetaNode build() { - return new ElementalMetaNode(channels, ref, if_, loop, title, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalNode.java deleted file mode 100644 index c2a9e11a..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalNode.java +++ /dev/null @@ -1,539 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonUnwrapped; -import com.fasterxml.jackson.annotation.JsonValue; -import java.util.Objects; -import java.util.Optional; - -public final class ElementalNode { - private final Value value; - - @JsonCreator(mode = JsonCreator.Mode.DELEGATING) - private ElementalNode(Value value) { - this.value = value; - } - - public T visit(Visitor visitor) { - return value.visit(visitor); - } - - public static ElementalNode text(ElementalTextNode value) { - return new ElementalNode(new TextValue(value)); - } - - public static ElementalNode meta(ElementalMetaNode value) { - return new ElementalNode(new MetaValue(value)); - } - - public static ElementalNode channel(ElementalChannelNode value) { - return new ElementalNode(new ChannelValue(value)); - } - - public static ElementalNode image(ElementalImageNode value) { - return new ElementalNode(new ImageValue(value)); - } - - public static ElementalNode action(ElementalActionNode value) { - return new ElementalNode(new ActionValue(value)); - } - - public static ElementalNode divider(ElementalDividerNode value) { - return new ElementalNode(new DividerValue(value)); - } - - public static ElementalNode group(ElementalGroupNode value) { - return new ElementalNode(new GroupValue(value)); - } - - public static ElementalNode quote(ElementalQuoteNode value) { - return new ElementalNode(new QuoteValue(value)); - } - - public boolean isText() { - return value instanceof TextValue; - } - - public boolean isMeta() { - return value instanceof MetaValue; - } - - public boolean isChannel() { - return value instanceof ChannelValue; - } - - public boolean isImage() { - return value instanceof ImageValue; - } - - public boolean isAction() { - return value instanceof ActionValue; - } - - public boolean isDivider() { - return value instanceof DividerValue; - } - - public boolean isGroup() { - return value instanceof GroupValue; - } - - public boolean isQuote() { - return value instanceof QuoteValue; - } - - public boolean _isUnknown() { - return value instanceof _UnknownValue; - } - - public Optional getText() { - if (isText()) { - return Optional.of(((TextValue) value).value); - } - return Optional.empty(); - } - - public Optional getMeta() { - if (isMeta()) { - return Optional.of(((MetaValue) value).value); - } - return Optional.empty(); - } - - public Optional getChannel() { - if (isChannel()) { - return Optional.of(((ChannelValue) value).value); - } - return Optional.empty(); - } - - public Optional getImage() { - if (isImage()) { - return Optional.of(((ImageValue) value).value); - } - return Optional.empty(); - } - - public Optional getAction() { - if (isAction()) { - return Optional.of(((ActionValue) value).value); - } - return Optional.empty(); - } - - public Optional getDivider() { - if (isDivider()) { - return Optional.of(((DividerValue) value).value); - } - return Optional.empty(); - } - - public Optional getGroup() { - if (isGroup()) { - return Optional.of(((GroupValue) value).value); - } - return Optional.empty(); - } - - public Optional getQuote() { - if (isQuote()) { - return Optional.of(((QuoteValue) value).value); - } - return Optional.empty(); - } - - public Optional _getUnknown() { - if (_isUnknown()) { - return Optional.of(((_UnknownValue) value).value); - } - return Optional.empty(); - } - - @JsonValue - private Value getValue() { - return this.value; - } - - public interface Visitor { - T visitText(ElementalTextNode text); - - T visitMeta(ElementalMetaNode meta); - - T visitChannel(ElementalChannelNode channel); - - T visitImage(ElementalImageNode image); - - T visitAction(ElementalActionNode action); - - T visitDivider(ElementalDividerNode divider); - - T visitGroup(ElementalGroupNode group); - - T visitQuote(ElementalQuoteNode quote); - - T _visitUnknown(Object unknownType); - } - - @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class) - @JsonSubTypes({ - @JsonSubTypes.Type(TextValue.class), - @JsonSubTypes.Type(MetaValue.class), - @JsonSubTypes.Type(ChannelValue.class), - @JsonSubTypes.Type(ImageValue.class), - @JsonSubTypes.Type(ActionValue.class), - @JsonSubTypes.Type(DividerValue.class), - @JsonSubTypes.Type(GroupValue.class), - @JsonSubTypes.Type(QuoteValue.class) - }) - @JsonIgnoreProperties(ignoreUnknown = true) - private interface Value { - T visit(Visitor visitor); - } - - @JsonTypeName("text") - private static final class TextValue implements Value { - @JsonUnwrapped - private ElementalTextNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private TextValue() {} - - private TextValue(ElementalTextNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitText(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TextValue && equalTo((TextValue) other); - } - - private boolean equalTo(TextValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("meta") - private static final class MetaValue implements Value { - @JsonUnwrapped - private ElementalMetaNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private MetaValue() {} - - private MetaValue(ElementalMetaNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitMeta(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MetaValue && equalTo((MetaValue) other); - } - - private boolean equalTo(MetaValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("channel") - private static final class ChannelValue implements Value { - @JsonUnwrapped - private ElementalChannelNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private ChannelValue() {} - - private ChannelValue(ElementalChannelNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitChannel(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ChannelValue && equalTo((ChannelValue) other); - } - - private boolean equalTo(ChannelValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("image") - private static final class ImageValue implements Value { - @JsonUnwrapped - private ElementalImageNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private ImageValue() {} - - private ImageValue(ElementalImageNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitImage(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ImageValue && equalTo((ImageValue) other); - } - - private boolean equalTo(ImageValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("action") - private static final class ActionValue implements Value { - @JsonUnwrapped - private ElementalActionNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private ActionValue() {} - - private ActionValue(ElementalActionNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitAction(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ActionValue && equalTo((ActionValue) other); - } - - private boolean equalTo(ActionValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("divider") - private static final class DividerValue implements Value { - @JsonUnwrapped - private ElementalDividerNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private DividerValue() {} - - private DividerValue(ElementalDividerNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitDivider(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DividerValue && equalTo((DividerValue) other); - } - - private boolean equalTo(DividerValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("group") - private static final class GroupValue implements Value { - @JsonUnwrapped - private ElementalGroupNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private GroupValue() {} - - private GroupValue(ElementalGroupNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitGroup(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GroupValue && equalTo((GroupValue) other); - } - - private boolean equalTo(GroupValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - @JsonTypeName("quote") - private static final class QuoteValue implements Value { - @JsonUnwrapped - private ElementalQuoteNode value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private QuoteValue() {} - - private QuoteValue(ElementalQuoteNode value) { - this.value = value; - } - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor.visitQuote(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof QuoteValue && equalTo((QuoteValue) other); - } - - private boolean equalTo(QuoteValue other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "value: " + value + "}"; - } - } - - private static final class _UnknownValue implements Value { - private String type; - - @JsonValue - private Object value; - - @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) - private _UnknownValue(@JsonProperty("value") Object value) {} - - @java.lang.Override - public T visit(Visitor visitor) { - return visitor._visitUnknown(value); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof _UnknownValue && equalTo((_UnknownValue) other); - } - - private boolean equalTo(_UnknownValue other) { - return type.equals(other.type) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.type, this.value); - } - - @java.lang.Override - public String toString() { - return "ElementalNode{" + "type: " + type + ", value: " + value + "}"; - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalQuoteNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalQuoteNode.java deleted file mode 100644 index ade57573..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalQuoteNode.java +++ /dev/null @@ -1,382 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalQuoteNode.Builder.class) -public final class ElementalQuoteNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final String content; - - private final Optional align; - - private final Optional borderColor; - - private final TextStyle textStyle; - - private final Optional> locales; - - private final Map additionalProperties; - - private ElementalQuoteNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - String content, - Optional align, - Optional borderColor, - TextStyle textStyle, - Optional> locales, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.content = content; - this.align = align; - this.borderColor = borderColor; - this.textStyle = textStyle; - this.locales = locales; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The text value of the quote. - */ - @JsonProperty("content") - public String getContent() { - return content; - } - - /** - * @return Alignment of the quote. - */ - @JsonProperty("align") - public Optional getAlign() { - return align; - } - - /** - * @return CSS border color property. For example, #fff - */ - @JsonProperty("borderColor") - public Optional getBorderColor() { - return borderColor; - } - - @JsonProperty("text_style") - public TextStyle getTextStyle() { - return textStyle; - } - - /** - * @return Region specific content. See locales docs for more details. - */ - @JsonProperty("locales") - public Optional> getLocales() { - return locales; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalQuoteNode && equalTo((ElementalQuoteNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalQuoteNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && content.equals(other.content) - && align.equals(other.align) - && borderColor.equals(other.borderColor) - && textStyle.equals(other.textStyle) - && locales.equals(other.locales); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.channels, - this.ref, - this.if_, - this.loop, - this.content, - this.align, - this.borderColor, - this.textStyle, - this.locales); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ContentStage builder() { - return new Builder(); - } - - public interface ContentStage { - TextStyleStage content(String content); - - Builder from(ElementalQuoteNode other); - } - - public interface TextStyleStage { - _FinalStage textStyle(TextStyle textStyle); - } - - public interface _FinalStage { - ElementalQuoteNode build(); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(List channels); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage loop(Optional loop); - - _FinalStage loop(String loop); - - _FinalStage align(Optional align); - - _FinalStage align(IAlignment align); - - _FinalStage borderColor(Optional borderColor); - - _FinalStage borderColor(String borderColor); - - _FinalStage locales(Optional> locales); - - _FinalStage locales(Map locales); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ContentStage, TextStyleStage, _FinalStage { - private String content; - - private TextStyle textStyle; - - private Optional> locales = Optional.empty(); - - private Optional borderColor = Optional.empty(); - - private Optional align = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional> channels = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalQuoteNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - content(other.getContent()); - align(other.getAlign()); - borderColor(other.getBorderColor()); - textStyle(other.getTextStyle()); - locales(other.getLocales()); - return this; - } - - /** - *

The text value of the quote.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public TextStyleStage content(String content) { - this.content = content; - return this; - } - - @java.lang.Override - @JsonSetter("text_style") - public _FinalStage textStyle(TextStyle textStyle) { - this.textStyle = textStyle; - return this; - } - - /** - *

Region specific content. See locales docs for more details.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage locales(Map locales) { - this.locales = Optional.of(locales); - return this; - } - - @java.lang.Override - @JsonSetter(value = "locales", nulls = Nulls.SKIP) - public _FinalStage locales(Optional> locales) { - this.locales = locales; - return this; - } - - /** - *

CSS border color property. For example, #fff

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage borderColor(String borderColor) { - this.borderColor = Optional.of(borderColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "borderColor", nulls = Nulls.SKIP) - public _FinalStage borderColor(Optional borderColor) { - this.borderColor = borderColor; - return this; - } - - /** - *

Alignment of the quote.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage align(IAlignment align) { - this.align = Optional.of(align); - return this; - } - - @java.lang.Override - @JsonSetter(value = "align", nulls = Nulls.SKIP) - public _FinalStage align(Optional align) { - this.align = align; - return this; - } - - @java.lang.Override - public _FinalStage loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @java.lang.Override - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public _FinalStage loop(Optional loop) { - this.loop = loop; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public ElementalQuoteNode build() { - return new ElementalQuoteNode( - channels, ref, if_, loop, content, align, borderColor, textStyle, locales, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ElementalTextNode.java b/src/main/java/com/courier/api/resources/send/types/ElementalTextNode.java deleted file mode 100644 index f55a5d91..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ElementalTextNode.java +++ /dev/null @@ -1,588 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ElementalTextNode.Builder.class) -public final class ElementalTextNode implements IElementalBaseNode { - private final Optional> channels; - - private final Optional ref; - - private final Optional if_; - - private final Optional loop; - - private final String content; - - private final TextAlign align; - - private final Optional textStyle; - - private final Optional color; - - private final Optional bold; - - private final Optional italic; - - private final Optional strikethrough; - - private final Optional underline; - - private final Optional> locales; - - private final Optional format; - - private final Map additionalProperties; - - private ElementalTextNode( - Optional> channels, - Optional ref, - Optional if_, - Optional loop, - String content, - TextAlign align, - Optional textStyle, - Optional color, - Optional bold, - Optional italic, - Optional strikethrough, - Optional underline, - Optional> locales, - Optional format, - Map additionalProperties) { - this.channels = channels; - this.ref = ref; - this.if_ = if_; - this.loop = loop; - this.content = content; - this.align = align; - this.textStyle = textStyle; - this.color = color; - this.bold = bold; - this.italic = italic; - this.strikethrough = strikethrough; - this.underline = underline; - this.locales = locales; - this.format = format; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - @JsonProperty("ref") - @java.lang.Override - public Optional getRef() { - return ref; - } - - @JsonProperty("if") - @java.lang.Override - public Optional getIf() { - return if_; - } - - @JsonProperty("loop") - @java.lang.Override - public Optional getLoop() { - return loop; - } - - /** - * @return The text content displayed in the notification. Either this - * field must be specified, or the elements field - */ - @JsonProperty("content") - public String getContent() { - return content; - } - - /** - * @return Text alignment. - */ - @JsonProperty("align") - public TextAlign getAlign() { - return align; - } - - /** - * @return Allows the text to be rendered as a heading level. - */ - @JsonProperty("text_style") - public Optional getTextStyle() { - return textStyle; - } - - /** - * @return Specifies the color of text. Can be any valid css color value - */ - @JsonProperty("color") - public Optional getColor() { - return color; - } - - /** - * @return Apply bold to the text - */ - @JsonProperty("bold") - public Optional getBold() { - return bold; - } - - /** - * @return Apply italics to the text - */ - @JsonProperty("italic") - public Optional getItalic() { - return italic; - } - - /** - * @return Apply a strike through the text - */ - @JsonProperty("strikethrough") - public Optional getStrikethrough() { - return strikethrough; - } - - /** - * @return Apply an underline to the text - */ - @JsonProperty("underline") - public Optional getUnderline() { - return underline; - } - - /** - * @return Region specific content. See locales docs for more details. - */ - @JsonProperty("locales") - public Optional> getLocales() { - return locales; - } - - @JsonProperty("format") - public Optional getFormat() { - return format; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ElementalTextNode && equalTo((ElementalTextNode) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ElementalTextNode other) { - return channels.equals(other.channels) - && ref.equals(other.ref) - && if_.equals(other.if_) - && loop.equals(other.loop) - && content.equals(other.content) - && align.equals(other.align) - && textStyle.equals(other.textStyle) - && color.equals(other.color) - && bold.equals(other.bold) - && italic.equals(other.italic) - && strikethrough.equals(other.strikethrough) - && underline.equals(other.underline) - && locales.equals(other.locales) - && format.equals(other.format); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.channels, - this.ref, - this.if_, - this.loop, - this.content, - this.align, - this.textStyle, - this.color, - this.bold, - this.italic, - this.strikethrough, - this.underline, - this.locales, - this.format); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ContentStage builder() { - return new Builder(); - } - - public interface ContentStage { - AlignStage content(String content); - - Builder from(ElementalTextNode other); - } - - public interface AlignStage { - _FinalStage align(TextAlign align); - } - - public interface _FinalStage { - ElementalTextNode build(); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(List channels); - - _FinalStage ref(Optional ref); - - _FinalStage ref(String ref); - - _FinalStage if_(Optional if_); - - _FinalStage if_(String if_); - - _FinalStage loop(Optional loop); - - _FinalStage loop(String loop); - - _FinalStage textStyle(Optional textStyle); - - _FinalStage textStyle(TextStyle textStyle); - - _FinalStage color(Optional color); - - _FinalStage color(String color); - - _FinalStage bold(Optional bold); - - _FinalStage bold(String bold); - - _FinalStage italic(Optional italic); - - _FinalStage italic(String italic); - - _FinalStage strikethrough(Optional strikethrough); - - _FinalStage strikethrough(String strikethrough); - - _FinalStage underline(Optional underline); - - _FinalStage underline(String underline); - - _FinalStage locales(Optional> locales); - - _FinalStage locales(Map locales); - - _FinalStage format(Optional format); - - _FinalStage format(String format); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ContentStage, AlignStage, _FinalStage { - private String content; - - private TextAlign align; - - private Optional format = Optional.empty(); - - private Optional> locales = Optional.empty(); - - private Optional underline = Optional.empty(); - - private Optional strikethrough = Optional.empty(); - - private Optional italic = Optional.empty(); - - private Optional bold = Optional.empty(); - - private Optional color = Optional.empty(); - - private Optional textStyle = Optional.empty(); - - private Optional loop = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional ref = Optional.empty(); - - private Optional> channels = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ElementalTextNode other) { - channels(other.getChannels()); - ref(other.getRef()); - if_(other.getIf()); - loop(other.getLoop()); - content(other.getContent()); - align(other.getAlign()); - textStyle(other.getTextStyle()); - color(other.getColor()); - bold(other.getBold()); - italic(other.getItalic()); - strikethrough(other.getStrikethrough()); - underline(other.getUnderline()); - locales(other.getLocales()); - format(other.getFormat()); - return this; - } - - /** - *

The text content displayed in the notification. Either this - * field must be specified, or the elements field

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("content") - public AlignStage content(String content) { - this.content = content; - return this; - } - - /** - *

Text alignment.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("align") - public _FinalStage align(TextAlign align) { - this.align = align; - return this; - } - - @java.lang.Override - public _FinalStage format(String format) { - this.format = Optional.of(format); - return this; - } - - @java.lang.Override - @JsonSetter(value = "format", nulls = Nulls.SKIP) - public _FinalStage format(Optional format) { - this.format = format; - return this; - } - - /** - *

Region specific content. See locales docs for more details.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage locales(Map locales) { - this.locales = Optional.of(locales); - return this; - } - - @java.lang.Override - @JsonSetter(value = "locales", nulls = Nulls.SKIP) - public _FinalStage locales(Optional> locales) { - this.locales = locales; - return this; - } - - /** - *

Apply an underline to the text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage underline(String underline) { - this.underline = Optional.of(underline); - return this; - } - - @java.lang.Override - @JsonSetter(value = "underline", nulls = Nulls.SKIP) - public _FinalStage underline(Optional underline) { - this.underline = underline; - return this; - } - - /** - *

Apply a strike through the text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage strikethrough(String strikethrough) { - this.strikethrough = Optional.of(strikethrough); - return this; - } - - @java.lang.Override - @JsonSetter(value = "strikethrough", nulls = Nulls.SKIP) - public _FinalStage strikethrough(Optional strikethrough) { - this.strikethrough = strikethrough; - return this; - } - - /** - *

Apply italics to the text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage italic(String italic) { - this.italic = Optional.of(italic); - return this; - } - - @java.lang.Override - @JsonSetter(value = "italic", nulls = Nulls.SKIP) - public _FinalStage italic(Optional italic) { - this.italic = italic; - return this; - } - - /** - *

Apply bold to the text

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage bold(String bold) { - this.bold = Optional.of(bold); - return this; - } - - @java.lang.Override - @JsonSetter(value = "bold", nulls = Nulls.SKIP) - public _FinalStage bold(Optional bold) { - this.bold = bold; - return this; - } - - /** - *

Specifies the color of text. Can be any valid css color value

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage color(String color) { - this.color = Optional.of(color); - return this; - } - - @java.lang.Override - @JsonSetter(value = "color", nulls = Nulls.SKIP) - public _FinalStage color(Optional color) { - this.color = color; - return this; - } - - /** - *

Allows the text to be rendered as a heading level.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage textStyle(TextStyle textStyle) { - this.textStyle = Optional.of(textStyle); - return this; - } - - @java.lang.Override - @JsonSetter(value = "text_style", nulls = Nulls.SKIP) - public _FinalStage textStyle(Optional textStyle) { - this.textStyle = textStyle; - return this; - } - - @java.lang.Override - public _FinalStage loop(String loop) { - this.loop = Optional.of(loop); - return this; - } - - @java.lang.Override - @JsonSetter(value = "loop", nulls = Nulls.SKIP) - public _FinalStage loop(Optional loop) { - this.loop = loop; - return this; - } - - @java.lang.Override - public _FinalStage if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @java.lang.Override - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public _FinalStage if_(Optional if_) { - this.if_ = if_; - return this; - } - - @java.lang.Override - public _FinalStage ref(String ref) { - this.ref = Optional.of(ref); - return this; - } - - @java.lang.Override - @JsonSetter(value = "ref", nulls = Nulls.SKIP) - public _FinalStage ref(Optional ref) { - this.ref = ref; - return this; - } - - @java.lang.Override - public _FinalStage channels(List channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public ElementalTextNode build() { - return new ElementalTextNode( - channels, - ref, - if_, - loop, - content, - align, - textStyle, - color, - bold, - italic, - strikethrough, - underline, - locales, - format, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/EmailFooter.java b/src/main/java/com/courier/api/resources/send/types/EmailFooter.java deleted file mode 100644 index 938567d0..00000000 --- a/src/main/java/com/courier/api/resources/send/types/EmailFooter.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = EmailFooter.Builder.class) -public final class EmailFooter { - private final Optional content; - - private final Optional inheritDefault; - - private final Map additionalProperties; - - private EmailFooter( - Optional content, Optional inheritDefault, Map additionalProperties) { - this.content = content; - this.inheritDefault = inheritDefault; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("content") - public Optional getContent() { - return content; - } - - @JsonProperty("inheritDefault") - public Optional getInheritDefault() { - return inheritDefault; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmailFooter && equalTo((EmailFooter) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(EmailFooter other) { - return content.equals(other.content) && inheritDefault.equals(other.inheritDefault); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.content, this.inheritDefault); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional content = Optional.empty(); - - private Optional inheritDefault = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(EmailFooter other) { - content(other.getContent()); - inheritDefault(other.getInheritDefault()); - return this; - } - - @JsonSetter(value = "content", nulls = Nulls.SKIP) - public Builder content(Optional content) { - this.content = content; - return this; - } - - public Builder content(Object content) { - this.content = Optional.of(content); - return this; - } - - @JsonSetter(value = "inheritDefault", nulls = Nulls.SKIP) - public Builder inheritDefault(Optional inheritDefault) { - this.inheritDefault = inheritDefault; - return this; - } - - public Builder inheritDefault(Boolean inheritDefault) { - this.inheritDefault = Optional.of(inheritDefault); - return this; - } - - public EmailFooter build() { - return new EmailFooter(content, inheritDefault, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/EmailHead.java b/src/main/java/com/courier/api/resources/send/types/EmailHead.java deleted file mode 100644 index c716e709..00000000 --- a/src/main/java/com/courier/api/resources/send/types/EmailHead.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = EmailHead.Builder.class) -public final class EmailHead { - private final boolean inheritDefault; - - private final Optional content; - - private final Map additionalProperties; - - private EmailHead(boolean inheritDefault, Optional content, Map additionalProperties) { - this.inheritDefault = inheritDefault; - this.content = content; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("inheritDefault") - public boolean getInheritDefault() { - return inheritDefault; - } - - @JsonProperty("content") - public Optional getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmailHead && equalTo((EmailHead) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(EmailHead other) { - return inheritDefault == other.inheritDefault && content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.inheritDefault, this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static InheritDefaultStage builder() { - return new Builder(); - } - - public interface InheritDefaultStage { - _FinalStage inheritDefault(boolean inheritDefault); - - Builder from(EmailHead other); - } - - public interface _FinalStage { - EmailHead build(); - - _FinalStage content(Optional content); - - _FinalStage content(String content); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements InheritDefaultStage, _FinalStage { - private boolean inheritDefault; - - private Optional content = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(EmailHead other) { - inheritDefault(other.getInheritDefault()); - content(other.getContent()); - return this; - } - - @java.lang.Override - @JsonSetter("inheritDefault") - public _FinalStage inheritDefault(boolean inheritDefault) { - this.inheritDefault = inheritDefault; - return this; - } - - @java.lang.Override - public _FinalStage content(String content) { - this.content = Optional.of(content); - return this; - } - - @java.lang.Override - @JsonSetter(value = "content", nulls = Nulls.SKIP) - public _FinalStage content(Optional content) { - this.content = content; - return this; - } - - @java.lang.Override - public EmailHead build() { - return new EmailHead(inheritDefault, content, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/EmailHeader.java b/src/main/java/com/courier/api/resources/send/types/EmailHeader.java deleted file mode 100644 index 2b61afec..00000000 --- a/src/main/java/com/courier/api/resources/send/types/EmailHeader.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = EmailHeader.Builder.class) -public final class EmailHeader { - private final Optional inheritDefault; - - private final Optional barColor; - - private final Logo logo; - - private final Map additionalProperties; - - private EmailHeader( - Optional inheritDefault, - Optional barColor, - Logo logo, - Map additionalProperties) { - this.inheritDefault = inheritDefault; - this.barColor = barColor; - this.logo = logo; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("inheritDefault") - public Optional getInheritDefault() { - return inheritDefault; - } - - @JsonProperty("barColor") - public Optional getBarColor() { - return barColor; - } - - @JsonProperty("logo") - public Logo getLogo() { - return logo; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof EmailHeader && equalTo((EmailHeader) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(EmailHeader other) { - return inheritDefault.equals(other.inheritDefault) - && barColor.equals(other.barColor) - && logo.equals(other.logo); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.inheritDefault, this.barColor, this.logo); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static LogoStage builder() { - return new Builder(); - } - - public interface LogoStage { - _FinalStage logo(Logo logo); - - Builder from(EmailHeader other); - } - - public interface _FinalStage { - EmailHeader build(); - - _FinalStage inheritDefault(Optional inheritDefault); - - _FinalStage inheritDefault(Boolean inheritDefault); - - _FinalStage barColor(Optional barColor); - - _FinalStage barColor(String barColor); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements LogoStage, _FinalStage { - private Logo logo; - - private Optional barColor = Optional.empty(); - - private Optional inheritDefault = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(EmailHeader other) { - inheritDefault(other.getInheritDefault()); - barColor(other.getBarColor()); - logo(other.getLogo()); - return this; - } - - @java.lang.Override - @JsonSetter("logo") - public _FinalStage logo(Logo logo) { - this.logo = logo; - return this; - } - - @java.lang.Override - public _FinalStage barColor(String barColor) { - this.barColor = Optional.of(barColor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "barColor", nulls = Nulls.SKIP) - public _FinalStage barColor(Optional barColor) { - this.barColor = barColor; - return this; - } - - @java.lang.Override - public _FinalStage inheritDefault(Boolean inheritDefault) { - this.inheritDefault = Optional.of(inheritDefault); - return this; - } - - @java.lang.Override - @JsonSetter(value = "inheritDefault", nulls = Nulls.SKIP) - public _FinalStage inheritDefault(Optional inheritDefault) { - this.inheritDefault = inheritDefault; - return this; - } - - @java.lang.Override - public EmailHeader build() { - return new EmailHeader(inheritDefault, barColor, logo, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ExpiresInType.java b/src/main/java/com/courier/api/resources/send/types/ExpiresInType.java deleted file mode 100644 index db5f80e1..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ExpiresInType.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ExpiresInType.Deserializer.class) -public final class ExpiresInType { - private final Object value; - - private final int type; - - private ExpiresInType(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((int) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ExpiresInType && equalTo((ExpiresInType) other); - } - - private boolean equalTo(ExpiresInType other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ExpiresInType of(String value) { - return new ExpiresInType(value, 0); - } - - public static ExpiresInType of(int value) { - return new ExpiresInType(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(int value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ExpiresInType.class); - } - - @java.lang.Override - public ExpiresInType deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - if (value instanceof Integer) { - return of((Integer) value); - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Expiry.java b/src/main/java/com/courier/api/resources/send/types/Expiry.java deleted file mode 100644 index 1f67d867..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Expiry.java +++ /dev/null @@ -1,145 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Expiry.Builder.class) -public final class Expiry { - private final Optional expiresAt; - - private final ExpiresInType expiresIn; - - private final Map additionalProperties; - - private Expiry(Optional expiresAt, ExpiresInType expiresIn, Map additionalProperties) { - this.expiresAt = expiresAt; - this.expiresIn = expiresIn; - this.additionalProperties = additionalProperties; - } - - /** - * @return An epoch timestamp or ISO8601 timestamp with timezone (YYYY-MM-DDThh:mm:ss.sTZD) that describes the time in which a message expires. - */ - @JsonProperty("expires_at") - public Optional getExpiresAt() { - return expiresAt; - } - - /** - * @return A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). - */ - @JsonProperty("expires_in") - public ExpiresInType getExpiresIn() { - return expiresIn; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Expiry && equalTo((Expiry) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Expiry other) { - return expiresAt.equals(other.expiresAt) && expiresIn.equals(other.expiresIn); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.expiresAt, this.expiresIn); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ExpiresInStage builder() { - return new Builder(); - } - - public interface ExpiresInStage { - _FinalStage expiresIn(ExpiresInType expiresIn); - - Builder from(Expiry other); - } - - public interface _FinalStage { - Expiry build(); - - _FinalStage expiresAt(Optional expiresAt); - - _FinalStage expiresAt(String expiresAt); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ExpiresInStage, _FinalStage { - private ExpiresInType expiresIn; - - private Optional expiresAt = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Expiry other) { - expiresAt(other.getExpiresAt()); - expiresIn(other.getExpiresIn()); - return this; - } - - /** - *

A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("expires_in") - public _FinalStage expiresIn(ExpiresInType expiresIn) { - this.expiresIn = expiresIn; - return this; - } - - /** - *

An epoch timestamp or ISO8601 timestamp with timezone (YYYY-MM-DDThh:mm:ss.sTZD) that describes the time in which a message expires.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiresAt(String expiresAt) { - this.expiresAt = Optional.of(expiresAt); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expires_at", nulls = Nulls.SKIP) - public _FinalStage expiresAt(Optional expiresAt) { - this.expiresAt = expiresAt; - return this; - } - - @java.lang.Override - public Expiry build() { - return new Expiry(expiresAt, expiresIn, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/IActionButtonStyle.java b/src/main/java/com/courier/api/resources/send/types/IActionButtonStyle.java deleted file mode 100644 index 7e94015c..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IActionButtonStyle.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum IActionButtonStyle { - BUTTON("button"), - - LINK("link"); - - private final String value; - - IActionButtonStyle(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/IAlignment.java b/src/main/java/com/courier/api/resources/send/types/IAlignment.java deleted file mode 100644 index bb690423..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IAlignment.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum IAlignment { - CENTER("center"), - - LEFT("left"), - - RIGHT("right"), - - FULL("full"); - - private final String value; - - IAlignment(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/IBaseMessage.java b/src/main/java/com/courier/api/resources/send/types/IBaseMessage.java deleted file mode 100644 index 51b3f9d9..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IBaseMessage.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import java.util.Map; -import java.util.Optional; - -public interface IBaseMessage { - Optional> getData(); - - Optional getBrandId(); - - Optional> getChannels(); - - Optional getContext(); - - Optional getMetadata(); - - Optional getPreferences(); - - Optional> getProviders(); - - Optional getRouting(); - - Optional getTimeout(); - - Optional getDelay(); - - Optional getExpiry(); -} diff --git a/src/main/java/com/courier/api/resources/send/types/IBaseMessageSendTo.java b/src/main/java/com/courier/api/resources/send/types/IBaseMessageSendTo.java deleted file mode 100644 index 845c1414..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IBaseMessageSendTo.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import java.util.Optional; - -public interface IBaseMessageSendTo { - Optional getTo(); -} diff --git a/src/main/java/com/courier/api/resources/send/types/IBrandTemplate.java b/src/main/java/com/courier/api/resources/send/types/IBrandTemplate.java deleted file mode 100644 index 44a234bc..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IBrandTemplate.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import java.util.Optional; - -public interface IBrandTemplate { - Optional getBackgroundColor(); - - Optional getBlocksBackgroundColor(); - - boolean getEnabled(); - - Optional getFooter(); - - Optional getHead(); - - Optional getHeader(); - - Optional getWidth(); -} diff --git a/src/main/java/com/courier/api/resources/send/types/IElementalBaseNode.java b/src/main/java/com/courier/api/resources/send/types/IElementalBaseNode.java deleted file mode 100644 index 119770b8..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IElementalBaseNode.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import java.util.List; -import java.util.Optional; - -public interface IElementalBaseNode { - Optional> getChannels(); - - Optional getRef(); - - Optional getIf(); - - Optional getLoop(); -} diff --git a/src/main/java/com/courier/api/resources/send/types/IListPatternRecipientType.java b/src/main/java/com/courier/api/resources/send/types/IListPatternRecipientType.java deleted file mode 100644 index 49ae5cb5..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IListPatternRecipientType.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -public interface IListPatternRecipientType {} diff --git a/src/main/java/com/courier/api/resources/send/types/IListRecipientType.java b/src/main/java/com/courier/api/resources/send/types/IListRecipientType.java deleted file mode 100644 index d7841555..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IListRecipientType.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -public interface IListRecipientType {} diff --git a/src/main/java/com/courier/api/resources/send/types/IProfilePreferences.java b/src/main/java/com/courier/api/resources/send/types/IProfilePreferences.java deleted file mode 100644 index 73f92b44..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IProfilePreferences.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = IProfilePreferences.Builder.class) -public final class IProfilePreferences { - private final Optional> categories; - - private final Map notifications; - - private final Optional templateId; - - private final Map additionalProperties; - - private IProfilePreferences( - Optional> categories, - Map notifications, - Optional templateId, - Map additionalProperties) { - this.categories = categories; - this.notifications = notifications; - this.templateId = templateId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("categories") - public Optional> getCategories() { - return categories; - } - - @JsonProperty("notifications") - public Map getNotifications() { - return notifications; - } - - @JsonProperty("templateId") - public Optional getTemplateId() { - return templateId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof IProfilePreferences && equalTo((IProfilePreferences) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(IProfilePreferences other) { - return categories.equals(other.categories) - && notifications.equals(other.notifications) - && templateId.equals(other.templateId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.categories, this.notifications, this.templateId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> categories = Optional.empty(); - - private Map notifications = new LinkedHashMap<>(); - - private Optional templateId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(IProfilePreferences other) { - categories(other.getCategories()); - notifications(other.getNotifications()); - templateId(other.getTemplateId()); - return this; - } - - @JsonSetter(value = "categories", nulls = Nulls.SKIP) - public Builder categories(Optional> categories) { - this.categories = categories; - return this; - } - - public Builder categories(Map categories) { - this.categories = Optional.of(categories); - return this; - } - - @JsonSetter(value = "notifications", nulls = Nulls.SKIP) - public Builder notifications(Map notifications) { - this.notifications.clear(); - this.notifications.putAll(notifications); - return this; - } - - public Builder putAllNotifications(Map notifications) { - this.notifications.putAll(notifications); - return this; - } - - public Builder notifications(String key, Preference value) { - this.notifications.put(key, value); - return this; - } - - @JsonSetter(value = "templateId", nulls = Nulls.SKIP) - public Builder templateId(Optional templateId) { - this.templateId = templateId; - return this; - } - - public Builder templateId(String templateId) { - this.templateId = Optional.of(templateId); - return this; - } - - public IProfilePreferences build() { - return new IProfilePreferences(categories, notifications, templateId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/IUserRecipientType.java b/src/main/java/com/courier/api/resources/send/types/IUserRecipientType.java deleted file mode 100644 index d7368e68..00000000 --- a/src/main/java/com/courier/api/resources/send/types/IUserRecipientType.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -public interface IUserRecipientType {} diff --git a/src/main/java/com/courier/api/resources/send/types/Icons.java b/src/main/java/com/courier/api/resources/send/types/Icons.java deleted file mode 100644 index 793de7c6..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Icons.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Icons.Builder.class) -public final class Icons { - private final Optional bell; - - private final Optional message; - - private final Map additionalProperties; - - private Icons(Optional bell, Optional message, Map additionalProperties) { - this.bell = bell; - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("bell") - public Optional getBell() { - return bell; - } - - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Icons && equalTo((Icons) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Icons other) { - return bell.equals(other.bell) && message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.bell, this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional bell = Optional.empty(); - - private Optional message = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Icons other) { - bell(other.getBell()); - message(other.getMessage()); - return this; - } - - @JsonSetter(value = "bell", nulls = Nulls.SKIP) - public Builder bell(Optional bell) { - this.bell = bell; - return this; - } - - public Builder bell(String bell) { - this.bell = Optional.of(bell); - return this; - } - - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public Builder message(Optional message) { - this.message = message; - return this; - } - - public Builder message(String message) { - this.message = Optional.of(message); - return this; - } - - public Icons build() { - return new Icons(bell, message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/InAppPlacement.java b/src/main/java/com/courier/api/resources/send/types/InAppPlacement.java deleted file mode 100644 index 7fe26c38..00000000 --- a/src/main/java/com/courier/api/resources/send/types/InAppPlacement.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum InAppPlacement { - TOP("top"), - - BOTTOM("bottom"), - - LEFT("left"), - - RIGHT("right"); - - private final String value; - - InAppPlacement(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/InvalidListPatternRecipient.java b/src/main/java/com/courier/api/resources/send/types/InvalidListPatternRecipient.java deleted file mode 100644 index b850144f..00000000 --- a/src/main/java/com/courier/api/resources/send/types/InvalidListPatternRecipient.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InvalidListPatternRecipient.Builder.class) -public final class InvalidListPatternRecipient { - private final String userId; - - private final String listId; - - private final Map additionalProperties; - - private InvalidListPatternRecipient(String userId, String listId, Map additionalProperties) { - this.userId = userId; - this.listId = listId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @JsonProperty("list_id") - public String getListId() { - return listId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvalidListPatternRecipient && equalTo((InvalidListPatternRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InvalidListPatternRecipient other) { - return userId.equals(other.userId) && listId.equals(other.listId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.listId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - ListIdStage userId(String userId); - - Builder from(InvalidListPatternRecipient other); - } - - public interface ListIdStage { - _FinalStage listId(String listId); - } - - public interface _FinalStage { - InvalidListPatternRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, ListIdStage, _FinalStage { - private String userId; - - private String listId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(InvalidListPatternRecipient other) { - userId(other.getUserId()); - listId(other.getListId()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public ListIdStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - @JsonSetter("list_id") - public _FinalStage listId(String listId) { - this.listId = listId; - return this; - } - - @java.lang.Override - public InvalidListPatternRecipient build() { - return new InvalidListPatternRecipient(userId, listId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/InvalidListRecipient.java b/src/main/java/com/courier/api/resources/send/types/InvalidListRecipient.java deleted file mode 100644 index 34aa755d..00000000 --- a/src/main/java/com/courier/api/resources/send/types/InvalidListRecipient.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InvalidListRecipient.Builder.class) -public final class InvalidListRecipient { - private final String userId; - - private final String listPattern; - - private final Map additionalProperties; - - private InvalidListRecipient(String userId, String listPattern, Map additionalProperties) { - this.userId = userId; - this.listPattern = listPattern; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @JsonProperty("list_pattern") - public String getListPattern() { - return listPattern; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvalidListRecipient && equalTo((InvalidListRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InvalidListRecipient other) { - return userId.equals(other.userId) && listPattern.equals(other.listPattern); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.listPattern); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - ListPatternStage userId(String userId); - - Builder from(InvalidListRecipient other); - } - - public interface ListPatternStage { - _FinalStage listPattern(String listPattern); - } - - public interface _FinalStage { - InvalidListRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, ListPatternStage, _FinalStage { - private String userId; - - private String listPattern; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(InvalidListRecipient other) { - userId(other.getUserId()); - listPattern(other.getListPattern()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public ListPatternStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - @JsonSetter("list_pattern") - public _FinalStage listPattern(String listPattern) { - this.listPattern = listPattern; - return this; - } - - @java.lang.Override - public InvalidListRecipient build() { - return new InvalidListRecipient(userId, listPattern, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/InvalidUserRecipient.java b/src/main/java/com/courier/api/resources/send/types/InvalidUserRecipient.java deleted file mode 100644 index e5fd3915..00000000 --- a/src/main/java/com/courier/api/resources/send/types/InvalidUserRecipient.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = InvalidUserRecipient.Builder.class) -public final class InvalidUserRecipient { - private final String listId; - - private final String listPattern; - - private final Map additionalProperties; - - private InvalidUserRecipient(String listId, String listPattern, Map additionalProperties) { - this.listId = listId; - this.listPattern = listPattern; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("list_id") - public String getListId() { - return listId; - } - - @JsonProperty("list_pattern") - public String getListPattern() { - return listPattern; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof InvalidUserRecipient && equalTo((InvalidUserRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(InvalidUserRecipient other) { - return listId.equals(other.listId) && listPattern.equals(other.listPattern); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.listId, this.listPattern); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ListIdStage builder() { - return new Builder(); - } - - public interface ListIdStage { - ListPatternStage listId(String listId); - - Builder from(InvalidUserRecipient other); - } - - public interface ListPatternStage { - _FinalStage listPattern(String listPattern); - } - - public interface _FinalStage { - InvalidUserRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ListIdStage, ListPatternStage, _FinalStage { - private String listId; - - private String listPattern; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(InvalidUserRecipient other) { - listId(other.getListId()); - listPattern(other.getListPattern()); - return this; - } - - @java.lang.Override - @JsonSetter("list_id") - public ListPatternStage listId(String listId) { - this.listId = listId; - return this; - } - - @java.lang.Override - @JsonSetter("list_pattern") - public _FinalStage listPattern(String listPattern) { - this.listPattern = listPattern; - return this; - } - - @java.lang.Override - public InvalidUserRecipient build() { - return new InvalidUserRecipient(listId, listPattern, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ListFilter.java b/src/main/java/com/courier/api/resources/send/types/ListFilter.java deleted file mode 100644 index 54c1dfaf..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ListFilter.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListFilter.Builder.class) -public final class ListFilter { - private final String value; - - private final Map additionalProperties; - - private ListFilter(String value, Map additionalProperties) { - this.value = value; - this.additionalProperties = additionalProperties; - } - - /** - * @return Send to users only if they are member of the account - */ - @JsonProperty("operator") - public String getOperator() { - return "MEMBER_OF"; - } - - @JsonProperty("path") - public String getPath() { - return "account_id"; - } - - @JsonProperty("value") - public String getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListFilter && equalTo((ListFilter) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListFilter other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ValueStage builder() { - return new Builder(); - } - - public interface ValueStage { - _FinalStage value(String value); - - Builder from(ListFilter other); - } - - public interface _FinalStage { - ListFilter build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ValueStage, _FinalStage { - private String value; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListFilter other) { - value(other.getValue()); - return this; - } - - @java.lang.Override - @JsonSetter("value") - public _FinalStage value(String value) { - this.value = value; - return this; - } - - @java.lang.Override - public ListFilter build() { - return new ListFilter(value, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ListPatternRecipient.java b/src/main/java/com/courier/api/resources/send/types/ListPatternRecipient.java deleted file mode 100644 index d16ef711..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ListPatternRecipient.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListPatternRecipient.Builder.class) -public final class ListPatternRecipient implements IListPatternRecipientType { - private final Optional listPattern; - - private final Optional> data; - - private final Map additionalProperties; - - private ListPatternRecipient( - Optional listPattern, - Optional> data, - Map additionalProperties) { - this.listPattern = listPattern; - this.data = data; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("list_pattern") - public Optional getListPattern() { - return listPattern; - } - - @JsonProperty("data") - public Optional> getData() { - return data; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListPatternRecipient && equalTo((ListPatternRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListPatternRecipient other) { - return listPattern.equals(other.listPattern) && data.equals(other.data); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.listPattern, this.data); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional listPattern = Optional.empty(); - - private Optional> data = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListPatternRecipient other) { - listPattern(other.getListPattern()); - data(other.getData()); - return this; - } - - @JsonSetter(value = "list_pattern", nulls = Nulls.SKIP) - public Builder listPattern(Optional listPattern) { - this.listPattern = listPattern; - return this; - } - - public Builder listPattern(String listPattern) { - this.listPattern = Optional.of(listPattern); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - public ListPatternRecipient build() { - return new ListPatternRecipient(listPattern, data, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ListPatternRecipientType.java b/src/main/java/com/courier/api/resources/send/types/ListPatternRecipientType.java deleted file mode 100644 index 9a7c62af..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ListPatternRecipientType.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListPatternRecipientType.Builder.class) -public final class ListPatternRecipientType implements IListPatternRecipientType { - private final Map additionalProperties; - - private ListPatternRecipientType(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListPatternRecipientType; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListPatternRecipientType other) { - return this; - } - - public ListPatternRecipientType build() { - return new ListPatternRecipientType(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ListRecipient.java b/src/main/java/com/courier/api/resources/send/types/ListRecipient.java deleted file mode 100644 index 88c5e521..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ListRecipient.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListRecipient.Builder.class) -public final class ListRecipient implements IListRecipientType { - private final Optional listId; - - private final Optional> data; - - private final Optional> filters; - - private final Map additionalProperties; - - private ListRecipient( - Optional listId, - Optional> data, - Optional> filters, - Map additionalProperties) { - this.listId = listId; - this.data = data; - this.filters = filters; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("list_id") - public Optional getListId() { - return listId; - } - - @JsonProperty("data") - public Optional> getData() { - return data; - } - - @JsonProperty("filters") - public Optional> getFilters() { - return filters; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListRecipient && equalTo((ListRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListRecipient other) { - return listId.equals(other.listId) && data.equals(other.data) && filters.equals(other.filters); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.listId, this.data, this.filters); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional listId = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional> filters = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListRecipient other) { - listId(other.getListId()); - data(other.getData()); - filters(other.getFilters()); - return this; - } - - @JsonSetter(value = "list_id", nulls = Nulls.SKIP) - public Builder listId(Optional listId) { - this.listId = listId; - return this; - } - - public Builder listId(String listId) { - this.listId = Optional.of(listId); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "filters", nulls = Nulls.SKIP) - public Builder filters(Optional> filters) { - this.filters = filters; - return this; - } - - public Builder filters(List filters) { - this.filters = Optional.of(filters); - return this; - } - - public ListRecipient build() { - return new ListRecipient(listId, data, filters, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/ListRecipientType.java b/src/main/java/com/courier/api/resources/send/types/ListRecipientType.java deleted file mode 100644 index bca08536..00000000 --- a/src/main/java/com/courier/api/resources/send/types/ListRecipientType.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListRecipientType.Builder.class) -public final class ListRecipientType implements IListRecipientType { - private final Map additionalProperties; - - private ListRecipientType(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListRecipientType; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListRecipientType other) { - return this; - } - - public ListRecipientType build() { - return new ListRecipientType(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Locale.java b/src/main/java/com/courier/api/resources/send/types/Locale.java deleted file mode 100644 index e8360f5d..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Locale.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Locale.Builder.class) -public final class Locale { - private final String content; - - private final Map additionalProperties; - - private Locale(String content, Map additionalProperties) { - this.content = content; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("content") - public String getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Locale && equalTo((Locale) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Locale other) { - return content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ContentStage builder() { - return new Builder(); - } - - public interface ContentStage { - _FinalStage content(String content); - - Builder from(Locale other); - } - - public interface _FinalStage { - Locale build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ContentStage, _FinalStage { - private String content; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Locale other) { - content(other.getContent()); - return this; - } - - @java.lang.Override - @JsonSetter("content") - public _FinalStage content(String content) { - this.content = content; - return this; - } - - @java.lang.Override - public Locale build() { - return new Locale(content, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Logo.java b/src/main/java/com/courier/api/resources/send/types/Logo.java deleted file mode 100644 index 3c2a981d..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Logo.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Logo.Builder.class) -public final class Logo { - private final Optional href; - - private final Optional image; - - private final Map additionalProperties; - - private Logo(Optional href, Optional image, Map additionalProperties) { - this.href = href; - this.image = image; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("href") - public Optional getHref() { - return href; - } - - @JsonProperty("image") - public Optional getImage() { - return image; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Logo && equalTo((Logo) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Logo other) { - return href.equals(other.href) && image.equals(other.image); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.href, this.image); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional href = Optional.empty(); - - private Optional image = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Logo other) { - href(other.getHref()); - image(other.getImage()); - return this; - } - - @JsonSetter(value = "href", nulls = Nulls.SKIP) - public Builder href(Optional href) { - this.href = href; - return this; - } - - public Builder href(String href) { - this.href = Optional.of(href); - return this; - } - - @JsonSetter(value = "image", nulls = Nulls.SKIP) - public Builder image(Optional image) { - this.image = image; - return this; - } - - public Builder image(String image) { - this.image = Optional.of(image); - return this; - } - - public Logo build() { - return new Logo(href, image, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Message.java b/src/main/java/com/courier/api/resources/send/types/Message.java deleted file mode 100644 index bf528947..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Message.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = Message.Deserializer.class) -public final class Message { - private final Object value; - - private final int type; - - private Message(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((ContentMessage) this.value); - } else if (this.type == 1) { - return visitor.visit((TemplateMessage) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Message && equalTo((Message) other); - } - - private boolean equalTo(Message other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Message of(ContentMessage value) { - return new Message(value, 0); - } - - public static Message of(TemplateMessage value) { - return new Message(value, 1); - } - - public interface Visitor { - T visit(ContentMessage value); - - T visit(TemplateMessage value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Message.class); - } - - @java.lang.Override - public Message deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ContentMessage.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, TemplateMessage.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/MessageContext.java b/src/main/java/com/courier/api/resources/send/types/MessageContext.java deleted file mode 100644 index 32b6172e..00000000 --- a/src/main/java/com/courier/api/resources/send/types/MessageContext.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageContext.Builder.class) -public final class MessageContext { - private final Optional tenantId; - - private final Map additionalProperties; - - private MessageContext(Optional tenantId, Map additionalProperties) { - this.tenantId = tenantId; - this.additionalProperties = additionalProperties; - } - - /** - * @return An id of a tenant, see tenants api docs. - * Will load brand, default preferences and any other base context data associated with this tenant. - */ - @JsonProperty("tenant_id") - public Optional getTenantId() { - return tenantId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageContext && equalTo((MessageContext) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageContext other) { - return tenantId.equals(other.tenantId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional tenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MessageContext other) { - tenantId(other.getTenantId()); - return this; - } - - @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) - public Builder tenantId(Optional tenantId) { - this.tenantId = tenantId; - return this; - } - - public Builder tenantId(String tenantId) { - this.tenantId = Optional.of(tenantId); - return this; - } - - public MessageContext build() { - return new MessageContext(tenantId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/MessageMetadata.java b/src/main/java/com/courier/api/resources/send/types/MessageMetadata.java deleted file mode 100644 index f02245ad..00000000 --- a/src/main/java/com/courier/api/resources/send/types/MessageMetadata.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageMetadata.Builder.class) -public final class MessageMetadata { - private final Optional event; - - private final Optional> tags; - - private final Optional utm; - - private final Optional traceId; - - private final Map additionalProperties; - - private MessageMetadata( - Optional event, - Optional> tags, - Optional utm, - Optional traceId, - Map additionalProperties) { - this.event = event; - this.tags = tags; - this.utm = utm; - this.traceId = traceId; - this.additionalProperties = additionalProperties; - } - - /** - * @return An arbitrary string to tracks the event that generated this request (e.g. 'signup'). - */ - @JsonProperty("event") - public Optional getEvent() { - return event; - } - - /** - * @return An array of up to 9 tags you wish to associate with this request (and corresponding messages) for later analysis. Individual tags cannot be more than 30 characters in length. - */ - @JsonProperty("tags") - public Optional> getTags() { - return tags; - } - - /** - * @return Identify the campaign that refers traffic to a specific website, and attributes the browser's website session. - */ - @JsonProperty("utm") - public Optional getUtm() { - return utm; - } - - /** - * @return A unique ID used to correlate this request to processing on your servers. Note: Courier does not verify the uniqueness of this ID. - */ - @JsonProperty("trace_id") - public Optional getTraceId() { - return traceId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageMetadata && equalTo((MessageMetadata) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageMetadata other) { - return event.equals(other.event) - && tags.equals(other.tags) - && utm.equals(other.utm) - && traceId.equals(other.traceId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.event, this.tags, this.utm, this.traceId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional event = Optional.empty(); - - private Optional> tags = Optional.empty(); - - private Optional utm = Optional.empty(); - - private Optional traceId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MessageMetadata other) { - event(other.getEvent()); - tags(other.getTags()); - utm(other.getUtm()); - traceId(other.getTraceId()); - return this; - } - - @JsonSetter(value = "event", nulls = Nulls.SKIP) - public Builder event(Optional event) { - this.event = event; - return this; - } - - public Builder event(String event) { - this.event = Optional.of(event); - return this; - } - - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public Builder tags(Optional> tags) { - this.tags = tags; - return this; - } - - public Builder tags(List tags) { - this.tags = Optional.of(tags); - return this; - } - - @JsonSetter(value = "utm", nulls = Nulls.SKIP) - public Builder utm(Optional utm) { - this.utm = utm; - return this; - } - - public Builder utm(Utm utm) { - this.utm = Optional.of(utm); - return this; - } - - @JsonSetter(value = "trace_id", nulls = Nulls.SKIP) - public Builder traceId(Optional traceId) { - this.traceId = traceId; - return this; - } - - public Builder traceId(String traceId) { - this.traceId = Optional.of(traceId); - return this; - } - - public MessageMetadata build() { - return new MessageMetadata(event, tags, utm, traceId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/MessagePreferences.java b/src/main/java/com/courier/api/resources/send/types/MessagePreferences.java deleted file mode 100644 index 557a9236..00000000 --- a/src/main/java/com/courier/api/resources/send/types/MessagePreferences.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessagePreferences.Builder.class) -public final class MessagePreferences { - private final String subscriptionTopicId; - - private final Map additionalProperties; - - private MessagePreferences(String subscriptionTopicId, Map additionalProperties) { - this.subscriptionTopicId = subscriptionTopicId; - this.additionalProperties = additionalProperties; - } - - /** - * @return The ID of the subscription topic you want to apply to the message. If this is a templated message, it will override the subscription topic if already associated - */ - @JsonProperty("subscription_topic_id") - public String getSubscriptionTopicId() { - return subscriptionTopicId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessagePreferences && equalTo((MessagePreferences) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessagePreferences other) { - return subscriptionTopicId.equals(other.subscriptionTopicId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.subscriptionTopicId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static SubscriptionTopicIdStage builder() { - return new Builder(); - } - - public interface SubscriptionTopicIdStage { - _FinalStage subscriptionTopicId(String subscriptionTopicId); - - Builder from(MessagePreferences other); - } - - public interface _FinalStage { - MessagePreferences build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SubscriptionTopicIdStage, _FinalStage { - private String subscriptionTopicId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MessagePreferences other) { - subscriptionTopicId(other.getSubscriptionTopicId()); - return this; - } - - /** - *

The ID of the subscription topic you want to apply to the message. If this is a templated message, it will override the subscription topic if already associated

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("subscription_topic_id") - public _FinalStage subscriptionTopicId(String subscriptionTopicId) { - this.subscriptionTopicId = subscriptionTopicId; - return this; - } - - @java.lang.Override - public MessagePreferences build() { - return new MessagePreferences(subscriptionTopicId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/MessageProvidersType.java b/src/main/java/com/courier/api/resources/send/types/MessageProvidersType.java deleted file mode 100644 index c8824cee..00000000 --- a/src/main/java/com/courier/api/resources/send/types/MessageProvidersType.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MessageProvidersType.Builder.class) -public final class MessageProvidersType { - private final Optional> override; - - private final Optional if_; - - private final Optional timeouts; - - private final Optional metadata; - - private final Map additionalProperties; - - private MessageProvidersType( - Optional> override, - Optional if_, - Optional timeouts, - Optional metadata, - Map additionalProperties) { - this.override = override; - this.if_ = if_; - this.timeouts = timeouts; - this.metadata = metadata; - this.additionalProperties = additionalProperties; - } - - /** - * @return Provider specific overrides. - */ - @JsonProperty("override") - public Optional> getOverride() { - return override; - } - - /** - * @return A JavaScript conditional expression to determine if the message should - * be sent through the provider. Has access to the data and profile object. - * Only applies when a custom routing strategy is defined. - * For example, data.name === profile.name - */ - @JsonProperty("if") - public Optional getIf() { - return if_; - } - - @JsonProperty("timeouts") - public Optional getTimeouts() { - return timeouts; - } - - @JsonProperty("metadata") - public Optional getMetadata() { - return metadata; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageProvidersType && equalTo((MessageProvidersType) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MessageProvidersType other) { - return override.equals(other.override) - && if_.equals(other.if_) - && timeouts.equals(other.timeouts) - && metadata.equals(other.metadata); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.override, this.if_, this.timeouts, this.metadata); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> override = Optional.empty(); - - private Optional if_ = Optional.empty(); - - private Optional timeouts = Optional.empty(); - - private Optional metadata = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(MessageProvidersType other) { - override(other.getOverride()); - if_(other.getIf()); - timeouts(other.getTimeouts()); - metadata(other.getMetadata()); - return this; - } - - @JsonSetter(value = "override", nulls = Nulls.SKIP) - public Builder override(Optional> override) { - this.override = override; - return this; - } - - public Builder override(Map override) { - this.override = Optional.of(override); - return this; - } - - @JsonSetter(value = "if", nulls = Nulls.SKIP) - public Builder if_(Optional if_) { - this.if_ = if_; - return this; - } - - public Builder if_(String if_) { - this.if_ = Optional.of(if_); - return this; - } - - @JsonSetter(value = "timeouts", nulls = Nulls.SKIP) - public Builder timeouts(Optional timeouts) { - this.timeouts = timeouts; - return this; - } - - public Builder timeouts(Integer timeouts) { - this.timeouts = Optional.of(timeouts); - return this; - } - - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public Builder metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - public Builder metadata(Metadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - public MessageProvidersType build() { - return new MessageProvidersType(override, if_, timeouts, metadata, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/MessageRecipient.java b/src/main/java/com/courier/api/resources/send/types/MessageRecipient.java deleted file mode 100644 index d24e9edc..00000000 --- a/src/main/java/com/courier/api/resources/send/types/MessageRecipient.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.List; -import java.util.Objects; - -@JsonDeserialize(using = MessageRecipient.Deserializer.class) -public final class MessageRecipient { - private final Object value; - - private final int type; - - private MessageRecipient(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((Recipient) this.value); - } else if (this.type == 1) { - return visitor.visit((List) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MessageRecipient && equalTo((MessageRecipient) other); - } - - private boolean equalTo(MessageRecipient other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static MessageRecipient of(Recipient value) { - return new MessageRecipient(value, 0); - } - - public static MessageRecipient of(List value) { - return new MessageRecipient(value, 1); - } - - public interface Visitor { - T visit(Recipient value); - - T visit(List value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(MessageRecipient.class); - } - - @java.lang.Override - public MessageRecipient deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, Recipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Metadata.java b/src/main/java/com/courier/api/resources/send/types/Metadata.java deleted file mode 100644 index e00abad3..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Metadata.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Metadata.Builder.class) -public final class Metadata { - private final Optional utm; - - private final Map additionalProperties; - - private Metadata(Optional utm, Map additionalProperties) { - this.utm = utm; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("utm") - public Optional getUtm() { - return utm; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Metadata && equalTo((Metadata) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Metadata other) { - return utm.equals(other.utm); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.utm); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional utm = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Metadata other) { - utm(other.getUtm()); - return this; - } - - @JsonSetter(value = "utm", nulls = Nulls.SKIP) - public Builder utm(Optional utm) { - this.utm = utm; - return this; - } - - public Builder utm(Utm utm) { - this.utm = Optional.of(utm); - return this; - } - - public Metadata build() { - return new Metadata(utm, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/MsTeamsRecipient.java b/src/main/java/com/courier/api/resources/send/types/MsTeamsRecipient.java deleted file mode 100644 index dd748a5b..00000000 --- a/src/main/java/com/courier/api/resources/send/types/MsTeamsRecipient.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.profiles.types.MsTeams; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = MsTeamsRecipient.Builder.class) -public final class MsTeamsRecipient { - private final MsTeams msTeams; - - private final Map additionalProperties; - - private MsTeamsRecipient(MsTeams msTeams, Map additionalProperties) { - this.msTeams = msTeams; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("ms_teams") - public MsTeams getMsTeams() { - return msTeams; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof MsTeamsRecipient && equalTo((MsTeamsRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(MsTeamsRecipient other) { - return msTeams.equals(other.msTeams); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.msTeams); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MsTeamsStage builder() { - return new Builder(); - } - - public interface MsTeamsStage { - _FinalStage msTeams(MsTeams msTeams); - - Builder from(MsTeamsRecipient other); - } - - public interface _FinalStage { - MsTeamsRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MsTeamsStage, _FinalStage { - private MsTeams msTeams; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(MsTeamsRecipient other) { - msTeams(other.getMsTeams()); - return this; - } - - @java.lang.Override - @JsonSetter("ms_teams") - public _FinalStage msTeams(MsTeams msTeams) { - this.msTeams = msTeams; - return this; - } - - @java.lang.Override - public MsTeamsRecipient build() { - return new MsTeamsRecipient(msTeams, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/PagerdutyRecipient.java b/src/main/java/com/courier/api/resources/send/types/PagerdutyRecipient.java deleted file mode 100644 index 7fac9aa2..00000000 --- a/src/main/java/com/courier/api/resources/send/types/PagerdutyRecipient.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.profiles.types.Pagerduty; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PagerdutyRecipient.Builder.class) -public final class PagerdutyRecipient { - private final Pagerduty pagerduty; - - private final Map additionalProperties; - - private PagerdutyRecipient(Pagerduty pagerduty, Map additionalProperties) { - this.pagerduty = pagerduty; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("pagerduty") - public Pagerduty getPagerduty() { - return pagerduty; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PagerdutyRecipient && equalTo((PagerdutyRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PagerdutyRecipient other) { - return pagerduty.equals(other.pagerduty); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.pagerduty); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagerdutyStage builder() { - return new Builder(); - } - - public interface PagerdutyStage { - _FinalStage pagerduty(Pagerduty pagerduty); - - Builder from(PagerdutyRecipient other); - } - - public interface _FinalStage { - PagerdutyRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagerdutyStage, _FinalStage { - private Pagerduty pagerduty; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PagerdutyRecipient other) { - pagerduty(other.getPagerduty()); - return this; - } - - @java.lang.Override - @JsonSetter("pagerduty") - public _FinalStage pagerduty(Pagerduty pagerduty) { - this.pagerduty = pagerduty; - return this; - } - - @java.lang.Override - public PagerdutyRecipient build() { - return new PagerdutyRecipient(pagerduty, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Preference.java b/src/main/java/com/courier/api/resources/send/types/Preference.java deleted file mode 100644 index 5f82434b..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Preference.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ChannelPreference; -import com.courier.api.resources.commons.types.PreferenceStatus; -import com.courier.api.resources.commons.types.Rule; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Preference.Builder.class) -public final class Preference { - private final PreferenceStatus status; - - private final Optional> rules; - - private final Optional> channelPreferences; - - private final Optional source; - - private final Map additionalProperties; - - private Preference( - PreferenceStatus status, - Optional> rules, - Optional> channelPreferences, - Optional source, - Map additionalProperties) { - this.status = status; - this.rules = rules; - this.channelPreferences = channelPreferences; - this.source = source; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public PreferenceStatus getStatus() { - return status; - } - - @JsonProperty("rules") - public Optional> getRules() { - return rules; - } - - @JsonProperty("channel_preferences") - public Optional> getChannelPreferences() { - return channelPreferences; - } - - @JsonProperty("source") - public Optional getSource() { - return source; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Preference && equalTo((Preference) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Preference other) { - return status.equals(other.status) - && rules.equals(other.rules) - && channelPreferences.equals(other.channelPreferences) - && source.equals(other.source); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.status, this.rules, this.channelPreferences, this.source); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - _FinalStage status(PreferenceStatus status); - - Builder from(Preference other); - } - - public interface _FinalStage { - Preference build(); - - _FinalStage rules(Optional> rules); - - _FinalStage rules(List rules); - - _FinalStage channelPreferences(Optional> channelPreferences); - - _FinalStage channelPreferences(List channelPreferences); - - _FinalStage source(Optional source); - - _FinalStage source(ChannelSource source); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, _FinalStage { - private PreferenceStatus status; - - private Optional source = Optional.empty(); - - private Optional> channelPreferences = Optional.empty(); - - private Optional> rules = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Preference other) { - status(other.getStatus()); - rules(other.getRules()); - channelPreferences(other.getChannelPreferences()); - source(other.getSource()); - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(PreferenceStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - public _FinalStage source(ChannelSource source) { - this.source = Optional.of(source); - return this; - } - - @java.lang.Override - @JsonSetter(value = "source", nulls = Nulls.SKIP) - public _FinalStage source(Optional source) { - this.source = source; - return this; - } - - @java.lang.Override - public _FinalStage channelPreferences(List channelPreferences) { - this.channelPreferences = Optional.of(channelPreferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channel_preferences", nulls = Nulls.SKIP) - public _FinalStage channelPreferences(Optional> channelPreferences) { - this.channelPreferences = channelPreferences; - return this; - } - - @java.lang.Override - public _FinalStage rules(List rules) { - this.rules = Optional.of(rules); - return this; - } - - @java.lang.Override - @JsonSetter(value = "rules", nulls = Nulls.SKIP) - public _FinalStage rules(Optional> rules) { - this.rules = rules; - return this; - } - - @java.lang.Override - public Preference build() { - return new Preference(status, rules, channelPreferences, source, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Preferences.java b/src/main/java/com/courier/api/resources/send/types/Preferences.java deleted file mode 100644 index d8c161a2..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Preferences.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Preferences.Builder.class) -public final class Preferences { - private final List templateIds; - - private final Map additionalProperties; - - private Preferences(List templateIds, Map additionalProperties) { - this.templateIds = templateIds; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("templateIds") - public List getTemplateIds() { - return templateIds; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Preferences && equalTo((Preferences) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Preferences other) { - return templateIds.equals(other.templateIds); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.templateIds); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List templateIds = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Preferences other) { - templateIds(other.getTemplateIds()); - return this; - } - - @JsonSetter(value = "templateIds", nulls = Nulls.SKIP) - public Builder templateIds(List templateIds) { - this.templateIds.clear(); - this.templateIds.addAll(templateIds); - return this; - } - - public Builder addTemplateIds(String templateIds) { - this.templateIds.add(templateIds); - return this; - } - - public Builder addAllTemplateIds(List templateIds) { - this.templateIds.addAll(templateIds); - return this; - } - - public Preferences build() { - return new Preferences(templateIds, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Recipient.java b/src/main/java/com/courier/api/resources/send/types/Recipient.java deleted file mode 100644 index 0c179fde..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Recipient.java +++ /dev/null @@ -1,180 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Map; -import java.util.Objects; - -@JsonDeserialize(using = Recipient.Deserializer.class) -public final class Recipient { - private final Object value; - - private final int type; - - private Recipient(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((AudienceRecipient) this.value); - } else if (this.type == 1) { - return visitor.visit((ListRecipient) this.value); - } else if (this.type == 2) { - return visitor.visit((ListPatternRecipient) this.value); - } else if (this.type == 3) { - return visitor.visit((UserRecipient) this.value); - } else if (this.type == 4) { - return visitor.visit((SlackRecipient) this.value); - } else if (this.type == 5) { - return visitor.visit((MsTeamsRecipient) this.value); - } else if (this.type == 6) { - return visitor.visit((Map) this.value); - } else if (this.type == 7) { - return visitor.visit((PagerdutyRecipient) this.value); - } else if (this.type == 8) { - return visitor.visit((WebhookRecipient) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Recipient && equalTo((Recipient) other); - } - - private boolean equalTo(Recipient other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static Recipient of(AudienceRecipient value) { - return new Recipient(value, 0); - } - - public static Recipient of(ListRecipient value) { - return new Recipient(value, 1); - } - - public static Recipient of(ListPatternRecipient value) { - return new Recipient(value, 2); - } - - public static Recipient of(UserRecipient value) { - return new Recipient(value, 3); - } - - public static Recipient of(SlackRecipient value) { - return new Recipient(value, 4); - } - - public static Recipient of(MsTeamsRecipient value) { - return new Recipient(value, 5); - } - - public static Recipient of(Map value) { - return new Recipient(value, 6); - } - - public static Recipient of(PagerdutyRecipient value) { - return new Recipient(value, 7); - } - - public static Recipient of(WebhookRecipient value) { - return new Recipient(value, 8); - } - - public interface Visitor { - T visit(AudienceRecipient value); - - T visit(ListRecipient value); - - T visit(ListPatternRecipient value); - - T visit(UserRecipient value); - - T visit(SlackRecipient value); - - T visit(MsTeamsRecipient value); - - T visit(Map value); - - T visit(PagerdutyRecipient value); - - T visit(WebhookRecipient value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(Recipient.class); - } - - @java.lang.Override - public Recipient deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, AudienceRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ListRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, ListPatternRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, UserRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, SlackRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, MsTeamsRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, new TypeReference>() {})); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, PagerdutyRecipient.class)); - } catch (IllegalArgumentException e) { - } - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, WebhookRecipient.class)); - } catch (IllegalArgumentException e) { - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Routing.java b/src/main/java/com/courier/api/resources/send/types/Routing.java deleted file mode 100644 index 7d14f9f2..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Routing.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.notifications.types.MessageRoutingChannel; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Routing.Builder.class) -public final class Routing { - private final RoutingMethod method; - - private final List channels; - - private final Map additionalProperties; - - private Routing( - RoutingMethod method, List channels, Map additionalProperties) { - this.method = method; - this.channels = channels; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("method") - public RoutingMethod getMethod() { - return method; - } - - /** - * @return A list of channels or providers to send the message through. Can also recursively define - * sub-routing methods, which can be useful for defining advanced push notification - * delivery strategies. - */ - @JsonProperty("channels") - public List getChannels() { - return channels; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Routing && equalTo((Routing) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Routing other) { - return method.equals(other.method) && channels.equals(other.channels); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.method, this.channels); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MethodStage builder() { - return new Builder(); - } - - public interface MethodStage { - _FinalStage method(RoutingMethod method); - - Builder from(Routing other); - } - - public interface _FinalStage { - Routing build(); - - _FinalStage channels(List channels); - - _FinalStage addChannels(MessageRoutingChannel channels); - - _FinalStage addAllChannels(List channels); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MethodStage, _FinalStage { - private RoutingMethod method; - - private List channels = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Routing other) { - method(other.getMethod()); - channels(other.getChannels()); - return this; - } - - @java.lang.Override - @JsonSetter("method") - public _FinalStage method(RoutingMethod method) { - this.method = method; - return this; - } - - /** - *

A list of channels or providers to send the message through. Can also recursively define - * sub-routing methods, which can be useful for defining advanced push notification - * delivery strategies.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllChannels(List channels) { - this.channels.addAll(channels); - return this; - } - - /** - *

A list of channels or providers to send the message through. Can also recursively define - * sub-routing methods, which can be useful for defining advanced push notification - * delivery strategies.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addChannels(MessageRoutingChannel channels) { - this.channels.add(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(List channels) { - this.channels.clear(); - this.channels.addAll(channels); - return this; - } - - @java.lang.Override - public Routing build() { - return new Routing(method, channels, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/RoutingMethod.java b/src/main/java/com/courier/api/resources/send/types/RoutingMethod.java deleted file mode 100644 index c7f80970..00000000 --- a/src/main/java/com/courier/api/resources/send/types/RoutingMethod.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum RoutingMethod { - ALL("all"), - - SINGLE("single"); - - private final String value; - - RoutingMethod(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/RuleType.java b/src/main/java/com/courier/api/resources/send/types/RuleType.java deleted file mode 100644 index 71c7e1e1..00000000 --- a/src/main/java/com/courier/api/resources/send/types/RuleType.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum RuleType { - SNOOZE("snooze"), - - CHANNEL_PREFERENCES("channel_preferences"), - - STATUS("status"); - - private final String value; - - RuleType(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/SlackRecipient.java b/src/main/java/com/courier/api/resources/send/types/SlackRecipient.java deleted file mode 100644 index f290590d..00000000 --- a/src/main/java/com/courier/api/resources/send/types/SlackRecipient.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.profiles.types.Slack; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SlackRecipient.Builder.class) -public final class SlackRecipient { - private final Slack slack; - - private final Map additionalProperties; - - private SlackRecipient(Slack slack, Map additionalProperties) { - this.slack = slack; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("slack") - public Slack getSlack() { - return slack; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SlackRecipient && equalTo((SlackRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SlackRecipient other) { - return slack.equals(other.slack); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.slack); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static SlackStage builder() { - return new Builder(); - } - - public interface SlackStage { - _FinalStage slack(Slack slack); - - Builder from(SlackRecipient other); - } - - public interface _FinalStage { - SlackRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements SlackStage, _FinalStage { - private Slack slack; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SlackRecipient other) { - slack(other.getSlack()); - return this; - } - - @java.lang.Override - @JsonSetter("slack") - public _FinalStage slack(Slack slack) { - this.slack = slack; - return this; - } - - @java.lang.Override - public SlackRecipient build() { - return new SlackRecipient(slack, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/TemplateMessage.java b/src/main/java/com/courier/api/resources/send/types/TemplateMessage.java deleted file mode 100644 index 11190706..00000000 --- a/src/main/java/com/courier/api/resources/send/types/TemplateMessage.java +++ /dev/null @@ -1,580 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TemplateMessage.Builder.class) -public final class TemplateMessage implements IBaseMessage, IBaseMessageSendTo { - private final Optional> data; - - private final Optional brandId; - - private final Optional> channels; - - private final Optional context; - - private final Optional metadata; - - private final Optional preferences; - - private final Optional> providers; - - private final Optional routing; - - private final Optional timeout; - - private final Optional delay; - - private final Optional expiry; - - private final Optional to; - - private final String template; - - private final Map additionalProperties; - - private TemplateMessage( - Optional> data, - Optional brandId, - Optional> channels, - Optional context, - Optional metadata, - Optional preferences, - Optional> providers, - Optional routing, - Optional timeout, - Optional delay, - Optional expiry, - Optional to, - String template, - Map additionalProperties) { - this.data = data; - this.brandId = brandId; - this.channels = channels; - this.context = context; - this.metadata = metadata; - this.preferences = preferences; - this.providers = providers; - this.routing = routing; - this.timeout = timeout; - this.delay = delay; - this.expiry = expiry; - this.to = to; - this.template = template; - this.additionalProperties = additionalProperties; - } - - /** - * @return An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables. - */ - @JsonProperty("data") - @java.lang.Override - public Optional> getData() { - return data; - } - - @JsonProperty("brand_id") - @java.lang.Override - public Optional getBrandId() { - return brandId; - } - - /** - * @return "Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - @JsonProperty("channels") - @java.lang.Override - public Optional> getChannels() { - return channels; - } - - /** - * @return Context to load with this recipient. Will override any context set on message.context. - */ - @JsonProperty("context") - @java.lang.Override - public Optional getContext() { - return context; - } - - /** - * @return Metadata such as utm tracking attached with the notification through this channel. - */ - @JsonProperty("metadata") - @java.lang.Override - public Optional getMetadata() { - return metadata; - } - - @JsonProperty("preferences") - @java.lang.Override - public Optional getPreferences() { - return preferences; - } - - /** - * @return An object whose keys are valid provider identifiers which map to an object. - */ - @JsonProperty("providers") - @java.lang.Override - public Optional> getProviders() { - return providers; - } - - @JsonProperty("routing") - @java.lang.Override - public Optional getRouting() { - return routing; - } - - /** - * @return Time in ms to attempt the channel before failing over to the next available channel. - */ - @JsonProperty("timeout") - @java.lang.Override - public Optional getTimeout() { - return timeout; - } - - /** - * @return Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm') - */ - @JsonProperty("delay") - @java.lang.Override - public Optional getDelay() { - return delay; - } - - /** - * @return "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - @JsonProperty("expiry") - @java.lang.Override - public Optional getExpiry() { - return expiry; - } - - /** - * @return The recipient or a list of recipients of the message - */ - @JsonProperty("to") - @java.lang.Override - public Optional getTo() { - return to; - } - - /** - * @return The id of the notification template to be rendered and sent to the recipient(s). - * This field or the content field must be supplied. - */ - @JsonProperty("template") - public String getTemplate() { - return template; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TemplateMessage && equalTo((TemplateMessage) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TemplateMessage other) { - return data.equals(other.data) - && brandId.equals(other.brandId) - && channels.equals(other.channels) - && context.equals(other.context) - && metadata.equals(other.metadata) - && preferences.equals(other.preferences) - && providers.equals(other.providers) - && routing.equals(other.routing) - && timeout.equals(other.timeout) - && delay.equals(other.delay) - && expiry.equals(other.expiry) - && to.equals(other.to) - && template.equals(other.template); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.data, - this.brandId, - this.channels, - this.context, - this.metadata, - this.preferences, - this.providers, - this.routing, - this.timeout, - this.delay, - this.expiry, - this.to, - this.template); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TemplateStage builder() { - return new Builder(); - } - - public interface TemplateStage { - _FinalStage template(String template); - - Builder from(TemplateMessage other); - } - - public interface _FinalStage { - TemplateMessage build(); - - _FinalStage data(Optional> data); - - _FinalStage data(Map data); - - _FinalStage brandId(Optional brandId); - - _FinalStage brandId(String brandId); - - _FinalStage channels(Optional> channels); - - _FinalStage channels(Map channels); - - _FinalStage context(Optional context); - - _FinalStage context(MessageContext context); - - _FinalStage metadata(Optional metadata); - - _FinalStage metadata(MessageMetadata metadata); - - _FinalStage preferences(Optional preferences); - - _FinalStage preferences(MessagePreferences preferences); - - _FinalStage providers(Optional> providers); - - _FinalStage providers(Map providers); - - _FinalStage routing(Optional routing); - - _FinalStage routing(Routing routing); - - _FinalStage timeout(Optional timeout); - - _FinalStage timeout(Timeout timeout); - - _FinalStage delay(Optional delay); - - _FinalStage delay(Delay delay); - - _FinalStage expiry(Optional expiry); - - _FinalStage expiry(Expiry expiry); - - _FinalStage to(Optional to); - - _FinalStage to(MessageRecipient to); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TemplateStage, _FinalStage { - private String template; - - private Optional to = Optional.empty(); - - private Optional expiry = Optional.empty(); - - private Optional delay = Optional.empty(); - - private Optional timeout = Optional.empty(); - - private Optional routing = Optional.empty(); - - private Optional> providers = Optional.empty(); - - private Optional preferences = Optional.empty(); - - private Optional metadata = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional> channels = Optional.empty(); - - private Optional brandId = Optional.empty(); - - private Optional> data = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TemplateMessage other) { - data(other.getData()); - brandId(other.getBrandId()); - channels(other.getChannels()); - context(other.getContext()); - metadata(other.getMetadata()); - preferences(other.getPreferences()); - providers(other.getProviders()); - routing(other.getRouting()); - timeout(other.getTimeout()); - delay(other.getDelay()); - expiry(other.getExpiry()); - to(other.getTo()); - template(other.getTemplate()); - return this; - } - - /** - *

The id of the notification template to be rendered and sent to the recipient(s). - * This field or the content field must be supplied.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("template") - public _FinalStage template(String template) { - this.template = template; - return this; - } - - /** - *

The recipient or a list of recipients of the message

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage to(MessageRecipient to) { - this.to = Optional.of(to); - return this; - } - - @java.lang.Override - @JsonSetter(value = "to", nulls = Nulls.SKIP) - public _FinalStage to(Optional to) { - this.to = to; - return this; - } - - /** - *

"Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiry(Expiry expiry) { - this.expiry = Optional.of(expiry); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expiry", nulls = Nulls.SKIP) - public _FinalStage expiry(Optional expiry) { - this.expiry = expiry; - return this; - } - - /** - *

Defines the time to wait before delivering the message. You can specify one of the following options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like format that specifies the Delivery Window (e.g., 'Mo-Fr 08:00-18:00pm')

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage delay(Delay delay) { - this.delay = Optional.of(delay); - return this; - } - - @java.lang.Override - @JsonSetter(value = "delay", nulls = Nulls.SKIP) - public _FinalStage delay(Optional delay) { - this.delay = delay; - return this; - } - - /** - *

Time in ms to attempt the channel before failing over to the next available channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage timeout(Timeout timeout) { - this.timeout = Optional.of(timeout); - return this; - } - - @java.lang.Override - @JsonSetter(value = "timeout", nulls = Nulls.SKIP) - public _FinalStage timeout(Optional timeout) { - this.timeout = timeout; - return this; - } - - @java.lang.Override - public _FinalStage routing(Routing routing) { - this.routing = Optional.of(routing); - return this; - } - - @java.lang.Override - @JsonSetter(value = "routing", nulls = Nulls.SKIP) - public _FinalStage routing(Optional routing) { - this.routing = routing; - return this; - } - - /** - *

An object whose keys are valid provider identifiers which map to an object.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage providers(Map providers) { - this.providers = Optional.of(providers); - return this; - } - - @java.lang.Override - @JsonSetter(value = "providers", nulls = Nulls.SKIP) - public _FinalStage providers(Optional> providers) { - this.providers = providers; - return this; - } - - @java.lang.Override - public _FinalStage preferences(MessagePreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public _FinalStage preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - /** - *

Metadata such as utm tracking attached with the notification through this channel.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage metadata(MessageMetadata metadata) { - this.metadata = Optional.of(metadata); - return this; - } - - @java.lang.Override - @JsonSetter(value = "metadata", nulls = Nulls.SKIP) - public _FinalStage metadata(Optional metadata) { - this.metadata = metadata; - return this; - } - - /** - *

Context to load with this recipient. Will override any context set on message.context.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage context(MessageContext context) { - this.context = Optional.of(context); - return this; - } - - @java.lang.Override - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public _FinalStage context(Optional context) { - this.context = context; - return this; - } - - /** - *

"Define run-time configuration for one or more channels. If you don't specify channels, the default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook."

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage channels(Map channels) { - this.channels = Optional.of(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(Optional> channels) { - this.channels = channels; - return this; - } - - @java.lang.Override - public _FinalStage brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public _FinalStage brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - /** - *

An arbitrary object that includes any data you want to pass to the message. - * The data will populate the corresponding template or elements variables.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage data(Map data) { - this.data = Optional.of(data); - return this; - } - - @java.lang.Override - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public _FinalStage data(Optional> data) { - this.data = data; - return this; - } - - @java.lang.Override - public TemplateMessage build() { - return new TemplateMessage( - data, - brandId, - channels, - context, - metadata, - preferences, - providers, - routing, - timeout, - delay, - expiry, - to, - template, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/TextAlign.java b/src/main/java/com/courier/api/resources/send/types/TextAlign.java deleted file mode 100644 index d09f3e1a..00000000 --- a/src/main/java/com/courier/api/resources/send/types/TextAlign.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TextAlign { - LEFT("left"), - - CENTER("center"), - - RIGHT("right"); - - private final String value; - - TextAlign(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/TextStyle.java b/src/main/java/com/courier/api/resources/send/types/TextStyle.java deleted file mode 100644 index b5d14cce..00000000 --- a/src/main/java/com/courier/api/resources/send/types/TextStyle.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TextStyle { - TEXT("text"), - - H_1("h1"), - - H_2("h2"), - - SUBTEXT("subtext"); - - private final String value; - - TextStyle(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Timeout.java b/src/main/java/com/courier/api/resources/send/types/Timeout.java deleted file mode 100644 index 9bef070b..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Timeout.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Timeout.Builder.class) -public final class Timeout { - private final Optional> provider; - - private final Optional> channel; - - private final Optional message; - - private final Optional escalation; - - private final Optional criteria; - - private final Map additionalProperties; - - private Timeout( - Optional> provider, - Optional> channel, - Optional message, - Optional escalation, - Optional criteria, - Map additionalProperties) { - this.provider = provider; - this.channel = channel; - this.message = message; - this.escalation = escalation; - this.criteria = criteria; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("provider") - public Optional> getProvider() { - return provider; - } - - @JsonProperty("channel") - public Optional> getChannel() { - return channel; - } - - @JsonProperty("message") - public Optional getMessage() { - return message; - } - - @JsonProperty("escalation") - public Optional getEscalation() { - return escalation; - } - - @JsonProperty("criteria") - public Optional getCriteria() { - return criteria; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Timeout && equalTo((Timeout) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Timeout other) { - return provider.equals(other.provider) - && channel.equals(other.channel) - && message.equals(other.message) - && escalation.equals(other.escalation) - && criteria.equals(other.criteria); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.provider, this.channel, this.message, this.escalation, this.criteria); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> provider = Optional.empty(); - - private Optional> channel = Optional.empty(); - - private Optional message = Optional.empty(); - - private Optional escalation = Optional.empty(); - - private Optional criteria = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Timeout other) { - provider(other.getProvider()); - channel(other.getChannel()); - message(other.getMessage()); - escalation(other.getEscalation()); - criteria(other.getCriteria()); - return this; - } - - @JsonSetter(value = "provider", nulls = Nulls.SKIP) - public Builder provider(Optional> provider) { - this.provider = provider; - return this; - } - - public Builder provider(Map provider) { - this.provider = Optional.of(provider); - return this; - } - - @JsonSetter(value = "channel", nulls = Nulls.SKIP) - public Builder channel(Optional> channel) { - this.channel = channel; - return this; - } - - public Builder channel(Map channel) { - this.channel = Optional.of(channel); - return this; - } - - @JsonSetter(value = "message", nulls = Nulls.SKIP) - public Builder message(Optional message) { - this.message = message; - return this; - } - - public Builder message(Integer message) { - this.message = Optional.of(message); - return this; - } - - @JsonSetter(value = "escalation", nulls = Nulls.SKIP) - public Builder escalation(Optional escalation) { - this.escalation = escalation; - return this; - } - - public Builder escalation(Integer escalation) { - this.escalation = Optional.of(escalation); - return this; - } - - @JsonSetter(value = "criteria", nulls = Nulls.SKIP) - public Builder criteria(Optional criteria) { - this.criteria = criteria; - return this; - } - - public Builder criteria(Criteria criteria) { - this.criteria = Optional.of(criteria); - return this; - } - - public Timeout build() { - return new Timeout(provider, channel, message, escalation, criteria, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Timeouts.java b/src/main/java/com/courier/api/resources/send/types/Timeouts.java deleted file mode 100644 index 5a121d8b..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Timeouts.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Timeouts.Builder.class) -public final class Timeouts { - private final Optional provider; - - private final Optional channel; - - private final Map additionalProperties; - - private Timeouts(Optional provider, Optional channel, Map additionalProperties) { - this.provider = provider; - this.channel = channel; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("provider") - public Optional getProvider() { - return provider; - } - - @JsonProperty("channel") - public Optional getChannel() { - return channel; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Timeouts && equalTo((Timeouts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Timeouts other) { - return provider.equals(other.provider) && channel.equals(other.channel); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.provider, this.channel); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional provider = Optional.empty(); - - private Optional channel = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Timeouts other) { - provider(other.getProvider()); - channel(other.getChannel()); - return this; - } - - @JsonSetter(value = "provider", nulls = Nulls.SKIP) - public Builder provider(Optional provider) { - this.provider = provider; - return this; - } - - public Builder provider(Integer provider) { - this.provider = Optional.of(provider); - return this; - } - - @JsonSetter(value = "channel", nulls = Nulls.SKIP) - public Builder channel(Optional channel) { - this.channel = channel; - return this; - } - - public Builder channel(Integer channel) { - this.channel = Optional.of(channel); - return this; - } - - public Timeouts build() { - return new Timeouts(provider, channel, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/TrackingOverride.java b/src/main/java/com/courier/api/resources/send/types/TrackingOverride.java deleted file mode 100644 index 69a1eb34..00000000 --- a/src/main/java/com/courier/api/resources/send/types/TrackingOverride.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TrackingOverride.Builder.class) -public final class TrackingOverride { - private final boolean open; - - private final Map additionalProperties; - - private TrackingOverride(boolean open, Map additionalProperties) { - this.open = open; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("open") - public boolean getOpen() { - return open; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TrackingOverride && equalTo((TrackingOverride) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TrackingOverride other) { - return open == other.open; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.open); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static OpenStage builder() { - return new Builder(); - } - - public interface OpenStage { - _FinalStage open(boolean open); - - Builder from(TrackingOverride other); - } - - public interface _FinalStage { - TrackingOverride build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements OpenStage, _FinalStage { - private boolean open; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TrackingOverride other) { - open(other.getOpen()); - return this; - } - - @java.lang.Override - @JsonSetter("open") - public _FinalStage open(boolean open) { - this.open = open; - return this; - } - - @java.lang.Override - public TrackingOverride build() { - return new TrackingOverride(open, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/UserRecipient.java b/src/main/java/com/courier/api/resources/send/types/UserRecipient.java deleted file mode 100644 index 0b6ebde5..00000000 --- a/src/main/java/com/courier/api/resources/send/types/UserRecipient.java +++ /dev/null @@ -1,321 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserRecipient.Builder.class) -public final class UserRecipient implements IUserRecipientType { - private final Optional accountId; - - private final Optional context; - - private final Optional> data; - - private final Optional email; - - private final Optional locale; - - private final Optional userId; - - private final Optional phoneNumber; - - private final Optional preferences; - - private final Optional tenantId; - - private final Map additionalProperties; - - private UserRecipient( - Optional accountId, - Optional context, - Optional> data, - Optional email, - Optional locale, - Optional userId, - Optional phoneNumber, - Optional preferences, - Optional tenantId, - Map additionalProperties) { - this.accountId = accountId; - this.context = context; - this.data = data; - this.email = email; - this.locale = locale; - this.userId = userId; - this.phoneNumber = phoneNumber; - this.preferences = preferences; - this.tenantId = tenantId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Use tenant_id instad. - */ - @JsonProperty("account_id") - public Optional getAccountId() { - return accountId; - } - - /** - * @return Context information such as tenant_id to send the notification with. - */ - @JsonProperty("context") - public Optional getContext() { - return context; - } - - @JsonProperty("data") - public Optional> getData() { - return data; - } - - @JsonProperty("email") - public Optional getEmail() { - return email; - } - - /** - * @return The user's preferred ISO 639-1 language code. - */ - @JsonProperty("locale") - public Optional getLocale() { - return locale; - } - - @JsonProperty("user_id") - public Optional getUserId() { - return userId; - } - - @JsonProperty("phone_number") - public Optional getPhoneNumber() { - return phoneNumber; - } - - @JsonProperty("preferences") - public Optional getPreferences() { - return preferences; - } - - /** - * @return An id of a tenant, see tenants api docs. - * Will load brand, default preferences and any other base context data associated with this tenant. - */ - @JsonProperty("tenant_id") - public Optional getTenantId() { - return tenantId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserRecipient && equalTo((UserRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserRecipient other) { - return accountId.equals(other.accountId) - && context.equals(other.context) - && data.equals(other.data) - && email.equals(other.email) - && locale.equals(other.locale) - && userId.equals(other.userId) - && phoneNumber.equals(other.phoneNumber) - && preferences.equals(other.preferences) - && tenantId.equals(other.tenantId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.accountId, - this.context, - this.data, - this.email, - this.locale, - this.userId, - this.phoneNumber, - this.preferences, - this.tenantId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional accountId = Optional.empty(); - - private Optional context = Optional.empty(); - - private Optional> data = Optional.empty(); - - private Optional email = Optional.empty(); - - private Optional locale = Optional.empty(); - - private Optional userId = Optional.empty(); - - private Optional phoneNumber = Optional.empty(); - - private Optional preferences = Optional.empty(); - - private Optional tenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(UserRecipient other) { - accountId(other.getAccountId()); - context(other.getContext()); - data(other.getData()); - email(other.getEmail()); - locale(other.getLocale()); - userId(other.getUserId()); - phoneNumber(other.getPhoneNumber()); - preferences(other.getPreferences()); - tenantId(other.getTenantId()); - return this; - } - - @JsonSetter(value = "account_id", nulls = Nulls.SKIP) - public Builder accountId(Optional accountId) { - this.accountId = accountId; - return this; - } - - public Builder accountId(String accountId) { - this.accountId = Optional.of(accountId); - return this; - } - - @JsonSetter(value = "context", nulls = Nulls.SKIP) - public Builder context(Optional context) { - this.context = context; - return this; - } - - public Builder context(MessageContext context) { - this.context = Optional.of(context); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(Optional> data) { - this.data = data; - return this; - } - - public Builder data(Map data) { - this.data = Optional.of(data); - return this; - } - - @JsonSetter(value = "email", nulls = Nulls.SKIP) - public Builder email(Optional email) { - this.email = email; - return this; - } - - public Builder email(String email) { - this.email = Optional.of(email); - return this; - } - - @JsonSetter(value = "locale", nulls = Nulls.SKIP) - public Builder locale(Optional locale) { - this.locale = locale; - return this; - } - - public Builder locale(String locale) { - this.locale = Optional.of(locale); - return this; - } - - @JsonSetter(value = "user_id", nulls = Nulls.SKIP) - public Builder userId(Optional userId) { - this.userId = userId; - return this; - } - - public Builder userId(String userId) { - this.userId = Optional.of(userId); - return this; - } - - @JsonSetter(value = "phone_number", nulls = Nulls.SKIP) - public Builder phoneNumber(Optional phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - - public Builder phoneNumber(String phoneNumber) { - this.phoneNumber = Optional.of(phoneNumber); - return this; - } - - @JsonSetter(value = "preferences", nulls = Nulls.SKIP) - public Builder preferences(Optional preferences) { - this.preferences = preferences; - return this; - } - - public Builder preferences(IProfilePreferences preferences) { - this.preferences = Optional.of(preferences); - return this; - } - - @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) - public Builder tenantId(Optional tenantId) { - this.tenantId = tenantId; - return this; - } - - public Builder tenantId(String tenantId) { - this.tenantId = Optional.of(tenantId); - return this; - } - - public UserRecipient build() { - return new UserRecipient( - accountId, - context, - data, - email, - locale, - userId, - phoneNumber, - preferences, - tenantId, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/UserRecipientType.java b/src/main/java/com/courier/api/resources/send/types/UserRecipientType.java deleted file mode 100644 index 44d5303e..00000000 --- a/src/main/java/com/courier/api/resources/send/types/UserRecipientType.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserRecipientType.Builder.class) -public final class UserRecipientType implements IUserRecipientType { - private final Map additionalProperties; - - private UserRecipientType(Map additionalProperties) { - this.additionalProperties = additionalProperties; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserRecipientType; - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(UserRecipientType other) { - return this; - } - - public UserRecipientType build() { - return new UserRecipientType(additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/Utm.java b/src/main/java/com/courier/api/resources/send/types/Utm.java deleted file mode 100644 index 69e53f1a..00000000 --- a/src/main/java/com/courier/api/resources/send/types/Utm.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Utm.Builder.class) -public final class Utm { - private final Optional source; - - private final Optional medium; - - private final Optional campaign; - - private final Optional term; - - private final Optional content; - - private final Map additionalProperties; - - private Utm( - Optional source, - Optional medium, - Optional campaign, - Optional term, - Optional content, - Map additionalProperties) { - this.source = source; - this.medium = medium; - this.campaign = campaign; - this.term = term; - this.content = content; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("source") - public Optional getSource() { - return source; - } - - @JsonProperty("medium") - public Optional getMedium() { - return medium; - } - - @JsonProperty("campaign") - public Optional getCampaign() { - return campaign; - } - - @JsonProperty("term") - public Optional getTerm() { - return term; - } - - @JsonProperty("content") - public Optional getContent() { - return content; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Utm && equalTo((Utm) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Utm other) { - return source.equals(other.source) - && medium.equals(other.medium) - && campaign.equals(other.campaign) - && term.equals(other.term) - && content.equals(other.content); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.source, this.medium, this.campaign, this.term, this.content); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional source = Optional.empty(); - - private Optional medium = Optional.empty(); - - private Optional campaign = Optional.empty(); - - private Optional term = Optional.empty(); - - private Optional content = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Utm other) { - source(other.getSource()); - medium(other.getMedium()); - campaign(other.getCampaign()); - term(other.getTerm()); - content(other.getContent()); - return this; - } - - @JsonSetter(value = "source", nulls = Nulls.SKIP) - public Builder source(Optional source) { - this.source = source; - return this; - } - - public Builder source(String source) { - this.source = Optional.of(source); - return this; - } - - @JsonSetter(value = "medium", nulls = Nulls.SKIP) - public Builder medium(Optional medium) { - this.medium = medium; - return this; - } - - public Builder medium(String medium) { - this.medium = Optional.of(medium); - return this; - } - - @JsonSetter(value = "campaign", nulls = Nulls.SKIP) - public Builder campaign(Optional campaign) { - this.campaign = campaign; - return this; - } - - public Builder campaign(String campaign) { - this.campaign = Optional.of(campaign); - return this; - } - - @JsonSetter(value = "term", nulls = Nulls.SKIP) - public Builder term(Optional term) { - this.term = term; - return this; - } - - public Builder term(String term) { - this.term = Optional.of(term); - return this; - } - - @JsonSetter(value = "content", nulls = Nulls.SKIP) - public Builder content(Optional content) { - this.content = content; - return this; - } - - public Builder content(String content) { - this.content = Optional.of(content); - return this; - } - - public Utm build() { - return new Utm(source, medium, campaign, term, content, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/WebhookRecipient.java b/src/main/java/com/courier/api/resources/send/types/WebhookRecipient.java deleted file mode 100644 index 223ff695..00000000 --- a/src/main/java/com/courier/api/resources/send/types/WebhookRecipient.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.profiles.types.WebhookProfile; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = WebhookRecipient.Builder.class) -public final class WebhookRecipient { - private final WebhookProfile webhook; - - private final Map additionalProperties; - - private WebhookRecipient(WebhookProfile webhook, Map additionalProperties) { - this.webhook = webhook; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("webhook") - public WebhookProfile getWebhook() { - return webhook; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof WebhookRecipient && equalTo((WebhookRecipient) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(WebhookRecipient other) { - return webhook.equals(other.webhook); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.webhook); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static WebhookStage builder() { - return new Builder(); - } - - public interface WebhookStage { - _FinalStage webhook(WebhookProfile webhook); - - Builder from(WebhookRecipient other); - } - - public interface _FinalStage { - WebhookRecipient build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements WebhookStage, _FinalStage { - private WebhookProfile webhook; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(WebhookRecipient other) { - webhook(other.getWebhook()); - return this; - } - - @java.lang.Override - @JsonSetter("webhook") - public _FinalStage webhook(WebhookProfile webhook) { - this.webhook = webhook; - return this; - } - - @java.lang.Override - public WebhookRecipient build() { - return new WebhookRecipient(webhook, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/send/types/WidgetBackground.java b/src/main/java/com/courier/api/resources/send/types/WidgetBackground.java deleted file mode 100644 index c219fe9a..00000000 --- a/src/main/java/com/courier/api/resources/send/types/WidgetBackground.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.send.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = WidgetBackground.Builder.class) -public final class WidgetBackground { - private final Optional topColor; - - private final Optional bottomColor; - - private final Map additionalProperties; - - private WidgetBackground( - Optional topColor, Optional bottomColor, Map additionalProperties) { - this.topColor = topColor; - this.bottomColor = bottomColor; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("topColor") - public Optional getTopColor() { - return topColor; - } - - @JsonProperty("bottomColor") - public Optional getBottomColor() { - return bottomColor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof WidgetBackground && equalTo((WidgetBackground) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(WidgetBackground other) { - return topColor.equals(other.topColor) && bottomColor.equals(other.bottomColor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.topColor, this.bottomColor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional topColor = Optional.empty(); - - private Optional bottomColor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(WidgetBackground other) { - topColor(other.getTopColor()); - bottomColor(other.getBottomColor()); - return this; - } - - @JsonSetter(value = "topColor", nulls = Nulls.SKIP) - public Builder topColor(Optional topColor) { - this.topColor = topColor; - return this; - } - - public Builder topColor(String topColor) { - this.topColor = Optional.of(topColor); - return this; - } - - @JsonSetter(value = "bottomColor", nulls = Nulls.SKIP) - public Builder bottomColor(Optional bottomColor) { - this.bottomColor = bottomColor; - return this; - } - - public Builder bottomColor(String bottomColor) { - this.bottomColor = Optional.of(bottomColor); - return this; - } - - public WidgetBackground build() { - return new WidgetBackground(topColor, bottomColor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/TemplatesClient.java b/src/main/java/com/courier/api/resources/templates/TemplatesClient.java deleted file mode 100644 index 635453c1..00000000 --- a/src/main/java/com/courier/api/resources/templates/TemplatesClient.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.templates.requests.ListTemplatesRequest; -import com.courier.api.resources.templates.types.ListTemplatesResponse; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class TemplatesClient { - protected final ClientOptions clientOptions; - - public TemplatesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Returns a list of notification templates - */ - public ListTemplatesResponse list() { - return list(ListTemplatesRequest.builder().build()); - } - - /** - * Returns a list of notification templates - */ - public ListTemplatesResponse list(ListTemplatesRequest request) { - return list(request, null); - } - - /** - * Returns a list of notification templates - */ - public ListTemplatesResponse list(ListTemplatesRequest request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("notifications"); - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListTemplatesResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/requests/ListTemplatesRequest.java b/src/main/java/com/courier/api/resources/templates/requests/ListTemplatesRequest.java deleted file mode 100644 index b0aa305f..00000000 --- a/src/main/java/com/courier/api/resources/templates/requests/ListTemplatesRequest.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTemplatesRequest.Builder.class) -public final class ListTemplatesRequest { - private final Optional cursor; - - private final Map additionalProperties; - - private ListTemplatesRequest(Optional cursor, Map additionalProperties) { - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier that allows for fetching the next set of templates - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTemplatesRequest && equalTo((ListTemplatesRequest) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTemplatesRequest other) { - return cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListTemplatesRequest other) { - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListTemplatesRequest build() { - return new ListTemplatesRequest(cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/types/ListTemplatesResponse.java b/src/main/java/com/courier/api/resources/templates/types/ListTemplatesResponse.java deleted file mode 100644 index e6240f4a..00000000 --- a/src/main/java/com/courier/api/resources/templates/types/ListTemplatesResponse.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTemplatesResponse.Builder.class) -public final class ListTemplatesResponse { - private final Paging paging; - - private final List results; - - private final Map additionalProperties; - - private ListTemplatesResponse( - Paging paging, List results, Map additionalProperties) { - this.paging = paging; - this.results = results; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - /** - * @return An array of Notification Templates - */ - @JsonProperty("results") - public List getResults() { - return results; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTemplatesResponse && equalTo((ListTemplatesResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTemplatesResponse other) { - return paging.equals(other.paging) && results.equals(other.results); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.results); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(ListTemplatesResponse other); - } - - public interface _FinalStage { - ListTemplatesResponse build(); - - _FinalStage results(List results); - - _FinalStage addResults(NotificationTemplates results); - - _FinalStage addAllResults(List results); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List results = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListTemplatesResponse other) { - paging(other.getPaging()); - results(other.getResults()); - return this; - } - - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - /** - *

An array of Notification Templates

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllResults(List results) { - this.results.addAll(results); - return this; - } - - /** - *

An array of Notification Templates

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addResults(NotificationTemplates results) { - this.results.add(results); - return this; - } - - @java.lang.Override - @JsonSetter(value = "results", nulls = Nulls.SKIP) - public _FinalStage results(List results) { - this.results.clear(); - this.results.addAll(results); - return this; - } - - @java.lang.Override - public ListTemplatesResponse build() { - return new ListTemplatesResponse(paging, results, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/types/NotificationTemplates.java b/src/main/java/com/courier/api/resources/templates/types/NotificationTemplates.java deleted file mode 100644 index 7894757f..00000000 --- a/src/main/java/com/courier/api/resources/templates/types/NotificationTemplates.java +++ /dev/null @@ -1,288 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = NotificationTemplates.Builder.class) -public final class NotificationTemplates { - private final long createdAt; - - private final String id; - - private final RoutingStrategy routing; - - private final List tags; - - private final String title; - - private final long updatedAt; - - private final Map additionalProperties; - - private NotificationTemplates( - long createdAt, - String id, - RoutingStrategy routing, - List tags, - String title, - long updatedAt, - Map additionalProperties) { - this.createdAt = createdAt; - this.id = id; - this.routing = routing; - this.tags = tags; - this.title = title; - this.updatedAt = updatedAt; - this.additionalProperties = additionalProperties; - } - - /** - * @return A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). - */ - @JsonProperty("created_at") - public long getCreatedAt() { - return createdAt; - } - - /** - * @return A unique identifier associated with the notification. - */ - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * @return Routing strategy used by this notification. - */ - @JsonProperty("routing") - public RoutingStrategy getRouting() { - return routing; - } - - /** - * @return A list of tags attached to the notification. - */ - @JsonProperty("tags") - public List getTags() { - return tags; - } - - /** - * @return The title of the notification. - */ - @JsonProperty("title") - public String getTitle() { - return title; - } - - /** - * @return A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). - */ - @JsonProperty("updated_at") - public long getUpdatedAt() { - return updatedAt; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof NotificationTemplates && equalTo((NotificationTemplates) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(NotificationTemplates other) { - return createdAt == other.createdAt - && id.equals(other.id) - && routing.equals(other.routing) - && tags.equals(other.tags) - && title.equals(other.title) - && updatedAt == other.updatedAt; - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.createdAt, this.id, this.routing, this.tags, this.title, this.updatedAt); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static CreatedAtStage builder() { - return new Builder(); - } - - public interface CreatedAtStage { - IdStage createdAt(long createdAt); - - Builder from(NotificationTemplates other); - } - - public interface IdStage { - RoutingStage id(String id); - } - - public interface RoutingStage { - TitleStage routing(RoutingStrategy routing); - } - - public interface TitleStage { - UpdatedAtStage title(String title); - } - - public interface UpdatedAtStage { - _FinalStage updatedAt(long updatedAt); - } - - public interface _FinalStage { - NotificationTemplates build(); - - _FinalStage tags(List tags); - - _FinalStage addTags(Tag tags); - - _FinalStage addAllTags(List tags); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements CreatedAtStage, IdStage, RoutingStage, TitleStage, UpdatedAtStage, _FinalStage { - private long createdAt; - - private String id; - - private RoutingStrategy routing; - - private String title; - - private long updatedAt; - - private List tags = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(NotificationTemplates other) { - createdAt(other.getCreatedAt()); - id(other.getId()); - routing(other.getRouting()); - tags(other.getTags()); - title(other.getTitle()); - updatedAt(other.getUpdatedAt()); - return this; - } - - /** - *

A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public IdStage createdAt(long createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - *

A unique identifier associated with the notification.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public RoutingStage id(String id) { - this.id = id; - return this; - } - - /** - *

Routing strategy used by this notification.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("routing") - public TitleStage routing(RoutingStrategy routing) { - this.routing = routing; - return this; - } - - /** - *

The title of the notification.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("title") - public UpdatedAtStage title(String title) { - this.title = title; - return this; - } - - /** - *

A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated_at") - public _FinalStage updatedAt(long updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - /** - *

A list of tags attached to the notification.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllTags(List tags) { - this.tags.addAll(tags); - return this; - } - - /** - *

A list of tags attached to the notification.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addTags(Tag tags) { - this.tags.add(tags); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tags", nulls = Nulls.SKIP) - public _FinalStage tags(List tags) { - this.tags.clear(); - this.tags.addAll(tags); - return this; - } - - @java.lang.Override - public NotificationTemplates build() { - return new NotificationTemplates(createdAt, id, routing, tags, title, updatedAt, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/types/RoutingStrategy.java b/src/main/java/com/courier/api/resources/templates/types/RoutingStrategy.java deleted file mode 100644 index d4921397..00000000 --- a/src/main/java/com/courier/api/resources/templates/types/RoutingStrategy.java +++ /dev/null @@ -1,160 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = RoutingStrategy.Builder.class) -public final class RoutingStrategy { - private final RoutingStrategyMethod method; - - private final List channels; - - private final Map additionalProperties; - - private RoutingStrategy( - RoutingStrategyMethod method, List channels, Map additionalProperties) { - this.method = method; - this.channels = channels; - this.additionalProperties = additionalProperties; - } - - /** - * @return The method for selecting channels to send the message with. Value can be either 'single' or 'all'. If not provided will default to 'single' - */ - @JsonProperty("method") - public RoutingStrategyMethod getMethod() { - return method; - } - - /** - * @return An array of valid channel identifiers (like email, push, sms, etc.) and additional routing nodes. - */ - @JsonProperty("channels") - public List getChannels() { - return channels; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof RoutingStrategy && equalTo((RoutingStrategy) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(RoutingStrategy other) { - return method.equals(other.method) && channels.equals(other.channels); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.method, this.channels); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MethodStage builder() { - return new Builder(); - } - - public interface MethodStage { - _FinalStage method(RoutingStrategyMethod method); - - Builder from(RoutingStrategy other); - } - - public interface _FinalStage { - RoutingStrategy build(); - - _FinalStage channels(List channels); - - _FinalStage addChannels(String channels); - - _FinalStage addAllChannels(List channels); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MethodStage, _FinalStage { - private RoutingStrategyMethod method; - - private List channels = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(RoutingStrategy other) { - method(other.getMethod()); - channels(other.getChannels()); - return this; - } - - /** - *

The method for selecting channels to send the message with. Value can be either 'single' or 'all'. If not provided will default to 'single'

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("method") - public _FinalStage method(RoutingStrategyMethod method) { - this.method = method; - return this; - } - - /** - *

An array of valid channel identifiers (like email, push, sms, etc.) and additional routing nodes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllChannels(List channels) { - this.channels.addAll(channels); - return this; - } - - /** - *

An array of valid channel identifiers (like email, push, sms, etc.) and additional routing nodes.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addChannels(String channels) { - this.channels.add(channels); - return this; - } - - @java.lang.Override - @JsonSetter(value = "channels", nulls = Nulls.SKIP) - public _FinalStage channels(List channels) { - this.channels.clear(); - this.channels.addAll(channels); - return this; - } - - @java.lang.Override - public RoutingStrategy build() { - return new RoutingStrategy(method, channels, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/types/RoutingStrategyMethod.java b/src/main/java/com/courier/api/resources/templates/types/RoutingStrategyMethod.java deleted file mode 100644 index f0447417..00000000 --- a/src/main/java/com/courier/api/resources/templates/types/RoutingStrategyMethod.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum RoutingStrategyMethod { - ALL("all"), - - SINGLE("single"); - - private final String value; - - RoutingStrategyMethod(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/templates/types/Tag.java b/src/main/java/com/courier/api/resources/templates/types/Tag.java deleted file mode 100644 index ff814245..00000000 --- a/src/main/java/com/courier/api/resources/templates/types/Tag.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Tag.Builder.class) -public final class Tag { - private final List data; - - private final Map additionalProperties; - - private Tag(List data, Map additionalProperties) { - this.data = data; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("data") - public List getData() { - return data; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Tag && equalTo((Tag) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Tag other) { - return data.equals(other.data); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.data); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List data = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Tag other) { - data(other.getData()); - return this; - } - - @JsonSetter(value = "data", nulls = Nulls.SKIP) - public Builder data(List data) { - this.data.clear(); - this.data.addAll(data); - return this; - } - - public Builder addData(TagData data) { - this.data.add(data); - return this; - } - - public Builder addAllData(List data) { - this.data.addAll(data); - return this; - } - - public Tag build() { - return new Tag(data, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/templates/types/TagData.java b/src/main/java/com/courier/api/resources/templates/types/TagData.java deleted file mode 100644 index 424ba3eb..00000000 --- a/src/main/java/com/courier/api/resources/templates/types/TagData.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.templates.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TagData.Builder.class) -public final class TagData { - private final String id; - - private final String name; - - private final Map additionalProperties; - - private TagData(String id, String name, Map additionalProperties) { - this.id = id; - this.name = name; - this.additionalProperties = additionalProperties; - } - - /** - * @return A unique identifier of the tag. - */ - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * @return Name of the tag. - */ - @JsonProperty("name") - public String getName() { - return name; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TagData && equalTo((TagData) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TagData other) { - return id.equals(other.id) && name.equals(other.name); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.id, this.name); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - NameStage id(String id); - - Builder from(TagData other); - } - - public interface NameStage { - _FinalStage name(String name); - } - - public interface _FinalStage { - TagData build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, _FinalStage { - private String id; - - private String name; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TagData other) { - id(other.getId()); - name(other.getName()); - return this; - } - - /** - *

A unique identifier of the tag.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(String id) { - this.id = id; - return this; - } - - /** - *

Name of the tag.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - @java.lang.Override - public TagData build() { - return new TagData(id, name, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/TenantsClient.java b/src/main/java/com/courier/api/resources/tenants/TenantsClient.java deleted file mode 100644 index facea5b7..00000000 --- a/src/main/java/com/courier/api/resources/tenants/TenantsClient.java +++ /dev/null @@ -1,452 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.tenants.requests.GetTemplateListByTenantParams; -import com.courier.api.resources.tenants.requests.ListTenantParams; -import com.courier.api.resources.tenants.requests.ListUsersForTenantParams; -import com.courier.api.resources.tenants.requests.TenantCreateOrReplaceParams; -import com.courier.api.resources.tenants.types.GetTemplateByTenantResponse; -import com.courier.api.resources.tenants.types.ListTemplatesByTenantResponse; -import com.courier.api.resources.tenants.types.ListUsersForTenantResponse; -import com.courier.api.resources.tenants.types.SubscriptionTopicNew; -import com.courier.api.resources.tenants.types.Tenant; -import com.courier.api.resources.tenants.types.TenantListResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class TenantsClient { - protected final ClientOptions clientOptions; - - public TenantsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - public Tenant createOrReplace(String tenantId, TenantCreateOrReplaceParams request) { - return createOrReplace(tenantId, request, null); - } - - public Tenant createOrReplace(String tenantId, TenantCreateOrReplaceParams request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tenant.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public Tenant get(String tenantId) { - return get(tenantId, null); - } - - public Tenant get(String tenantId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), Tenant.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public TenantListResponse list() { - return list(ListTenantParams.builder().build()); - } - - public TenantListResponse list(ListTenantParams request) { - return list(request, null); - } - - public TenantListResponse list(ListTenantParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants"); - if (request.getParentTenantId().isPresent()) { - httpUrl.addQueryParameter( - "parent_tenant_id", request.getParentTenantId().get()); - } - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), TenantListResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void delete(String tenantId) { - delete(tenantId, null); - } - - public void delete(String tenantId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public ListUsersForTenantResponse getUsersByTenant(String tenantId) { - return getUsersByTenant(tenantId, ListUsersForTenantParams.builder().build()); - } - - public ListUsersForTenantResponse getUsersByTenant(String tenantId, ListUsersForTenantParams request) { - return getUsersByTenant(tenantId, request, null); - } - - public ListUsersForTenantResponse getUsersByTenant( - String tenantId, ListUsersForTenantParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .addPathSegments("users"); - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListUsersForTenantResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void createOrReplaceDefaultPreferencesForTopic( - String tenantId, String topicId, SubscriptionTopicNew request) { - createOrReplaceDefaultPreferencesForTopic(tenantId, topicId, request, null); - } - - public void createOrReplaceDefaultPreferencesForTopic( - String tenantId, String topicId, SubscriptionTopicNew request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .addPathSegments("default_preferences/items") - .addPathSegment(topicId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void removeDefaultPreferencesForTopic(String tenantId, String topicId) { - removeDefaultPreferencesForTopic(tenantId, topicId, null); - } - - public void removeDefaultPreferencesForTopic(String tenantId, String topicId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .addPathSegments("default_preferences/items") - .addPathSegment(topicId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public GetTemplateByTenantResponse getTemplateByTenant(String tenantId, String templateId) { - return getTemplateByTenant(tenantId, templateId, null); - } - - public GetTemplateByTenantResponse getTemplateByTenant( - String tenantId, String templateId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .addPathSegments("templates") - .addPathSegment(templateId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetTemplateByTenantResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public ListTemplatesByTenantResponse getTemplateListByTenant(String tenantId) { - return getTemplateListByTenant( - tenantId, GetTemplateListByTenantParams.builder().build()); - } - - public ListTemplatesByTenantResponse getTemplateListByTenant( - String tenantId, GetTemplateListByTenantParams request) { - return getTemplateListByTenant(tenantId, request, null); - } - - public ListTemplatesByTenantResponse getTemplateListByTenant( - String tenantId, GetTemplateListByTenantParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("tenants") - .addPathSegment(tenantId) - .addPathSegments("templates"); - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListTemplatesByTenantResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/requests/GetTemplateListByTenantParams.java b/src/main/java/com/courier/api/resources/tenants/requests/GetTemplateListByTenantParams.java deleted file mode 100644 index 84e3e009..00000000 --- a/src/main/java/com/courier/api/resources/tenants/requests/GetTemplateListByTenantParams.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetTemplateListByTenantParams.Builder.class) -public final class GetTemplateListByTenantParams { - private final Optional limit; - - private final Optional cursor; - - private final Map additionalProperties; - - private GetTemplateListByTenantParams( - Optional limit, Optional cursor, Map additionalProperties) { - this.limit = limit; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return The number of templates to return (defaults to 20, maximum value of 100) - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return Continue the pagination with the next cursor - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetTemplateListByTenantParams && equalTo((GetTemplateListByTenantParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetTemplateListByTenantParams other) { - return limit.equals(other.limit) && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.limit, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional limit = Optional.empty(); - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(GetTemplateListByTenantParams other) { - limit(other.getLimit()); - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "limit", nulls = Nulls.SKIP) - public Builder limit(Optional limit) { - this.limit = limit; - return this; - } - - public Builder limit(Integer limit) { - this.limit = Optional.of(limit); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public GetTemplateListByTenantParams build() { - return new GetTemplateListByTenantParams(limit, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/requests/ListTenantParams.java b/src/main/java/com/courier/api/resources/tenants/requests/ListTenantParams.java deleted file mode 100644 index 19cf8111..00000000 --- a/src/main/java/com/courier/api/resources/tenants/requests/ListTenantParams.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTenantParams.Builder.class) -public final class ListTenantParams { - private final Optional parentTenantId; - - private final Optional limit; - - private final Optional cursor; - - private final Map additionalProperties; - - private ListTenantParams( - Optional parentTenantId, - Optional limit, - Optional cursor, - Map additionalProperties) { - this.parentTenantId = parentTenantId; - this.limit = limit; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return Filter the list of tenants by parent_id - */ - @JsonProperty("parent_tenant_id") - public Optional getParentTenantId() { - return parentTenantId; - } - - /** - * @return The number of tenants to return - * (defaults to 20, maximum value of 100) - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return Continue the pagination with the next cursor - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTenantParams && equalTo((ListTenantParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTenantParams other) { - return parentTenantId.equals(other.parentTenantId) && limit.equals(other.limit) && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.parentTenantId, this.limit, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional parentTenantId = Optional.empty(); - - private Optional limit = Optional.empty(); - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListTenantParams other) { - parentTenantId(other.getParentTenantId()); - limit(other.getLimit()); - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "parent_tenant_id", nulls = Nulls.SKIP) - public Builder parentTenantId(Optional parentTenantId) { - this.parentTenantId = parentTenantId; - return this; - } - - public Builder parentTenantId(String parentTenantId) { - this.parentTenantId = Optional.of(parentTenantId); - return this; - } - - @JsonSetter(value = "limit", nulls = Nulls.SKIP) - public Builder limit(Optional limit) { - this.limit = limit; - return this; - } - - public Builder limit(Integer limit) { - this.limit = Optional.of(limit); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListTenantParams build() { - return new ListTenantParams(parentTenantId, limit, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/requests/ListUsersForTenantParams.java b/src/main/java/com/courier/api/resources/tenants/requests/ListUsersForTenantParams.java deleted file mode 100644 index 855b7f3e..00000000 --- a/src/main/java/com/courier/api/resources/tenants/requests/ListUsersForTenantParams.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListUsersForTenantParams.Builder.class) -public final class ListUsersForTenantParams { - private final Optional limit; - - private final Optional cursor; - - private final Map additionalProperties; - - private ListUsersForTenantParams( - Optional limit, Optional cursor, Map additionalProperties) { - this.limit = limit; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return The number of accounts to return - * (defaults to 20, maximum value of 100) - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return Continue the pagination with the next cursor - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListUsersForTenantParams && equalTo((ListUsersForTenantParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListUsersForTenantParams other) { - return limit.equals(other.limit) && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.limit, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional limit = Optional.empty(); - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListUsersForTenantParams other) { - limit(other.getLimit()); - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "limit", nulls = Nulls.SKIP) - public Builder limit(Optional limit) { - this.limit = limit; - return this; - } - - public Builder limit(Integer limit) { - this.limit = Optional.of(limit); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListUsersForTenantParams build() { - return new ListUsersForTenantParams(limit, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/requests/TenantCreateOrReplaceParams.java b/src/main/java/com/courier/api/resources/tenants/requests/TenantCreateOrReplaceParams.java deleted file mode 100644 index 7a2d0fb9..00000000 --- a/src/main/java/com/courier/api/resources/tenants/requests/TenantCreateOrReplaceParams.java +++ /dev/null @@ -1,305 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.tenants.types.DefaultPreferences; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TenantCreateOrReplaceParams.Builder.class) -public final class TenantCreateOrReplaceParams { - private final String name; - - private final Optional parentTenantId; - - private final Optional defaultPreferences; - - private final Optional> properties; - - private final Optional> userProfile; - - private final Optional brandId; - - private final Map additionalProperties; - - private TenantCreateOrReplaceParams( - String name, - Optional parentTenantId, - Optional defaultPreferences, - Optional> properties, - Optional> userProfile, - Optional brandId, - Map additionalProperties) { - this.name = name; - this.parentTenantId = parentTenantId; - this.defaultPreferences = defaultPreferences; - this.properties = properties; - this.userProfile = userProfile; - this.brandId = brandId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Name of the tenant. - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return Tenant's parent id (if any). - */ - @JsonProperty("parent_tenant_id") - public Optional getParentTenantId() { - return parentTenantId; - } - - /** - * @return Defines the preferences used for the tenant when the user hasn't specified their own. - */ - @JsonProperty("default_preferences") - public Optional getDefaultPreferences() { - return defaultPreferences; - } - - /** - * @return Arbitrary properties accessible to a template. - */ - @JsonProperty("properties") - public Optional> getProperties() { - return properties; - } - - /** - * @return A user profile object merged with user profile on send. - */ - @JsonProperty("user_profile") - public Optional> getUserProfile() { - return userProfile; - } - - /** - * @return Brand to be used for the account when one is not specified by the send call. - */ - @JsonProperty("brand_id") - public Optional getBrandId() { - return brandId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TenantCreateOrReplaceParams && equalTo((TenantCreateOrReplaceParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TenantCreateOrReplaceParams other) { - return name.equals(other.name) - && parentTenantId.equals(other.parentTenantId) - && defaultPreferences.equals(other.defaultPreferences) - && properties.equals(other.properties) - && userProfile.equals(other.userProfile) - && brandId.equals(other.brandId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.name, - this.parentTenantId, - this.defaultPreferences, - this.properties, - this.userProfile, - this.brandId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static NameStage builder() { - return new Builder(); - } - - public interface NameStage { - _FinalStage name(String name); - - Builder from(TenantCreateOrReplaceParams other); - } - - public interface _FinalStage { - TenantCreateOrReplaceParams build(); - - _FinalStage parentTenantId(Optional parentTenantId); - - _FinalStage parentTenantId(String parentTenantId); - - _FinalStage defaultPreferences(Optional defaultPreferences); - - _FinalStage defaultPreferences(DefaultPreferences defaultPreferences); - - _FinalStage properties(Optional> properties); - - _FinalStage properties(Map properties); - - _FinalStage userProfile(Optional> userProfile); - - _FinalStage userProfile(Map userProfile); - - _FinalStage brandId(Optional brandId); - - _FinalStage brandId(String brandId); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements NameStage, _FinalStage { - private String name; - - private Optional brandId = Optional.empty(); - - private Optional> userProfile = Optional.empty(); - - private Optional> properties = Optional.empty(); - - private Optional defaultPreferences = Optional.empty(); - - private Optional parentTenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TenantCreateOrReplaceParams other) { - name(other.getName()); - parentTenantId(other.getParentTenantId()); - defaultPreferences(other.getDefaultPreferences()); - properties(other.getProperties()); - userProfile(other.getUserProfile()); - brandId(other.getBrandId()); - return this; - } - - /** - *

Name of the tenant.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - /** - *

Brand to be used for the account when one is not specified by the send call.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public _FinalStage brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - /** - *

A user profile object merged with user profile on send.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage userProfile(Map userProfile) { - this.userProfile = Optional.of(userProfile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "user_profile", nulls = Nulls.SKIP) - public _FinalStage userProfile(Optional> userProfile) { - this.userProfile = userProfile; - return this; - } - - /** - *

Arbitrary properties accessible to a template.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage properties(Map properties) { - this.properties = Optional.of(properties); - return this; - } - - @java.lang.Override - @JsonSetter(value = "properties", nulls = Nulls.SKIP) - public _FinalStage properties(Optional> properties) { - this.properties = properties; - return this; - } - - /** - *

Defines the preferences used for the tenant when the user hasn't specified their own.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage defaultPreferences(DefaultPreferences defaultPreferences) { - this.defaultPreferences = Optional.of(defaultPreferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "default_preferences", nulls = Nulls.SKIP) - public _FinalStage defaultPreferences(Optional defaultPreferences) { - this.defaultPreferences = defaultPreferences; - return this; - } - - /** - *

Tenant's parent id (if any).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage parentTenantId(String parentTenantId) { - this.parentTenantId = Optional.of(parentTenantId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "parent_tenant_id", nulls = Nulls.SKIP) - public _FinalStage parentTenantId(Optional parentTenantId) { - this.parentTenantId = parentTenantId; - return this; - } - - @java.lang.Override - public TenantCreateOrReplaceParams build() { - return new TenantCreateOrReplaceParams( - name, parentTenantId, defaultPreferences, properties, userProfile, brandId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/DefaultPreferences.java b/src/main/java/com/courier/api/resources/tenants/types/DefaultPreferences.java deleted file mode 100644 index 8ade52ec..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/DefaultPreferences.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DefaultPreferences.Builder.class) -public final class DefaultPreferences { - private final Optional> items; - - private final Map additionalProperties; - - private DefaultPreferences(Optional> items, Map additionalProperties) { - this.items = items; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public Optional> getItems() { - return items; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DefaultPreferences && equalTo((DefaultPreferences) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DefaultPreferences other) { - return items.equals(other.items); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> items = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(DefaultPreferences other) { - items(other.getItems()); - return this; - } - - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public Builder items(Optional> items) { - this.items = items; - return this; - } - - public Builder items(List items) { - this.items = Optional.of(items); - return this; - } - - public DefaultPreferences build() { - return new DefaultPreferences(items, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/GetTemplateByTenantResponse.java b/src/main/java/com/courier/api/resources/tenants/types/GetTemplateByTenantResponse.java deleted file mode 100644 index be36d4fc..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/GetTemplateByTenantResponse.java +++ /dev/null @@ -1,268 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ISingleTemplateTenantAssociation; -import com.courier.api.resources.commons.types.TenantTemplateData; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetTemplateByTenantResponse.Builder.class) -public final class GetTemplateByTenantResponse implements ISingleTemplateTenantAssociation { - private final TenantTemplateData data; - - private final String id; - - private final String createdAt; - - private final String updatedAt; - - private final String publishedAt; - - private final String version; - - private final Map additionalProperties; - - private GetTemplateByTenantResponse( - TenantTemplateData data, - String id, - String createdAt, - String updatedAt, - String publishedAt, - String version, - Map additionalProperties) { - this.data = data; - this.id = id; - this.createdAt = createdAt; - this.updatedAt = updatedAt; - this.publishedAt = publishedAt; - this.version = version; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("data") - @java.lang.Override - public TenantTemplateData getData() { - return data; - } - - /** - * @return The template's id - */ - @JsonProperty("id") - @java.lang.Override - public String getId() { - return id; - } - - /** - * @return The timestamp at which the template was created - */ - @JsonProperty("created_at") - @java.lang.Override - public String getCreatedAt() { - return createdAt; - } - - /** - * @return The timestamp at which the template was last updated - */ - @JsonProperty("updated_at") - @java.lang.Override - public String getUpdatedAt() { - return updatedAt; - } - - /** - * @return The timestamp at which the template was published - */ - @JsonProperty("published_at") - @java.lang.Override - public String getPublishedAt() { - return publishedAt; - } - - /** - * @return The version of the template - */ - @JsonProperty("version") - @java.lang.Override - public String getVersion() { - return version; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetTemplateByTenantResponse && equalTo((GetTemplateByTenantResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetTemplateByTenantResponse other) { - return data.equals(other.data) - && id.equals(other.id) - && createdAt.equals(other.createdAt) - && updatedAt.equals(other.updatedAt) - && publishedAt.equals(other.publishedAt) - && version.equals(other.version); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.data, this.id, this.createdAt, this.updatedAt, this.publishedAt, this.version); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static DataStage builder() { - return new Builder(); - } - - public interface DataStage { - IdStage data(TenantTemplateData data); - - Builder from(GetTemplateByTenantResponse other); - } - - public interface IdStage { - CreatedAtStage id(String id); - } - - public interface CreatedAtStage { - UpdatedAtStage createdAt(String createdAt); - } - - public interface UpdatedAtStage { - PublishedAtStage updatedAt(String updatedAt); - } - - public interface PublishedAtStage { - VersionStage publishedAt(String publishedAt); - } - - public interface VersionStage { - _FinalStage version(String version); - } - - public interface _FinalStage { - GetTemplateByTenantResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements DataStage, IdStage, CreatedAtStage, UpdatedAtStage, PublishedAtStage, VersionStage, _FinalStage { - private TenantTemplateData data; - - private String id; - - private String createdAt; - - private String updatedAt; - - private String publishedAt; - - private String version; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetTemplateByTenantResponse other) { - data(other.getData()); - id(other.getId()); - createdAt(other.getCreatedAt()); - updatedAt(other.getUpdatedAt()); - publishedAt(other.getPublishedAt()); - version(other.getVersion()); - return this; - } - - @java.lang.Override - @JsonSetter("data") - public IdStage data(TenantTemplateData data) { - this.data = data; - return this; - } - - /** - *

The template's id

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public CreatedAtStage id(String id) { - this.id = id; - return this; - } - - /** - *

The timestamp at which the template was created

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("created_at") - public UpdatedAtStage createdAt(String createdAt) { - this.createdAt = createdAt; - return this; - } - - /** - *

The timestamp at which the template was last updated

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("updated_at") - public PublishedAtStage updatedAt(String updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - /** - *

The timestamp at which the template was published

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("published_at") - public VersionStage publishedAt(String publishedAt) { - this.publishedAt = publishedAt; - return this; - } - - /** - *

The version of the template

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("version") - public _FinalStage version(String version) { - this.version = version; - return this; - } - - @java.lang.Override - public GetTemplateByTenantResponse build() { - return new GetTemplateByTenantResponse( - data, id, createdAt, updatedAt, publishedAt, version, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/ISubscriptionTopicNew.java b/src/main/java/com/courier/api/resources/tenants/types/ISubscriptionTopicNew.java deleted file mode 100644 index 44e4d1bc..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/ISubscriptionTopicNew.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.resources.commons.types.ChannelClassification; -import java.util.List; -import java.util.Optional; - -public interface ISubscriptionTopicNew { - SubscriptionTopicStatus getStatus(); - - Optional getHasCustomRouting(); - - Optional> getCustomRouting(); -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/ListTemplatesByTenantResponse.java b/src/main/java/com/courier/api/resources/tenants/types/ListTemplatesByTenantResponse.java deleted file mode 100644 index 38802d35..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/ListTemplatesByTenantResponse.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ListTemplateTenantAssociation; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTemplatesByTenantResponse.Builder.class) -public final class ListTemplatesByTenantResponse { - private final Optional> items; - - private final boolean hasMore; - - private final String url; - - private final Optional nextUrl; - - private final Optional cursor; - - private final Map additionalProperties; - - private ListTemplatesByTenantResponse( - Optional> items, - boolean hasMore, - String url, - Optional nextUrl, - Optional cursor, - Map additionalProperties) { - this.items = items; - this.hasMore = hasMore; - this.url = url; - this.nextUrl = nextUrl; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public Optional> getItems() { - return items; - } - - /** - * @return Set to true when there are more pages that can be retrieved. - */ - @JsonProperty("has_more") - public boolean getHasMore() { - return hasMore; - } - - /** - * @return A url that may be used to generate these results. - */ - @JsonProperty("url") - public String getUrl() { - return url; - } - - /** - * @return A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true - */ - @JsonProperty("next_url") - public Optional getNextUrl() { - return nextUrl; - } - - /** - * @return A pointer to the next page of results. Defined - * only when has_more is set to true - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return Always set to list. Represents the type of this object. - */ - @JsonProperty("type") - public String getType() { - return "list"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTemplatesByTenantResponse && equalTo((ListTemplatesByTenantResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTemplatesByTenantResponse other) { - return items.equals(other.items) - && hasMore == other.hasMore - && url.equals(other.url) - && nextUrl.equals(other.nextUrl) - && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items, this.hasMore, this.url, this.nextUrl, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static HasMoreStage builder() { - return new Builder(); - } - - public interface HasMoreStage { - UrlStage hasMore(boolean hasMore); - - Builder from(ListTemplatesByTenantResponse other); - } - - public interface UrlStage { - _FinalStage url(String url); - } - - public interface _FinalStage { - ListTemplatesByTenantResponse build(); - - _FinalStage items(Optional> items); - - _FinalStage items(List items); - - _FinalStage nextUrl(Optional nextUrl); - - _FinalStage nextUrl(String nextUrl); - - _FinalStage cursor(Optional cursor); - - _FinalStage cursor(String cursor); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements HasMoreStage, UrlStage, _FinalStage { - private boolean hasMore; - - private String url; - - private Optional cursor = Optional.empty(); - - private Optional nextUrl = Optional.empty(); - - private Optional> items = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListTemplatesByTenantResponse other) { - items(other.getItems()); - hasMore(other.getHasMore()); - url(other.getUrl()); - nextUrl(other.getNextUrl()); - cursor(other.getCursor()); - return this; - } - - /** - *

Set to true when there are more pages that can be retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("has_more") - public UrlStage hasMore(boolean hasMore) { - this.hasMore = hasMore; - return this; - } - - /** - *

A url that may be used to generate these results.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - /** - *

A pointer to the next page of results. Defined - * only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public _FinalStage cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - /** - *

A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage nextUrl(String nextUrl) { - this.nextUrl = Optional.of(nextUrl); - return this; - } - - @java.lang.Override - @JsonSetter(value = "next_url", nulls = Nulls.SKIP) - public _FinalStage nextUrl(Optional nextUrl) { - this.nextUrl = nextUrl; - return this; - } - - @java.lang.Override - public _FinalStage items(List items) { - this.items = Optional.of(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(Optional> items) { - this.items = items; - return this; - } - - @java.lang.Override - public ListTemplatesByTenantResponse build() { - return new ListTemplatesByTenantResponse(items, hasMore, url, nextUrl, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/ListUsersForTenantResponse.java b/src/main/java/com/courier/api/resources/tenants/types/ListUsersForTenantResponse.java deleted file mode 100644 index 098e043c..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/ListUsersForTenantResponse.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.UserTenantAssociation; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListUsersForTenantResponse.Builder.class) -public final class ListUsersForTenantResponse { - private final Optional> items; - - private final boolean hasMore; - - private final String url; - - private final Optional nextUrl; - - private final Optional cursor; - - private final Map additionalProperties; - - private ListUsersForTenantResponse( - Optional> items, - boolean hasMore, - String url, - Optional nextUrl, - Optional cursor, - Map additionalProperties) { - this.items = items; - this.hasMore = hasMore; - this.url = url; - this.nextUrl = nextUrl; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public Optional> getItems() { - return items; - } - - /** - * @return Set to true when there are more pages that can be retrieved. - */ - @JsonProperty("has_more") - public boolean getHasMore() { - return hasMore; - } - - /** - * @return A url that may be used to generate these results. - */ - @JsonProperty("url") - public String getUrl() { - return url; - } - - /** - * @return A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true - */ - @JsonProperty("next_url") - public Optional getNextUrl() { - return nextUrl; - } - - /** - * @return A pointer to the next page of results. Defined - * only when has_more is set to true - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return Always set to list. Represents the type of this object. - */ - @JsonProperty("type") - public String getType() { - return "list"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListUsersForTenantResponse && equalTo((ListUsersForTenantResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListUsersForTenantResponse other) { - return items.equals(other.items) - && hasMore == other.hasMore - && url.equals(other.url) - && nextUrl.equals(other.nextUrl) - && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items, this.hasMore, this.url, this.nextUrl, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static HasMoreStage builder() { - return new Builder(); - } - - public interface HasMoreStage { - UrlStage hasMore(boolean hasMore); - - Builder from(ListUsersForTenantResponse other); - } - - public interface UrlStage { - _FinalStage url(String url); - } - - public interface _FinalStage { - ListUsersForTenantResponse build(); - - _FinalStage items(Optional> items); - - _FinalStage items(List items); - - _FinalStage nextUrl(Optional nextUrl); - - _FinalStage nextUrl(String nextUrl); - - _FinalStage cursor(Optional cursor); - - _FinalStage cursor(String cursor); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements HasMoreStage, UrlStage, _FinalStage { - private boolean hasMore; - - private String url; - - private Optional cursor = Optional.empty(); - - private Optional nextUrl = Optional.empty(); - - private Optional> items = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListUsersForTenantResponse other) { - items(other.getItems()); - hasMore(other.getHasMore()); - url(other.getUrl()); - nextUrl(other.getNextUrl()); - cursor(other.getCursor()); - return this; - } - - /** - *

Set to true when there are more pages that can be retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("has_more") - public UrlStage hasMore(boolean hasMore) { - this.hasMore = hasMore; - return this; - } - - /** - *

A url that may be used to generate these results.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - /** - *

A pointer to the next page of results. Defined - * only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public _FinalStage cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - /** - *

A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage nextUrl(String nextUrl) { - this.nextUrl = Optional.of(nextUrl); - return this; - } - - @java.lang.Override - @JsonSetter(value = "next_url", nulls = Nulls.SKIP) - public _FinalStage nextUrl(Optional nextUrl) { - this.nextUrl = nextUrl; - return this; - } - - @java.lang.Override - public _FinalStage items(List items) { - this.items = Optional.of(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(Optional> items) { - this.items = items; - return this; - } - - @java.lang.Override - public ListUsersForTenantResponse build() { - return new ListUsersForTenantResponse(items, hasMore, url, nextUrl, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopic.java b/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopic.java deleted file mode 100644 index 3b61f20d..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopic.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ChannelClassification; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscriptionTopic.Builder.class) -public final class SubscriptionTopic implements ISubscriptionTopicNew { - private final SubscriptionTopicStatus status; - - private final Optional hasCustomRouting; - - private final Optional> customRouting; - - private final String id; - - private final Map additionalProperties; - - private SubscriptionTopic( - SubscriptionTopicStatus status, - Optional hasCustomRouting, - Optional> customRouting, - String id, - Map additionalProperties) { - this.status = status; - this.hasCustomRouting = hasCustomRouting; - this.customRouting = customRouting; - this.id = id; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - @java.lang.Override - public SubscriptionTopicStatus getStatus() { - return status; - } - - /** - * @return Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences - */ - @JsonProperty("has_custom_routing") - @java.lang.Override - public Optional getHasCustomRouting() { - return hasCustomRouting; - } - - /** - * @return The default channels to send to this tenant when has_custom_routing is enabled - */ - @JsonProperty("custom_routing") - @java.lang.Override - public Optional> getCustomRouting() { - return customRouting; - } - - /** - * @return Topic ID - */ - @JsonProperty("id") - public String getId() { - return id; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscriptionTopic && equalTo((SubscriptionTopic) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubscriptionTopic other) { - return status.equals(other.status) - && hasCustomRouting.equals(other.hasCustomRouting) - && customRouting.equals(other.customRouting) - && id.equals(other.id); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.status, this.hasCustomRouting, this.customRouting, this.id); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - IdStage status(SubscriptionTopicStatus status); - - Builder from(SubscriptionTopic other); - } - - public interface IdStage { - _FinalStage id(String id); - } - - public interface _FinalStage { - SubscriptionTopic build(); - - _FinalStage hasCustomRouting(Optional hasCustomRouting); - - _FinalStage hasCustomRouting(Boolean hasCustomRouting); - - _FinalStage customRouting(Optional> customRouting); - - _FinalStage customRouting(List customRouting); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, IdStage, _FinalStage { - private SubscriptionTopicStatus status; - - private String id; - - private Optional> customRouting = Optional.empty(); - - private Optional hasCustomRouting = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SubscriptionTopic other) { - status(other.getStatus()); - hasCustomRouting(other.getHasCustomRouting()); - customRouting(other.getCustomRouting()); - id(other.getId()); - return this; - } - - @java.lang.Override - @JsonSetter("status") - public IdStage status(SubscriptionTopicStatus status) { - this.status = status; - return this; - } - - /** - *

Topic ID

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public _FinalStage id(String id) { - this.id = id; - return this; - } - - /** - *

The default channels to send to this tenant when has_custom_routing is enabled

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customRouting(List customRouting) { - this.customRouting = Optional.of(customRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "custom_routing", nulls = Nulls.SKIP) - public _FinalStage customRouting(Optional> customRouting) { - this.customRouting = customRouting; - return this; - } - - /** - *

Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage hasCustomRouting(Boolean hasCustomRouting) { - this.hasCustomRouting = Optional.of(hasCustomRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_custom_routing", nulls = Nulls.SKIP) - public _FinalStage hasCustomRouting(Optional hasCustomRouting) { - this.hasCustomRouting = hasCustomRouting; - return this; - } - - @java.lang.Override - public SubscriptionTopic build() { - return new SubscriptionTopic(status, hasCustomRouting, customRouting, id, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicNew.java b/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicNew.java deleted file mode 100644 index d0e49e6a..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicNew.java +++ /dev/null @@ -1,184 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ChannelClassification; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SubscriptionTopicNew.Builder.class) -public final class SubscriptionTopicNew implements ISubscriptionTopicNew { - private final SubscriptionTopicStatus status; - - private final Optional hasCustomRouting; - - private final Optional> customRouting; - - private final Map additionalProperties; - - private SubscriptionTopicNew( - SubscriptionTopicStatus status, - Optional hasCustomRouting, - Optional> customRouting, - Map additionalProperties) { - this.status = status; - this.hasCustomRouting = hasCustomRouting; - this.customRouting = customRouting; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - @java.lang.Override - public SubscriptionTopicStatus getStatus() { - return status; - } - - /** - * @return Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences - */ - @JsonProperty("has_custom_routing") - @java.lang.Override - public Optional getHasCustomRouting() { - return hasCustomRouting; - } - - /** - * @return The default channels to send to this tenant when has_custom_routing is enabled - */ - @JsonProperty("custom_routing") - @java.lang.Override - public Optional> getCustomRouting() { - return customRouting; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SubscriptionTopicNew && equalTo((SubscriptionTopicNew) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SubscriptionTopicNew other) { - return status.equals(other.status) - && hasCustomRouting.equals(other.hasCustomRouting) - && customRouting.equals(other.customRouting); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.status, this.hasCustomRouting, this.customRouting); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - _FinalStage status(SubscriptionTopicStatus status); - - Builder from(SubscriptionTopicNew other); - } - - public interface _FinalStage { - SubscriptionTopicNew build(); - - _FinalStage hasCustomRouting(Optional hasCustomRouting); - - _FinalStage hasCustomRouting(Boolean hasCustomRouting); - - _FinalStage customRouting(Optional> customRouting); - - _FinalStage customRouting(List customRouting); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, _FinalStage { - private SubscriptionTopicStatus status; - - private Optional> customRouting = Optional.empty(); - - private Optional hasCustomRouting = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SubscriptionTopicNew other) { - status(other.getStatus()); - hasCustomRouting(other.getHasCustomRouting()); - customRouting(other.getCustomRouting()); - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(SubscriptionTopicStatus status) { - this.status = status; - return this; - } - - /** - *

The default channels to send to this tenant when has_custom_routing is enabled

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customRouting(List customRouting) { - this.customRouting = Optional.of(customRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "custom_routing", nulls = Nulls.SKIP) - public _FinalStage customRouting(Optional> customRouting) { - this.customRouting = customRouting; - return this; - } - - /** - *

Override channel routing with custom preferences. This will override any template prefernces that are set, but a user can still customize their preferences

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage hasCustomRouting(Boolean hasCustomRouting) { - this.hasCustomRouting = Optional.of(hasCustomRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_custom_routing", nulls = Nulls.SKIP) - public _FinalStage hasCustomRouting(Optional hasCustomRouting) { - this.hasCustomRouting = hasCustomRouting; - return this; - } - - @java.lang.Override - public SubscriptionTopicNew build() { - return new SubscriptionTopicNew(status, hasCustomRouting, customRouting, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicStatus.java b/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicStatus.java deleted file mode 100644 index c58ee77e..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/SubscriptionTopicStatus.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum SubscriptionTopicStatus { - OPTED_OUT("OPTED_OUT"), - - OPTED_IN("OPTED_IN"), - - REQUIRED("REQUIRED"); - - private final String value; - - SubscriptionTopicStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/Tenant.java b/src/main/java/com/courier/api/resources/tenants/types/Tenant.java deleted file mode 100644 index e8d9b876..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/Tenant.java +++ /dev/null @@ -1,343 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Tenant.Builder.class) -public final class Tenant { - private final String id; - - private final String name; - - private final Optional parentTenantId; - - private final Optional defaultPreferences; - - private final Optional> properties; - - private final Optional> userProfile; - - private final Optional brandId; - - private final Map additionalProperties; - - private Tenant( - String id, - String name, - Optional parentTenantId, - Optional defaultPreferences, - Optional> properties, - Optional> userProfile, - Optional brandId, - Map additionalProperties) { - this.id = id; - this.name = name; - this.parentTenantId = parentTenantId; - this.defaultPreferences = defaultPreferences; - this.properties = properties; - this.userProfile = userProfile; - this.brandId = brandId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Id of the tenant. - */ - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * @return Name of the tenant. - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * @return Tenant's parent id (if any). - */ - @JsonProperty("parent_tenant_id") - public Optional getParentTenantId() { - return parentTenantId; - } - - /** - * @return Defines the preferences used for the account when the user hasn't specified their own. - */ - @JsonProperty("default_preferences") - public Optional getDefaultPreferences() { - return defaultPreferences; - } - - /** - * @return Arbitrary properties accessible to a template. - */ - @JsonProperty("properties") - public Optional> getProperties() { - return properties; - } - - /** - * @return A user profile object merged with user profile on send. - */ - @JsonProperty("user_profile") - public Optional> getUserProfile() { - return userProfile; - } - - /** - * @return Brand to be used for the account when one is not specified by the send call. - */ - @JsonProperty("brand_id") - public Optional getBrandId() { - return brandId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Tenant && equalTo((Tenant) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Tenant other) { - return id.equals(other.id) - && name.equals(other.name) - && parentTenantId.equals(other.parentTenantId) - && defaultPreferences.equals(other.defaultPreferences) - && properties.equals(other.properties) - && userProfile.equals(other.userProfile) - && brandId.equals(other.brandId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.id, - this.name, - this.parentTenantId, - this.defaultPreferences, - this.properties, - this.userProfile, - this.brandId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static IdStage builder() { - return new Builder(); - } - - public interface IdStage { - NameStage id(String id); - - Builder from(Tenant other); - } - - public interface NameStage { - _FinalStage name(String name); - } - - public interface _FinalStage { - Tenant build(); - - _FinalStage parentTenantId(Optional parentTenantId); - - _FinalStage parentTenantId(String parentTenantId); - - _FinalStage defaultPreferences(Optional defaultPreferences); - - _FinalStage defaultPreferences(DefaultPreferences defaultPreferences); - - _FinalStage properties(Optional> properties); - - _FinalStage properties(Map properties); - - _FinalStage userProfile(Optional> userProfile); - - _FinalStage userProfile(Map userProfile); - - _FinalStage brandId(Optional brandId); - - _FinalStage brandId(String brandId); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements IdStage, NameStage, _FinalStage { - private String id; - - private String name; - - private Optional brandId = Optional.empty(); - - private Optional> userProfile = Optional.empty(); - - private Optional> properties = Optional.empty(); - - private Optional defaultPreferences = Optional.empty(); - - private Optional parentTenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(Tenant other) { - id(other.getId()); - name(other.getName()); - parentTenantId(other.getParentTenantId()); - defaultPreferences(other.getDefaultPreferences()); - properties(other.getProperties()); - userProfile(other.getUserProfile()); - brandId(other.getBrandId()); - return this; - } - - /** - *

Id of the tenant.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("id") - public NameStage id(String id) { - this.id = id; - return this; - } - - /** - *

Name of the tenant.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("name") - public _FinalStage name(String name) { - this.name = name; - return this; - } - - /** - *

Brand to be used for the account when one is not specified by the send call.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage brandId(String brandId) { - this.brandId = Optional.of(brandId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "brand_id", nulls = Nulls.SKIP) - public _FinalStage brandId(Optional brandId) { - this.brandId = brandId; - return this; - } - - /** - *

A user profile object merged with user profile on send.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage userProfile(Map userProfile) { - this.userProfile = Optional.of(userProfile); - return this; - } - - @java.lang.Override - @JsonSetter(value = "user_profile", nulls = Nulls.SKIP) - public _FinalStage userProfile(Optional> userProfile) { - this.userProfile = userProfile; - return this; - } - - /** - *

Arbitrary properties accessible to a template.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage properties(Map properties) { - this.properties = Optional.of(properties); - return this; - } - - @java.lang.Override - @JsonSetter(value = "properties", nulls = Nulls.SKIP) - public _FinalStage properties(Optional> properties) { - this.properties = properties; - return this; - } - - /** - *

Defines the preferences used for the account when the user hasn't specified their own.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage defaultPreferences(DefaultPreferences defaultPreferences) { - this.defaultPreferences = Optional.of(defaultPreferences); - return this; - } - - @java.lang.Override - @JsonSetter(value = "default_preferences", nulls = Nulls.SKIP) - public _FinalStage defaultPreferences(Optional defaultPreferences) { - this.defaultPreferences = defaultPreferences; - return this; - } - - /** - *

Tenant's parent id (if any).

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage parentTenantId(String parentTenantId) { - this.parentTenantId = Optional.of(parentTenantId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "parent_tenant_id", nulls = Nulls.SKIP) - public _FinalStage parentTenantId(Optional parentTenantId) { - this.parentTenantId = parentTenantId; - return this; - } - - @java.lang.Override - public Tenant build() { - return new Tenant( - id, - name, - parentTenantId, - defaultPreferences, - properties, - userProfile, - brandId, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/tenants/types/TenantListResponse.java b/src/main/java/com/courier/api/resources/tenants/types/TenantListResponse.java deleted file mode 100644 index 5e679bff..00000000 --- a/src/main/java/com/courier/api/resources/tenants/types/TenantListResponse.java +++ /dev/null @@ -1,279 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TenantListResponse.Builder.class) -public final class TenantListResponse { - private final Optional cursor; - - private final boolean hasMore; - - private final List items; - - private final Optional nextUrl; - - private final String url; - - private final Map additionalProperties; - - private TenantListResponse( - Optional cursor, - boolean hasMore, - List items, - Optional nextUrl, - String url, - Map additionalProperties) { - this.cursor = cursor; - this.hasMore = hasMore; - this.items = items; - this.nextUrl = nextUrl; - this.url = url; - this.additionalProperties = additionalProperties; - } - - /** - * @return A pointer to the next page of results. Defined only when has_more is set to true. - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return Set to true when there are more pages that can be retrieved. - */ - @JsonProperty("has_more") - public boolean getHasMore() { - return hasMore; - } - - /** - * @return An array of Tenants - */ - @JsonProperty("items") - public List getItems() { - return items; - } - - /** - * @return A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true - */ - @JsonProperty("next_url") - public Optional getNextUrl() { - return nextUrl; - } - - /** - * @return A url that may be used to generate these results. - */ - @JsonProperty("url") - public String getUrl() { - return url; - } - - /** - * @return Always set to "list". Represents the type of this object. - */ - @JsonProperty("type") - public String getType() { - return "list"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TenantListResponse && equalTo((TenantListResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TenantListResponse other) { - return cursor.equals(other.cursor) - && hasMore == other.hasMore - && items.equals(other.items) - && nextUrl.equals(other.nextUrl) - && url.equals(other.url); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.cursor, this.hasMore, this.items, this.nextUrl, this.url); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static HasMoreStage builder() { - return new Builder(); - } - - public interface HasMoreStage { - UrlStage hasMore(boolean hasMore); - - Builder from(TenantListResponse other); - } - - public interface UrlStage { - _FinalStage url(String url); - } - - public interface _FinalStage { - TenantListResponse build(); - - _FinalStage cursor(Optional cursor); - - _FinalStage cursor(String cursor); - - _FinalStage items(List items); - - _FinalStage addItems(Tenant items); - - _FinalStage addAllItems(List items); - - _FinalStage nextUrl(Optional nextUrl); - - _FinalStage nextUrl(String nextUrl); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements HasMoreStage, UrlStage, _FinalStage { - private boolean hasMore; - - private String url; - - private Optional nextUrl = Optional.empty(); - - private List items = new ArrayList<>(); - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TenantListResponse other) { - cursor(other.getCursor()); - hasMore(other.getHasMore()); - items(other.getItems()); - nextUrl(other.getNextUrl()); - url(other.getUrl()); - return this; - } - - /** - *

Set to true when there are more pages that can be retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("has_more") - public UrlStage hasMore(boolean hasMore) { - this.hasMore = hasMore; - return this; - } - - /** - *

A url that may be used to generate these results.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - /** - *

A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage nextUrl(String nextUrl) { - this.nextUrl = Optional.of(nextUrl); - return this; - } - - @java.lang.Override - @JsonSetter(value = "next_url", nulls = Nulls.SKIP) - public _FinalStage nextUrl(Optional nextUrl) { - this.nextUrl = nextUrl; - return this; - } - - /** - *

An array of Tenants

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllItems(List items) { - this.items.addAll(items); - return this; - } - - /** - *

An array of Tenants

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addItems(Tenant items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - /** - *

A pointer to the next page of results. Defined only when has_more is set to true.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public _FinalStage cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - @java.lang.Override - public TenantListResponse build() { - return new TenantListResponse(cursor, hasMore, items, nextUrl, url, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/translations/TranslationsClient.java b/src/main/java/com/courier/api/resources/translations/TranslationsClient.java deleted file mode 100644 index 26bf0437..00000000 --- a/src/main/java/com/courier/api/resources/translations/TranslationsClient.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.translations; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiNotFoundError; -import com.courier.api.resources.commons.types.NotFound; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class TranslationsClient { - protected final ClientOptions clientOptions; - - public TranslationsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Get translations by locale - */ - public String get(String domain, String locale) { - return get(domain, locale, null); - } - - /** - * Get translations by locale - */ - public String get(String domain, String locale, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("translations") - .addPathSegment(domain) - .addPathSegment(locale) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), String.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new CourierApiNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Update a translation - */ - public void update(String domain, String locale, String request) { - update(domain, locale, request, null); - } - - /** - * Update a translation - */ - public void update(String domain, String locale, String request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("translations") - .addPathSegment(domain) - .addPathSegment(locale) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new CourierApiNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/UsersClient.java b/src/main/java/com/courier/api/resources/users/UsersClient.java deleted file mode 100644 index 73d17827..00000000 --- a/src/main/java/com/courier/api/resources/users/UsersClient.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.Suppliers; -import com.courier.api.resources.users.preferences.PreferencesClient; -import com.courier.api.resources.users.tenants.TenantsClient; -import com.courier.api.resources.users.tokens.TokensClient; -import java.util.function.Supplier; - -public class UsersClient { - protected final ClientOptions clientOptions; - - protected final Supplier preferencesClient; - - protected final Supplier tenantsClient; - - protected final Supplier tokensClient; - - public UsersClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - this.preferencesClient = Suppliers.memoize(() -> new PreferencesClient(clientOptions)); - this.tenantsClient = Suppliers.memoize(() -> new TenantsClient(clientOptions)); - this.tokensClient = Suppliers.memoize(() -> new TokensClient(clientOptions)); - } - - public PreferencesClient preferences() { - return this.preferencesClient.get(); - } - - public TenantsClient tenants() { - return this.tenantsClient.get(); - } - - public TokensClient tokens() { - return this.tokensClient.get(); - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/PreferencesClient.java b/src/main/java/com/courier/api/resources/users/preferences/PreferencesClient.java deleted file mode 100644 index 14a55823..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/PreferencesClient.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.errors.CourierApiNotFoundError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.commons.types.NotFound; -import com.courier.api.resources.users.preferences.requests.UserPreferencesParams; -import com.courier.api.resources.users.preferences.requests.UserPreferencesTopicParams; -import com.courier.api.resources.users.preferences.requests.UserPreferencesUpdateParams; -import com.courier.api.resources.users.preferences.types.UserPreferencesGetResponse; -import com.courier.api.resources.users.preferences.types.UserPreferencesListResponse; -import com.courier.api.resources.users.preferences.types.UserPreferencesUpdateResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class PreferencesClient { - protected final ClientOptions clientOptions; - - public PreferencesClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Fetch all user preferences. - */ - public UserPreferencesListResponse list(String userId) { - return list(userId, UserPreferencesParams.builder().build()); - } - - /** - * Fetch all user preferences. - */ - public UserPreferencesListResponse list(String userId, UserPreferencesParams request) { - return list(userId, request, null); - } - - /** - * Fetch all user preferences. - */ - public UserPreferencesListResponse list( - String userId, UserPreferencesParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("preferences"); - if (request.getTenantId().isPresent()) { - httpUrl.addQueryParameter("tenant_id", request.getTenantId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UserPreferencesListResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Fetch user preferences for a specific subscription topic. - */ - public UserPreferencesGetResponse get(String userId, String topicId) { - return get(userId, topicId, UserPreferencesTopicParams.builder().build()); - } - - /** - * Fetch user preferences for a specific subscription topic. - */ - public UserPreferencesGetResponse get(String userId, String topicId, UserPreferencesTopicParams request) { - return get(userId, topicId, request, null); - } - - /** - * Fetch user preferences for a specific subscription topic. - */ - public UserPreferencesGetResponse get( - String userId, String topicId, UserPreferencesTopicParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("preferences") - .addPathSegment(topicId); - if (request.getTenantId().isPresent()) { - httpUrl.addQueryParameter("tenant_id", request.getTenantId().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UserPreferencesGetResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 404) { - throw new CourierApiNotFoundError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, NotFound.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Update or Create user preferences for a specific subscription topic. - */ - public UserPreferencesUpdateResponse update(String userId, String topicId, UserPreferencesUpdateParams request) { - return update(userId, topicId, request, null); - } - - /** - * Update or Create user preferences for a specific subscription topic. - */ - public UserPreferencesUpdateResponse update( - String userId, String topicId, UserPreferencesUpdateParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("preferences") - .addPathSegment(topicId); - if (request.getTenantId().isPresent()) { - httpUrl.addQueryParameter("tenant_id", request.getTenantId().get()); - } - Map properties = new HashMap<>(); - properties.put("topic", request.getTopic()); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(properties), MediaTypes.APPLICATION_JSON); - } catch (Exception e) { - throw new RuntimeException(e); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UserPreferencesUpdateResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesParams.java b/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesParams.java deleted file mode 100644 index 12060948..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesParams.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserPreferencesParams.Builder.class) -public final class UserPreferencesParams { - private final Optional tenantId; - - private final Map additionalProperties; - - private UserPreferencesParams(Optional tenantId, Map additionalProperties) { - this.tenantId = tenantId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Query the preferences of a user for this specific tenant context. - */ - @JsonProperty("tenant_id") - public Optional getTenantId() { - return tenantId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserPreferencesParams && equalTo((UserPreferencesParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserPreferencesParams other) { - return tenantId.equals(other.tenantId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional tenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(UserPreferencesParams other) { - tenantId(other.getTenantId()); - return this; - } - - @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) - public Builder tenantId(Optional tenantId) { - this.tenantId = tenantId; - return this; - } - - public Builder tenantId(String tenantId) { - this.tenantId = Optional.of(tenantId); - return this; - } - - public UserPreferencesParams build() { - return new UserPreferencesParams(tenantId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesTopicParams.java b/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesTopicParams.java deleted file mode 100644 index a834fdf9..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesTopicParams.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserPreferencesTopicParams.Builder.class) -public final class UserPreferencesTopicParams { - private final Optional tenantId; - - private final Map additionalProperties; - - private UserPreferencesTopicParams(Optional tenantId, Map additionalProperties) { - this.tenantId = tenantId; - this.additionalProperties = additionalProperties; - } - - /** - * @return Query the preferences of a user for this specific tenant context. - */ - @JsonProperty("tenant_id") - public Optional getTenantId() { - return tenantId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserPreferencesTopicParams && equalTo((UserPreferencesTopicParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserPreferencesTopicParams other) { - return tenantId.equals(other.tenantId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional tenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(UserPreferencesTopicParams other) { - tenantId(other.getTenantId()); - return this; - } - - @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) - public Builder tenantId(Optional tenantId) { - this.tenantId = tenantId; - return this; - } - - public Builder tenantId(String tenantId) { - this.tenantId = Optional.of(tenantId); - return this; - } - - public UserPreferencesTopicParams build() { - return new UserPreferencesTopicParams(tenantId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesUpdateParams.java b/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesUpdateParams.java deleted file mode 100644 index dc73205d..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/requests/UserPreferencesUpdateParams.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.users.preferences.types.TopicPreferenceUpdate; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserPreferencesUpdateParams.Builder.class) -public final class UserPreferencesUpdateParams { - private final Optional tenantId; - - private final TopicPreferenceUpdate topic; - - private final Map additionalProperties; - - private UserPreferencesUpdateParams( - Optional tenantId, TopicPreferenceUpdate topic, Map additionalProperties) { - this.tenantId = tenantId; - this.topic = topic; - this.additionalProperties = additionalProperties; - } - - /** - * @return Update the preferences of a user for this specific tenant context. - */ - @JsonProperty("tenant_id") - public Optional getTenantId() { - return tenantId; - } - - @JsonProperty("topic") - public TopicPreferenceUpdate getTopic() { - return topic; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserPreferencesUpdateParams && equalTo((UserPreferencesUpdateParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserPreferencesUpdateParams other) { - return tenantId.equals(other.tenantId) && topic.equals(other.topic); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenantId, this.topic); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TopicStage builder() { - return new Builder(); - } - - public interface TopicStage { - _FinalStage topic(TopicPreferenceUpdate topic); - - Builder from(UserPreferencesUpdateParams other); - } - - public interface _FinalStage { - UserPreferencesUpdateParams build(); - - _FinalStage tenantId(Optional tenantId); - - _FinalStage tenantId(String tenantId); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TopicStage, _FinalStage { - private TopicPreferenceUpdate topic; - - private Optional tenantId = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserPreferencesUpdateParams other) { - tenantId(other.getTenantId()); - topic(other.getTopic()); - return this; - } - - @java.lang.Override - @JsonSetter("topic") - public _FinalStage topic(TopicPreferenceUpdate topic) { - this.topic = topic; - return this; - } - - /** - *

Update the preferences of a user for this specific tenant context.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tenantId(String tenantId) { - this.tenantId = Optional.of(tenantId); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tenant_id", nulls = Nulls.SKIP) - public _FinalStage tenantId(Optional tenantId) { - this.tenantId = tenantId; - return this; - } - - @java.lang.Override - public UserPreferencesUpdateParams build() { - return new UserPreferencesUpdateParams(tenantId, topic, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/types/TopicPreference.java b/src/main/java/com/courier/api/resources/users/preferences/types/TopicPreference.java deleted file mode 100644 index e5831d13..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/types/TopicPreference.java +++ /dev/null @@ -1,255 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ChannelClassification; -import com.courier.api.resources.commons.types.PreferenceStatus; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TopicPreference.Builder.class) -public final class TopicPreference { - private final Optional> customRouting; - - private final PreferenceStatus defaultStatus; - - private final Optional hasCustomRouting; - - private final PreferenceStatus status; - - private final String topicId; - - private final String topicName; - - private final Map additionalProperties; - - private TopicPreference( - Optional> customRouting, - PreferenceStatus defaultStatus, - Optional hasCustomRouting, - PreferenceStatus status, - String topicId, - String topicName, - Map additionalProperties) { - this.customRouting = customRouting; - this.defaultStatus = defaultStatus; - this.hasCustomRouting = hasCustomRouting; - this.status = status; - this.topicId = topicId; - this.topicName = topicName; - this.additionalProperties = additionalProperties; - } - - /** - * @return The Channels a user has chosen to receive notifications through for this topic - */ - @JsonProperty("custom_routing") - public Optional> getCustomRouting() { - return customRouting; - } - - @JsonProperty("default_status") - public PreferenceStatus getDefaultStatus() { - return defaultStatus; - } - - @JsonProperty("has_custom_routing") - public Optional getHasCustomRouting() { - return hasCustomRouting; - } - - @JsonProperty("status") - public PreferenceStatus getStatus() { - return status; - } - - @JsonProperty("topic_id") - public String getTopicId() { - return topicId; - } - - @JsonProperty("topic_name") - public String getTopicName() { - return topicName; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TopicPreference && equalTo((TopicPreference) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TopicPreference other) { - return customRouting.equals(other.customRouting) - && defaultStatus.equals(other.defaultStatus) - && hasCustomRouting.equals(other.hasCustomRouting) - && status.equals(other.status) - && topicId.equals(other.topicId) - && topicName.equals(other.topicName); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.customRouting, - this.defaultStatus, - this.hasCustomRouting, - this.status, - this.topicId, - this.topicName); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static DefaultStatusStage builder() { - return new Builder(); - } - - public interface DefaultStatusStage { - StatusStage defaultStatus(PreferenceStatus defaultStatus); - - Builder from(TopicPreference other); - } - - public interface StatusStage { - TopicIdStage status(PreferenceStatus status); - } - - public interface TopicIdStage { - TopicNameStage topicId(String topicId); - } - - public interface TopicNameStage { - _FinalStage topicName(String topicName); - } - - public interface _FinalStage { - TopicPreference build(); - - _FinalStage customRouting(Optional> customRouting); - - _FinalStage customRouting(List customRouting); - - _FinalStage hasCustomRouting(Optional hasCustomRouting); - - _FinalStage hasCustomRouting(Boolean hasCustomRouting); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder - implements DefaultStatusStage, StatusStage, TopicIdStage, TopicNameStage, _FinalStage { - private PreferenceStatus defaultStatus; - - private PreferenceStatus status; - - private String topicId; - - private String topicName; - - private Optional hasCustomRouting = Optional.empty(); - - private Optional> customRouting = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TopicPreference other) { - customRouting(other.getCustomRouting()); - defaultStatus(other.getDefaultStatus()); - hasCustomRouting(other.getHasCustomRouting()); - status(other.getStatus()); - topicId(other.getTopicId()); - topicName(other.getTopicName()); - return this; - } - - @java.lang.Override - @JsonSetter("default_status") - public StatusStage defaultStatus(PreferenceStatus defaultStatus) { - this.defaultStatus = defaultStatus; - return this; - } - - @java.lang.Override - @JsonSetter("status") - public TopicIdStage status(PreferenceStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - @JsonSetter("topic_id") - public TopicNameStage topicId(String topicId) { - this.topicId = topicId; - return this; - } - - @java.lang.Override - @JsonSetter("topic_name") - public _FinalStage topicName(String topicName) { - this.topicName = topicName; - return this; - } - - @java.lang.Override - public _FinalStage hasCustomRouting(Boolean hasCustomRouting) { - this.hasCustomRouting = Optional.of(hasCustomRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_custom_routing", nulls = Nulls.SKIP) - public _FinalStage hasCustomRouting(Optional hasCustomRouting) { - this.hasCustomRouting = hasCustomRouting; - return this; - } - - /** - *

The Channels a user has chosen to receive notifications through for this topic

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customRouting(List customRouting) { - this.customRouting = Optional.of(customRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "custom_routing", nulls = Nulls.SKIP) - public _FinalStage customRouting(Optional> customRouting) { - this.customRouting = customRouting; - return this; - } - - @java.lang.Override - public TopicPreference build() { - return new TopicPreference( - customRouting, defaultStatus, hasCustomRouting, status, topicId, topicName, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/types/TopicPreferenceUpdate.java b/src/main/java/com/courier/api/resources/users/preferences/types/TopicPreferenceUpdate.java deleted file mode 100644 index c6557889..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/types/TopicPreferenceUpdate.java +++ /dev/null @@ -1,175 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.ChannelClassification; -import com.courier.api.resources.commons.types.PreferenceStatus; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = TopicPreferenceUpdate.Builder.class) -public final class TopicPreferenceUpdate { - private final PreferenceStatus status; - - private final Optional> customRouting; - - private final Optional hasCustomRouting; - - private final Map additionalProperties; - - private TopicPreferenceUpdate( - PreferenceStatus status, - Optional> customRouting, - Optional hasCustomRouting, - Map additionalProperties) { - this.status = status; - this.customRouting = customRouting; - this.hasCustomRouting = hasCustomRouting; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("status") - public PreferenceStatus getStatus() { - return status; - } - - /** - * @return The Channels a user has chosen to receive notifications through for this topic - */ - @JsonProperty("custom_routing") - public Optional> getCustomRouting() { - return customRouting; - } - - @JsonProperty("has_custom_routing") - public Optional getHasCustomRouting() { - return hasCustomRouting; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof TopicPreferenceUpdate && equalTo((TopicPreferenceUpdate) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(TopicPreferenceUpdate other) { - return status.equals(other.status) - && customRouting.equals(other.customRouting) - && hasCustomRouting.equals(other.hasCustomRouting); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.status, this.customRouting, this.hasCustomRouting); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static StatusStage builder() { - return new Builder(); - } - - public interface StatusStage { - _FinalStage status(PreferenceStatus status); - - Builder from(TopicPreferenceUpdate other); - } - - public interface _FinalStage { - TopicPreferenceUpdate build(); - - _FinalStage customRouting(Optional> customRouting); - - _FinalStage customRouting(List customRouting); - - _FinalStage hasCustomRouting(Optional hasCustomRouting); - - _FinalStage hasCustomRouting(Boolean hasCustomRouting); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements StatusStage, _FinalStage { - private PreferenceStatus status; - - private Optional hasCustomRouting = Optional.empty(); - - private Optional> customRouting = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(TopicPreferenceUpdate other) { - status(other.getStatus()); - customRouting(other.getCustomRouting()); - hasCustomRouting(other.getHasCustomRouting()); - return this; - } - - @java.lang.Override - @JsonSetter("status") - public _FinalStage status(PreferenceStatus status) { - this.status = status; - return this; - } - - @java.lang.Override - public _FinalStage hasCustomRouting(Boolean hasCustomRouting) { - this.hasCustomRouting = Optional.of(hasCustomRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "has_custom_routing", nulls = Nulls.SKIP) - public _FinalStage hasCustomRouting(Optional hasCustomRouting) { - this.hasCustomRouting = hasCustomRouting; - return this; - } - - /** - *

The Channels a user has chosen to receive notifications through for this topic

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage customRouting(List customRouting) { - this.customRouting = Optional.of(customRouting); - return this; - } - - @java.lang.Override - @JsonSetter(value = "custom_routing", nulls = Nulls.SKIP) - public _FinalStage customRouting(Optional> customRouting) { - this.customRouting = customRouting; - return this; - } - - @java.lang.Override - public TopicPreferenceUpdate build() { - return new TopicPreferenceUpdate(status, customRouting, hasCustomRouting, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesGetResponse.java b/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesGetResponse.java deleted file mode 100644 index ea1bf270..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesGetResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserPreferencesGetResponse.Builder.class) -public final class UserPreferencesGetResponse { - private final TopicPreference topic; - - private final Map additionalProperties; - - private UserPreferencesGetResponse(TopicPreference topic, Map additionalProperties) { - this.topic = topic; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("topic") - public TopicPreference getTopic() { - return topic; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserPreferencesGetResponse && equalTo((UserPreferencesGetResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserPreferencesGetResponse other) { - return topic.equals(other.topic); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.topic); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TopicStage builder() { - return new Builder(); - } - - public interface TopicStage { - _FinalStage topic(TopicPreference topic); - - Builder from(UserPreferencesGetResponse other); - } - - public interface _FinalStage { - UserPreferencesGetResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TopicStage, _FinalStage { - private TopicPreference topic; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserPreferencesGetResponse other) { - topic(other.getTopic()); - return this; - } - - @java.lang.Override - @JsonSetter("topic") - public _FinalStage topic(TopicPreference topic) { - this.topic = topic; - return this; - } - - @java.lang.Override - public UserPreferencesGetResponse build() { - return new UserPreferencesGetResponse(topic, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesListResponse.java b/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesListResponse.java deleted file mode 100644 index 8b762544..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesListResponse.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.Paging; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserPreferencesListResponse.Builder.class) -public final class UserPreferencesListResponse { - private final Paging paging; - - private final List items; - - private final Map additionalProperties; - - private UserPreferencesListResponse( - Paging paging, List items, Map additionalProperties) { - this.paging = paging; - this.items = items; - this.additionalProperties = additionalProperties; - } - - /** - * @return Deprecated - Paging not implemented on this endpoint - */ - @JsonProperty("paging") - public Paging getPaging() { - return paging; - } - - /** - * @return The Preferences associated with the user_id. - */ - @JsonProperty("items") - public List getItems() { - return items; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserPreferencesListResponse && equalTo((UserPreferencesListResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserPreferencesListResponse other) { - return paging.equals(other.paging) && items.equals(other.items); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.paging, this.items); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static PagingStage builder() { - return new Builder(); - } - - public interface PagingStage { - _FinalStage paging(Paging paging); - - Builder from(UserPreferencesListResponse other); - } - - public interface _FinalStage { - UserPreferencesListResponse build(); - - _FinalStage items(List items); - - _FinalStage addItems(TopicPreference items); - - _FinalStage addAllItems(List items); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements PagingStage, _FinalStage { - private Paging paging; - - private List items = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserPreferencesListResponse other) { - paging(other.getPaging()); - items(other.getItems()); - return this; - } - - /** - *

Deprecated - Paging not implemented on this endpoint

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("paging") - public _FinalStage paging(Paging paging) { - this.paging = paging; - return this; - } - - /** - *

The Preferences associated with the user_id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addAllItems(List items) { - this.items.addAll(items); - return this; - } - - /** - *

The Preferences associated with the user_id.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage addItems(TopicPreference items) { - this.items.add(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(List items) { - this.items.clear(); - this.items.addAll(items); - return this; - } - - @java.lang.Override - public UserPreferencesListResponse build() { - return new UserPreferencesListResponse(paging, items, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesUpdateResponse.java b/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesUpdateResponse.java deleted file mode 100644 index 42ce03d6..00000000 --- a/src/main/java/com/courier/api/resources/users/preferences/types/UserPreferencesUpdateResponse.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.preferences.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserPreferencesUpdateResponse.Builder.class) -public final class UserPreferencesUpdateResponse { - private final String message; - - private final Map additionalProperties; - - private UserPreferencesUpdateResponse(String message, Map additionalProperties) { - this.message = message; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("message") - public String getMessage() { - return message; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserPreferencesUpdateResponse && equalTo((UserPreferencesUpdateResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserPreferencesUpdateResponse other) { - return message.equals(other.message); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.message); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static MessageStage builder() { - return new Builder(); - } - - public interface MessageStage { - _FinalStage message(String message); - - Builder from(UserPreferencesUpdateResponse other); - } - - public interface _FinalStage { - UserPreferencesUpdateResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements MessageStage, _FinalStage { - private String message; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserPreferencesUpdateResponse other) { - message(other.getMessage()); - return this; - } - - @java.lang.Override - @JsonSetter("message") - public _FinalStage message(String message) { - this.message = message; - return this; - } - - @java.lang.Override - public UserPreferencesUpdateResponse build() { - return new UserPreferencesUpdateResponse(message, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tenants/TenantsClient.java b/src/main/java/com/courier/api/resources/users/tenants/TenantsClient.java deleted file mode 100644 index 419fe8e0..00000000 --- a/src/main/java/com/courier/api/resources/users/tenants/TenantsClient.java +++ /dev/null @@ -1,294 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tenants; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.users.tenants.requests.AddUserToMultipleTenantsParams; -import com.courier.api.resources.users.tenants.requests.AddUserToSingleTenantsParams; -import com.courier.api.resources.users.tenants.requests.ListTenantsForUserParams; -import com.courier.api.resources.users.tenants.types.ListTenantsForUserResponse; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.io.IOException; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class TenantsClient { - protected final ClientOptions clientOptions; - - public TenantsClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * This endpoint is used to add a user to - * multiple tenants in one call. - * A custom profile can also be supplied for each tenant. - * This profile will be merged with the user's main - * profile when sending to the user with that tenant. - */ - public void addMultple(String userId, AddUserToMultipleTenantsParams request) { - addMultple(userId, request, null); - } - - /** - * This endpoint is used to add a user to - * multiple tenants in one call. - * A custom profile can also be supplied for each tenant. - * This profile will be merged with the user's main - * profile when sending to the user with that tenant. - */ - public void addMultple(String userId, AddUserToMultipleTenantsParams request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tenants") - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * This endpoint is used to add a single tenant. - *

A custom profile can also be supplied with the tenant. - * This profile will be merged with the user's main profile - * when sending to the user with that tenant.

- */ - public void add(String userId, String tenantId) { - add(userId, tenantId, AddUserToSingleTenantsParams.builder().build()); - } - - /** - * This endpoint is used to add a single tenant. - *

A custom profile can also be supplied with the tenant. - * This profile will be merged with the user's main profile - * when sending to the user with that tenant.

- */ - public void add(String userId, String tenantId, AddUserToSingleTenantsParams request) { - add(userId, tenantId, request, null); - } - - /** - * This endpoint is used to add a single tenant. - *

A custom profile can also be supplied with the tenant. - * This profile will be merged with the user's main profile - * when sending to the user with that tenant.

- */ - public void add( - String userId, String tenantId, AddUserToSingleTenantsParams request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tenants") - .addPathSegment(tenantId) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Removes a user from any tenants they may have been associated with. - */ - public void removeAll(String userId) { - removeAll(userId, null); - } - - /** - * Removes a user from any tenants they may have been associated with. - */ - public void removeAll(String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tenants") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Removes a user from the supplied tenant. - */ - public void remove(String userId, String tenantId) { - remove(userId, tenantId, null); - } - - /** - * Removes a user from the supplied tenant. - */ - public void remove(String userId, String tenantId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tenants") - .addPathSegment(tenantId) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Returns a paginated list of user tenant associations. - */ - public ListTenantsForUserResponse list(String userId) { - return list(userId, ListTenantsForUserParams.builder().build()); - } - - /** - * Returns a paginated list of user tenant associations. - */ - public ListTenantsForUserResponse list(String userId, ListTenantsForUserParams request) { - return list(userId, request, null); - } - - /** - * Returns a paginated list of user tenant associations. - */ - public ListTenantsForUserResponse list( - String userId, ListTenantsForUserParams request, RequestOptions requestOptions) { - HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tenants"); - if (request.getLimit().isPresent()) { - httpUrl.addQueryParameter("limit", request.getLimit().get().toString()); - } - if (request.getCursor().isPresent()) { - httpUrl.addQueryParameter("cursor", request.getCursor().get()); - } - Request.Builder _requestBuilder = new Request.Builder() - .url(httpUrl.build()) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json"); - Request okhttpRequest = _requestBuilder.build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), ListTenantsForUserResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToMultipleTenantsParams.java b/src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToMultipleTenantsParams.java deleted file mode 100644 index b2bb30dd..00000000 --- a/src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToMultipleTenantsParams.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.UserTenantAssociation; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AddUserToMultipleTenantsParams.Builder.class) -public final class AddUserToMultipleTenantsParams { - private final List tenants; - - private final Map additionalProperties; - - private AddUserToMultipleTenantsParams( - List tenants, Map additionalProperties) { - this.tenants = tenants; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("tenants") - public List getTenants() { - return tenants; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddUserToMultipleTenantsParams && equalTo((AddUserToMultipleTenantsParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AddUserToMultipleTenantsParams other) { - return tenants.equals(other.tenants); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.tenants); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List tenants = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AddUserToMultipleTenantsParams other) { - tenants(other.getTenants()); - return this; - } - - @JsonSetter(value = "tenants", nulls = Nulls.SKIP) - public Builder tenants(List tenants) { - this.tenants.clear(); - this.tenants.addAll(tenants); - return this; - } - - public Builder addTenants(UserTenantAssociation tenants) { - this.tenants.add(tenants); - return this; - } - - public Builder addAllTenants(List tenants) { - this.tenants.addAll(tenants); - return this; - } - - public AddUserToMultipleTenantsParams build() { - return new AddUserToMultipleTenantsParams(tenants, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToSingleTenantsParams.java b/src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToSingleTenantsParams.java deleted file mode 100644 index e2a49ad3..00000000 --- a/src/main/java/com/courier/api/resources/users/tenants/requests/AddUserToSingleTenantsParams.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AddUserToSingleTenantsParams.Builder.class) -public final class AddUserToSingleTenantsParams { - private final Optional> profile; - - private final Map additionalProperties; - - private AddUserToSingleTenantsParams( - Optional> profile, Map additionalProperties) { - this.profile = profile; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("profile") - public Optional> getProfile() { - return profile; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddUserToSingleTenantsParams && equalTo((AddUserToSingleTenantsParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AddUserToSingleTenantsParams other) { - return profile.equals(other.profile); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.profile); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional> profile = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(AddUserToSingleTenantsParams other) { - profile(other.getProfile()); - return this; - } - - @JsonSetter(value = "profile", nulls = Nulls.SKIP) - public Builder profile(Optional> profile) { - this.profile = profile; - return this; - } - - public Builder profile(Map profile) { - this.profile = Optional.of(profile); - return this; - } - - public AddUserToSingleTenantsParams build() { - return new AddUserToSingleTenantsParams(profile, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tenants/requests/ListTenantsForUserParams.java b/src/main/java/com/courier/api/resources/users/tenants/requests/ListTenantsForUserParams.java deleted file mode 100644 index 8df115c7..00000000 --- a/src/main/java/com/courier/api/resources/users/tenants/requests/ListTenantsForUserParams.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tenants.requests; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTenantsForUserParams.Builder.class) -public final class ListTenantsForUserParams { - private final Optional limit; - - private final Optional cursor; - - private final Map additionalProperties; - - private ListTenantsForUserParams( - Optional limit, Optional cursor, Map additionalProperties) { - this.limit = limit; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - /** - * @return The number of accounts to return - * (defaults to 20, maximum value of 100) - */ - @JsonProperty("limit") - public Optional getLimit() { - return limit; - } - - /** - * @return Continue the pagination with the next cursor - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTenantsForUserParams && equalTo((ListTenantsForUserParams) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTenantsForUserParams other) { - return limit.equals(other.limit) && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.limit, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional limit = Optional.empty(); - - private Optional cursor = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(ListTenantsForUserParams other) { - limit(other.getLimit()); - cursor(other.getCursor()); - return this; - } - - @JsonSetter(value = "limit", nulls = Nulls.SKIP) - public Builder limit(Optional limit) { - this.limit = limit; - return this; - } - - public Builder limit(Integer limit) { - this.limit = Optional.of(limit); - return this; - } - - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public Builder cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - public Builder cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - public ListTenantsForUserParams build() { - return new ListTenantsForUserParams(limit, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tenants/types/AddUserToSingleTenantsParamsProfile.java b/src/main/java/com/courier/api/resources/users/tenants/types/AddUserToSingleTenantsParamsProfile.java deleted file mode 100644 index f49c16a3..00000000 --- a/src/main/java/com/courier/api/resources/users/tenants/types/AddUserToSingleTenantsParamsProfile.java +++ /dev/null @@ -1,250 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = AddUserToSingleTenantsParamsProfile.Builder.class) -public final class AddUserToSingleTenantsParamsProfile { - private final String title; - - private final String email; - - private final String phoneNumber; - - private final String locale; - - private final Map additionalFields; - - private final Map additionalProperties; - - private AddUserToSingleTenantsParamsProfile( - String title, - String email, - String phoneNumber, - String locale, - Map additionalFields, - Map additionalProperties) { - this.title = title; - this.email = email; - this.phoneNumber = phoneNumber; - this.locale = locale; - this.additionalFields = additionalFields; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("title") - public String getTitle() { - return title; - } - - /** - * @return Email Address - */ - @JsonProperty("email") - public String getEmail() { - return email; - } - - /** - * @return A valid phone number - */ - @JsonProperty("phone_number") - public String getPhoneNumber() { - return phoneNumber; - } - - /** - * @return The user's preferred ISO 639-1 language code. - */ - @JsonProperty("locale") - public String getLocale() { - return locale; - } - - /** - * @return Additional provider specific fields may be specified. - */ - @JsonProperty("additional_fields") - public Map getAdditionalFields() { - return additionalFields; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof AddUserToSingleTenantsParamsProfile - && equalTo((AddUserToSingleTenantsParamsProfile) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(AddUserToSingleTenantsParamsProfile other) { - return title.equals(other.title) - && email.equals(other.email) - && phoneNumber.equals(other.phoneNumber) - && locale.equals(other.locale) - && additionalFields.equals(other.additionalFields); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.title, this.email, this.phoneNumber, this.locale, this.additionalFields); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static TitleStage builder() { - return new Builder(); - } - - public interface TitleStage { - EmailStage title(String title); - - Builder from(AddUserToSingleTenantsParamsProfile other); - } - - public interface EmailStage { - PhoneNumberStage email(String email); - } - - public interface PhoneNumberStage { - LocaleStage phoneNumber(String phoneNumber); - } - - public interface LocaleStage { - _FinalStage locale(String locale); - } - - public interface _FinalStage { - AddUserToSingleTenantsParamsProfile build(); - - _FinalStage additionalFields(Map additionalFields); - - _FinalStage putAllAdditionalFields(Map additionalFields); - - _FinalStage additionalFields(String key, Object value); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements TitleStage, EmailStage, PhoneNumberStage, LocaleStage, _FinalStage { - private String title; - - private String email; - - private String phoneNumber; - - private String locale; - - private Map additionalFields = new LinkedHashMap<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(AddUserToSingleTenantsParamsProfile other) { - title(other.getTitle()); - email(other.getEmail()); - phoneNumber(other.getPhoneNumber()); - locale(other.getLocale()); - additionalFields(other.getAdditionalFields()); - return this; - } - - @java.lang.Override - @JsonSetter("title") - public EmailStage title(String title) { - this.title = title; - return this; - } - - /** - *

Email Address

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("email") - public PhoneNumberStage email(String email) { - this.email = email; - return this; - } - - /** - *

A valid phone number

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("phone_number") - public LocaleStage phoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - - /** - *

The user's preferred ISO 639-1 language code.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("locale") - public _FinalStage locale(String locale) { - this.locale = locale; - return this; - } - - /** - *

Additional provider specific fields may be specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage additionalFields(String key, Object value) { - this.additionalFields.put(key, value); - return this; - } - - /** - *

Additional provider specific fields may be specified.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage putAllAdditionalFields(Map additionalFields) { - this.additionalFields.putAll(additionalFields); - return this; - } - - @java.lang.Override - @JsonSetter(value = "additional_fields", nulls = Nulls.SKIP) - public _FinalStage additionalFields(Map additionalFields) { - this.additionalFields.clear(); - this.additionalFields.putAll(additionalFields); - return this; - } - - @java.lang.Override - public AddUserToSingleTenantsParamsProfile build() { - return new AddUserToSingleTenantsParamsProfile( - title, email, phoneNumber, locale, additionalFields, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tenants/types/ListTenantsForUserResponse.java b/src/main/java/com/courier/api/resources/users/tenants/types/ListTenantsForUserResponse.java deleted file mode 100644 index 570e1bd4..00000000 --- a/src/main/java/com/courier/api/resources/users/tenants/types/ListTenantsForUserResponse.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tenants.types; - -import com.courier.api.core.ObjectMappers; -import com.courier.api.resources.commons.types.UserTenantAssociation; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = ListTenantsForUserResponse.Builder.class) -public final class ListTenantsForUserResponse { - private final Optional> items; - - private final boolean hasMore; - - private final String url; - - private final Optional nextUrl; - - private final Optional cursor; - - private final Map additionalProperties; - - private ListTenantsForUserResponse( - Optional> items, - boolean hasMore, - String url, - Optional nextUrl, - Optional cursor, - Map additionalProperties) { - this.items = items; - this.hasMore = hasMore; - this.url = url; - this.nextUrl = nextUrl; - this.cursor = cursor; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("items") - public Optional> getItems() { - return items; - } - - /** - * @return Set to true when there are more pages that can be retrieved. - */ - @JsonProperty("has_more") - public boolean getHasMore() { - return hasMore; - } - - /** - * @return A url that may be used to generate these results. - */ - @JsonProperty("url") - public String getUrl() { - return url; - } - - /** - * @return A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true - */ - @JsonProperty("next_url") - public Optional getNextUrl() { - return nextUrl; - } - - /** - * @return A pointer to the next page of results. Defined - * only when has_more is set to true - */ - @JsonProperty("cursor") - public Optional getCursor() { - return cursor; - } - - /** - * @return Always set to list. Represents the type of this object. - */ - @JsonProperty("type") - public String getType() { - return "list"; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ListTenantsForUserResponse && equalTo((ListTenantsForUserResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(ListTenantsForUserResponse other) { - return items.equals(other.items) - && hasMore == other.hasMore - && url.equals(other.url) - && nextUrl.equals(other.nextUrl) - && cursor.equals(other.cursor); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.items, this.hasMore, this.url, this.nextUrl, this.cursor); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static HasMoreStage builder() { - return new Builder(); - } - - public interface HasMoreStage { - UrlStage hasMore(boolean hasMore); - - Builder from(ListTenantsForUserResponse other); - } - - public interface UrlStage { - _FinalStage url(String url); - } - - public interface _FinalStage { - ListTenantsForUserResponse build(); - - _FinalStage items(Optional> items); - - _FinalStage items(List items); - - _FinalStage nextUrl(Optional nextUrl); - - _FinalStage nextUrl(String nextUrl); - - _FinalStage cursor(Optional cursor); - - _FinalStage cursor(String cursor); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements HasMoreStage, UrlStage, _FinalStage { - private boolean hasMore; - - private String url; - - private Optional cursor = Optional.empty(); - - private Optional nextUrl = Optional.empty(); - - private Optional> items = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(ListTenantsForUserResponse other) { - items(other.getItems()); - hasMore(other.getHasMore()); - url(other.getUrl()); - nextUrl(other.getNextUrl()); - cursor(other.getCursor()); - return this; - } - - /** - *

Set to true when there are more pages that can be retrieved.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("has_more") - public UrlStage hasMore(boolean hasMore) { - this.hasMore = hasMore; - return this; - } - - /** - *

A url that may be used to generate these results.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("url") - public _FinalStage url(String url) { - this.url = url; - return this; - } - - /** - *

A pointer to the next page of results. Defined - * only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage cursor(String cursor) { - this.cursor = Optional.of(cursor); - return this; - } - - @java.lang.Override - @JsonSetter(value = "cursor", nulls = Nulls.SKIP) - public _FinalStage cursor(Optional cursor) { - this.cursor = cursor; - return this; - } - - /** - *

A url that may be used to generate fetch the next set of results. - * Defined only when has_more is set to true

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage nextUrl(String nextUrl) { - this.nextUrl = Optional.of(nextUrl); - return this; - } - - @java.lang.Override - @JsonSetter(value = "next_url", nulls = Nulls.SKIP) - public _FinalStage nextUrl(Optional nextUrl) { - this.nextUrl = nextUrl; - return this; - } - - @java.lang.Override - public _FinalStage items(List items) { - this.items = Optional.of(items); - return this; - } - - @java.lang.Override - @JsonSetter(value = "items", nulls = Nulls.SKIP) - public _FinalStage items(Optional> items) { - this.items = items; - return this; - } - - @java.lang.Override - public ListTenantsForUserResponse build() { - return new ListTenantsForUserResponse(items, hasMore, url, nextUrl, cursor, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/TokensClient.java b/src/main/java/com/courier/api/resources/users/tokens/TokensClient.java deleted file mode 100644 index aa08b524..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/TokensClient.java +++ /dev/null @@ -1,338 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens; - -import com.courier.api.core.ClientOptions; -import com.courier.api.core.CourierApiApiError; -import com.courier.api.core.CourierApiError; -import com.courier.api.core.MediaTypes; -import com.courier.api.core.ObjectMappers; -import com.courier.api.core.RequestOptions; -import com.courier.api.resources.commons.errors.CourierApiBadRequestError; -import com.courier.api.resources.commons.types.BadRequest; -import com.courier.api.resources.users.tokens.types.GetUserTokenResponse; -import com.courier.api.resources.users.tokens.types.PatchUserTokenOpts; -import com.courier.api.resources.users.tokens.types.UserToken; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import java.io.IOException; -import java.util.List; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; -import okhttp3.ResponseBody; - -public class TokensClient { - protected final ClientOptions clientOptions; - - public TokensClient(ClientOptions clientOptions) { - this.clientOptions = clientOptions; - } - - /** - * Adds multiple tokens to a user and overwrites matching existing tokens. - */ - public void addMultiple(String userId) { - addMultiple(userId, null); - } - - /** - * Adds multiple tokens to a user and overwrites matching existing tokens. - */ - public void addMultiple(String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tokens") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Adds a single token to a user and overwrites a matching existing token. - */ - public void add(String userId, String token, UserToken request) { - add(userId, token, request, null); - } - - /** - * Adds a single token to a user and overwrites a matching existing token. - */ - public void add(String userId, String token, UserToken request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tokens") - .addPathSegment(token) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PUT", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Apply a JSON Patch (RFC 6902) to the specified token. - */ - public void update(String userId, String token, PatchUserTokenOpts request) { - update(userId, token, request, null); - } - - /** - * Apply a JSON Patch (RFC 6902) to the specified token. - */ - public void update(String userId, String token, PatchUserTokenOpts request, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tokens") - .addPathSegment(token) - .build(); - RequestBody body; - try { - body = RequestBody.create( - ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON); - } catch (JsonProcessingException e) { - throw new CourierApiError("Failed to serialize request", e); - } - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("PATCH", body) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Get single token available for a :token - */ - public GetUserTokenResponse get(String userId, String token) { - return get(userId, token, null); - } - - /** - * Get single token available for a :token - */ - public GetUserTokenResponse get(String userId, String token, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tokens") - .addPathSegment(token) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), GetUserTokenResponse.class); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - /** - * Gets all tokens available for a :user_id - */ - public List list(String userId) { - return list(userId, null); - } - - /** - * Gets all tokens available for a :user_id - */ - public List list(String userId, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tokens") - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("GET", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .addHeader("Content-Type", "application/json") - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return ObjectMappers.JSON_MAPPER.readValue( - responseBody.string(), new TypeReference>() {}); - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - try { - if (response.code() == 400) { - throw new CourierApiBadRequestError( - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, BadRequest.class)); - } - } catch (JsonProcessingException ignored) { - // unable to map error response, throwing generic error - } - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } - - public void delete(String userId, String token) { - delete(userId, token, null); - } - - public void delete(String userId, String token, RequestOptions requestOptions) { - HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) - .newBuilder() - .addPathSegments("users") - .addPathSegment(userId) - .addPathSegments("tokens") - .addPathSegment(token) - .build(); - Request okhttpRequest = new Request.Builder() - .url(httpUrl) - .method("DELETE", null) - .headers(Headers.of(clientOptions.headers(requestOptions))) - .build(); - OkHttpClient client = clientOptions.httpClient(); - if (requestOptions != null && requestOptions.getTimeout().isPresent()) { - client = clientOptions.httpClientWithTimeout(requestOptions); - } - try (Response response = client.newCall(okhttpRequest).execute()) { - ResponseBody responseBody = response.body(); - if (response.isSuccessful()) { - return; - } - String responseBodyString = responseBody != null ? responseBody.string() : "{}"; - throw new CourierApiApiError( - "Error with status code " + response.code(), - response.code(), - ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class)); - } catch (IOException e) { - throw new CourierApiError("Network error executing HTTP request", e); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/DeleteUserTokenOpts.java b/src/main/java/com/courier/api/resources/users/tokens/types/DeleteUserTokenOpts.java deleted file mode 100644 index 7515b1ee..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/DeleteUserTokenOpts.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = DeleteUserTokenOpts.Builder.class) -public final class DeleteUserTokenOpts { - private final String userId; - - private final String token; - - private final Map additionalProperties; - - private DeleteUserTokenOpts(String userId, String token, Map additionalProperties) { - this.userId = userId; - this.token = token; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @JsonProperty("token") - public String getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof DeleteUserTokenOpts && equalTo((DeleteUserTokenOpts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(DeleteUserTokenOpts other) { - return userId.equals(other.userId) && token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.token); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - TokenStage userId(String userId); - - Builder from(DeleteUserTokenOpts other); - } - - public interface TokenStage { - _FinalStage token(String token); - } - - public interface _FinalStage { - DeleteUserTokenOpts build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, TokenStage, _FinalStage { - private String userId; - - private String token; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(DeleteUserTokenOpts other) { - userId(other.getUserId()); - token(other.getToken()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public TokenStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - @JsonSetter("token") - public _FinalStage token(String token) { - this.token = token; - return this; - } - - @java.lang.Override - public DeleteUserTokenOpts build() { - return new DeleteUserTokenOpts(userId, token, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/Device.java b/src/main/java/com/courier/api/resources/users/tokens/types/Device.java deleted file mode 100644 index 9779ece2..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/Device.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Device.Builder.class) -public final class Device { - private final Optional appId; - - private final Optional adId; - - private final Optional deviceId; - - private final Optional platform; - - private final Optional manufacturer; - - private final Optional model; - - private final Map additionalProperties; - - private Device( - Optional appId, - Optional adId, - Optional deviceId, - Optional platform, - Optional manufacturer, - Optional model, - Map additionalProperties) { - this.appId = appId; - this.adId = adId; - this.deviceId = deviceId; - this.platform = platform; - this.manufacturer = manufacturer; - this.model = model; - this.additionalProperties = additionalProperties; - } - - /** - * @return Id of the application the token is used for - */ - @JsonProperty("app_id") - public Optional getAppId() { - return appId; - } - - /** - * @return Id of the advertising identifier - */ - @JsonProperty("ad_id") - public Optional getAdId() { - return adId; - } - - /** - * @return Id of the device the token is associated with - */ - @JsonProperty("device_id") - public Optional getDeviceId() { - return deviceId; - } - - /** - * @return The device platform i.e. android, ios, web - */ - @JsonProperty("platform") - public Optional getPlatform() { - return platform; - } - - /** - * @return The device manufacturer - */ - @JsonProperty("manufacturer") - public Optional getManufacturer() { - return manufacturer; - } - - /** - * @return The device model - */ - @JsonProperty("model") - public Optional getModel() { - return model; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Device && equalTo((Device) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Device other) { - return appId.equals(other.appId) - && adId.equals(other.adId) - && deviceId.equals(other.deviceId) - && platform.equals(other.platform) - && manufacturer.equals(other.manufacturer) - && model.equals(other.model); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.appId, this.adId, this.deviceId, this.platform, this.manufacturer, this.model); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional appId = Optional.empty(); - - private Optional adId = Optional.empty(); - - private Optional deviceId = Optional.empty(); - - private Optional platform = Optional.empty(); - - private Optional manufacturer = Optional.empty(); - - private Optional model = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Device other) { - appId(other.getAppId()); - adId(other.getAdId()); - deviceId(other.getDeviceId()); - platform(other.getPlatform()); - manufacturer(other.getManufacturer()); - model(other.getModel()); - return this; - } - - @JsonSetter(value = "app_id", nulls = Nulls.SKIP) - public Builder appId(Optional appId) { - this.appId = appId; - return this; - } - - public Builder appId(String appId) { - this.appId = Optional.of(appId); - return this; - } - - @JsonSetter(value = "ad_id", nulls = Nulls.SKIP) - public Builder adId(Optional adId) { - this.adId = adId; - return this; - } - - public Builder adId(String adId) { - this.adId = Optional.of(adId); - return this; - } - - @JsonSetter(value = "device_id", nulls = Nulls.SKIP) - public Builder deviceId(Optional deviceId) { - this.deviceId = deviceId; - return this; - } - - public Builder deviceId(String deviceId) { - this.deviceId = Optional.of(deviceId); - return this; - } - - @JsonSetter(value = "platform", nulls = Nulls.SKIP) - public Builder platform(Optional platform) { - this.platform = platform; - return this; - } - - public Builder platform(String platform) { - this.platform = Optional.of(platform); - return this; - } - - @JsonSetter(value = "manufacturer", nulls = Nulls.SKIP) - public Builder manufacturer(Optional manufacturer) { - this.manufacturer = manufacturer; - return this; - } - - public Builder manufacturer(String manufacturer) { - this.manufacturer = Optional.of(manufacturer); - return this; - } - - @JsonSetter(value = "model", nulls = Nulls.SKIP) - public Builder model(Optional model) { - this.model = model; - return this; - } - - public Builder model(String model) { - this.model = Optional.of(model); - return this; - } - - public Device build() { - return new Device(appId, adId, deviceId, platform, manufacturer, model, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/ExpiryDate.java b/src/main/java/com/courier/api/resources/users/tokens/types/ExpiryDate.java deleted file mode 100644 index e90e6db4..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/ExpiryDate.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonValue; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import java.io.IOException; -import java.util.Objects; - -@JsonDeserialize(using = ExpiryDate.Deserializer.class) -public final class ExpiryDate { - private final Object value; - - private final int type; - - private ExpiryDate(Object value, int type) { - this.value = value; - this.type = type; - } - - @JsonValue - public Object get() { - return this.value; - } - - public T visit(Visitor visitor) { - if (this.type == 0) { - return visitor.visit((String) this.value); - } else if (this.type == 1) { - return visitor.visit((boolean) this.value); - } - throw new IllegalStateException("Failed to visit value. This should never happen."); - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof ExpiryDate && equalTo((ExpiryDate) other); - } - - private boolean equalTo(ExpiryDate other) { - return value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.value); - } - - @java.lang.Override - public String toString() { - return this.value.toString(); - } - - public static ExpiryDate of(String value) { - return new ExpiryDate(value, 0); - } - - public static ExpiryDate of(boolean value) { - return new ExpiryDate(value, 1); - } - - public interface Visitor { - T visit(String value); - - T visit(boolean value); - } - - static final class Deserializer extends StdDeserializer { - Deserializer() { - super(ExpiryDate.class); - } - - @java.lang.Override - public ExpiryDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { - Object value = p.readValueAs(Object.class); - try { - return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class)); - } catch (IllegalArgumentException e) { - } - if (value instanceof Boolean) { - return of((Boolean) value); - } - throw new JsonParseException(p, "Failed to deserialize"); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenOpts.java b/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenOpts.java deleted file mode 100644 index 77eb07c1..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenOpts.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetUserTokenOpts.Builder.class) -public final class GetUserTokenOpts { - private final String userId; - - private final String token; - - private final Map additionalProperties; - - private GetUserTokenOpts(String userId, String token, Map additionalProperties) { - this.userId = userId; - this.token = token; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @JsonProperty("token") - public String getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetUserTokenOpts && equalTo((GetUserTokenOpts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetUserTokenOpts other) { - return userId.equals(other.userId) && token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.token); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - TokenStage userId(String userId); - - Builder from(GetUserTokenOpts other); - } - - public interface TokenStage { - _FinalStage token(String token); - } - - public interface _FinalStage { - GetUserTokenOpts build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, TokenStage, _FinalStage { - private String userId; - - private String token; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetUserTokenOpts other) { - userId(other.getUserId()); - token(other.getToken()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public TokenStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - @JsonSetter("token") - public _FinalStage token(String token) { - this.token = token; - return this; - } - - @java.lang.Override - public GetUserTokenOpts build() { - return new GetUserTokenOpts(userId, token, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenResponse.java b/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenResponse.java deleted file mode 100644 index 6c8bd294..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokenResponse.java +++ /dev/null @@ -1,380 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetUserTokenResponse.Builder.class) -public final class GetUserTokenResponse implements IUserToken { - private final Optional token; - - private final ProviderKey providerKey; - - private final Optional expiryDate; - - private final Optional properties; - - private final Optional device; - - private final Optional tracking; - - private final Optional status; - - private final Optional statusReason; - - private final Map additionalProperties; - - private GetUserTokenResponse( - Optional token, - ProviderKey providerKey, - Optional expiryDate, - Optional properties, - Optional device, - Optional tracking, - Optional status, - Optional statusReason, - Map additionalProperties) { - this.token = token; - this.providerKey = providerKey; - this.expiryDate = expiryDate; - this.properties = properties; - this.device = device; - this.tracking = tracking; - this.status = status; - this.statusReason = statusReason; - this.additionalProperties = additionalProperties; - } - - /** - * @return Full body of the token. Must match token in URL. - */ - @JsonProperty("token") - @java.lang.Override - public Optional getToken() { - return token; - } - - @JsonProperty("provider_key") - @java.lang.Override - public ProviderKey getProviderKey() { - return providerKey; - } - - /** - * @return ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable expiration. - */ - @JsonProperty("expiry_date") - @java.lang.Override - public Optional getExpiryDate() { - return expiryDate; - } - - /** - * @return Properties sent to the provider along with the token - */ - @JsonProperty("properties") - @java.lang.Override - public Optional getProperties() { - return properties; - } - - /** - * @return Information about the device the token is associated with. - */ - @JsonProperty("device") - @java.lang.Override - public Optional getDevice() { - return device; - } - - /** - * @return Information about the device the token is associated with. - */ - @JsonProperty("tracking") - @java.lang.Override - public Optional getTracking() { - return tracking; - } - - @JsonProperty("status") - public Optional getStatus() { - return status; - } - - /** - * @return The reason for the token status. - */ - @JsonProperty("status_reason") - public Optional getStatusReason() { - return statusReason; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetUserTokenResponse && equalTo((GetUserTokenResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetUserTokenResponse other) { - return token.equals(other.token) - && providerKey.equals(other.providerKey) - && expiryDate.equals(other.expiryDate) - && properties.equals(other.properties) - && device.equals(other.device) - && tracking.equals(other.tracking) - && status.equals(other.status) - && statusReason.equals(other.statusReason); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash( - this.token, - this.providerKey, - this.expiryDate, - this.properties, - this.device, - this.tracking, - this.status, - this.statusReason); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ProviderKeyStage builder() { - return new Builder(); - } - - public interface ProviderKeyStage { - _FinalStage providerKey(ProviderKey providerKey); - - Builder from(GetUserTokenResponse other); - } - - public interface _FinalStage { - GetUserTokenResponse build(); - - _FinalStage token(Optional token); - - _FinalStage token(String token); - - _FinalStage expiryDate(Optional expiryDate); - - _FinalStage expiryDate(ExpiryDate expiryDate); - - _FinalStage properties(Optional properties); - - _FinalStage properties(Object properties); - - _FinalStage device(Optional device); - - _FinalStage device(Device device); - - _FinalStage tracking(Optional tracking); - - _FinalStage tracking(Tracking tracking); - - _FinalStage status(Optional status); - - _FinalStage status(TokenStatus status); - - _FinalStage statusReason(Optional statusReason); - - _FinalStage statusReason(String statusReason); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ProviderKeyStage, _FinalStage { - private ProviderKey providerKey; - - private Optional statusReason = Optional.empty(); - - private Optional status = Optional.empty(); - - private Optional tracking = Optional.empty(); - - private Optional device = Optional.empty(); - - private Optional properties = Optional.empty(); - - private Optional expiryDate = Optional.empty(); - - private Optional token = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetUserTokenResponse other) { - token(other.getToken()); - providerKey(other.getProviderKey()); - expiryDate(other.getExpiryDate()); - properties(other.getProperties()); - device(other.getDevice()); - tracking(other.getTracking()); - status(other.getStatus()); - statusReason(other.getStatusReason()); - return this; - } - - @java.lang.Override - @JsonSetter("provider_key") - public _FinalStage providerKey(ProviderKey providerKey) { - this.providerKey = providerKey; - return this; - } - - /** - *

The reason for the token status.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage statusReason(String statusReason) { - this.statusReason = Optional.of(statusReason); - return this; - } - - @java.lang.Override - @JsonSetter(value = "status_reason", nulls = Nulls.SKIP) - public _FinalStage statusReason(Optional statusReason) { - this.statusReason = statusReason; - return this; - } - - @java.lang.Override - public _FinalStage status(TokenStatus status) { - this.status = Optional.of(status); - return this; - } - - @java.lang.Override - @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { - this.status = status; - return this; - } - - /** - *

Information about the device the token is associated with.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tracking(Tracking tracking) { - this.tracking = Optional.of(tracking); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tracking", nulls = Nulls.SKIP) - public _FinalStage tracking(Optional tracking) { - this.tracking = tracking; - return this; - } - - /** - *

Information about the device the token is associated with.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage device(Device device) { - this.device = Optional.of(device); - return this; - } - - @java.lang.Override - @JsonSetter(value = "device", nulls = Nulls.SKIP) - public _FinalStage device(Optional device) { - this.device = device; - return this; - } - - /** - *

Properties sent to the provider along with the token

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage properties(Object properties) { - this.properties = Optional.of(properties); - return this; - } - - @java.lang.Override - @JsonSetter(value = "properties", nulls = Nulls.SKIP) - public _FinalStage properties(Optional properties) { - this.properties = properties; - return this; - } - - /** - *

ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable expiration.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiryDate(ExpiryDate expiryDate) { - this.expiryDate = Optional.of(expiryDate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expiry_date", nulls = Nulls.SKIP) - public _FinalStage expiryDate(Optional expiryDate) { - this.expiryDate = expiryDate; - return this; - } - - /** - *

Full body of the token. Must match token in URL.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage token(String token) { - this.token = Optional.of(token); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token", nulls = Nulls.SKIP) - public _FinalStage token(Optional token) { - this.token = token; - return this; - } - - @java.lang.Override - public GetUserTokenResponse build() { - return new GetUserTokenResponse( - token, - providerKey, - expiryDate, - properties, - device, - tracking, - status, - statusReason, - additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokensOpts.java b/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokensOpts.java deleted file mode 100644 index 3d73c732..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/GetUserTokensOpts.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = GetUserTokensOpts.Builder.class) -public final class GetUserTokensOpts { - private final String userId; - - private final Map additionalProperties; - - private GetUserTokensOpts(String userId, Map additionalProperties) { - this.userId = userId; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof GetUserTokensOpts && equalTo((GetUserTokensOpts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(GetUserTokensOpts other) { - return userId.equals(other.userId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(GetUserTokensOpts other); - } - - public interface _FinalStage { - GetUserTokensOpts build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(GetUserTokensOpts other) { - userId(other.getUserId()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public GetUserTokensOpts build() { - return new GetUserTokensOpts(userId, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/IUserToken.java b/src/main/java/com/courier/api/resources/users/tokens/types/IUserToken.java deleted file mode 100644 index f2a5e29d..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/IUserToken.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import java.util.Optional; - -public interface IUserToken { - Optional getToken(); - - ProviderKey getProviderKey(); - - Optional getExpiryDate(); - - Optional getProperties(); - - Optional getDevice(); - - Optional getTracking(); -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/PatchOp.java b/src/main/java/com/courier/api/resources/users/tokens/types/PatchOp.java deleted file mode 100644 index eabdc61f..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/PatchOp.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum PatchOp { - REPLACE("replace"), - - ADD("add"), - - REMOVE("remove"), - - COPY("copy"), - - MOVE("move"), - - TEST("test"); - - private final String value; - - PatchOp(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/PatchOperation.java b/src/main/java/com/courier/api/resources/users/tokens/types/PatchOperation.java deleted file mode 100644 index e0906873..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/PatchOperation.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PatchOperation.Builder.class) -public final class PatchOperation { - private final String op; - - private final String path; - - private final Optional value; - - private final Map additionalProperties; - - private PatchOperation(String op, String path, Optional value, Map additionalProperties) { - this.op = op; - this.path = path; - this.value = value; - this.additionalProperties = additionalProperties; - } - - /** - * @return The operation to perform. - */ - @JsonProperty("op") - public String getOp() { - return op; - } - - /** - * @return The JSON path specifying the part of the profile to operate on. - */ - @JsonProperty("path") - public String getPath() { - return path; - } - - /** - * @return The value for the operation. - */ - @JsonProperty("value") - public Optional getValue() { - return value; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchOperation && equalTo((PatchOperation) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PatchOperation other) { - return op.equals(other.op) && path.equals(other.path) && value.equals(other.value); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.op, this.path, this.value); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static OpStage builder() { - return new Builder(); - } - - public interface OpStage { - PathStage op(String op); - - Builder from(PatchOperation other); - } - - public interface PathStage { - _FinalStage path(String path); - } - - public interface _FinalStage { - PatchOperation build(); - - _FinalStage value(Optional value); - - _FinalStage value(String value); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements OpStage, PathStage, _FinalStage { - private String op; - - private String path; - - private Optional value = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PatchOperation other) { - op(other.getOp()); - path(other.getPath()); - value(other.getValue()); - return this; - } - - /** - *

The operation to perform.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("op") - public PathStage op(String op) { - this.op = op; - return this; - } - - /** - *

The JSON path specifying the part of the profile to operate on.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("path") - public _FinalStage path(String path) { - this.path = path; - return this; - } - - /** - *

The value for the operation.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage value(String value) { - this.value = Optional.of(value); - return this; - } - - @java.lang.Override - @JsonSetter(value = "value", nulls = Nulls.SKIP) - public _FinalStage value(Optional value) { - this.value = value; - return this; - } - - @java.lang.Override - public PatchOperation build() { - return new PatchOperation(op, path, value, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/PatchUserTokenOpts.java b/src/main/java/com/courier/api/resources/users/tokens/types/PatchUserTokenOpts.java deleted file mode 100644 index 4f843446..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/PatchUserTokenOpts.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PatchUserTokenOpts.Builder.class) -public final class PatchUserTokenOpts { - private final List patch; - - private final Map additionalProperties; - - private PatchUserTokenOpts(List patch, Map additionalProperties) { - this.patch = patch; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("patch") - public List getPatch() { - return patch; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PatchUserTokenOpts && equalTo((PatchUserTokenOpts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PatchUserTokenOpts other) { - return patch.equals(other.patch); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.patch); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private List patch = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(PatchUserTokenOpts other) { - patch(other.getPatch()); - return this; - } - - @JsonSetter(value = "patch", nulls = Nulls.SKIP) - public Builder patch(List patch) { - this.patch.clear(); - this.patch.addAll(patch); - return this; - } - - public Builder addPatch(PatchOperation patch) { - this.patch.add(patch); - return this; - } - - public Builder addAllPatch(List patch) { - this.patch.addAll(patch); - return this; - } - - public PatchUserTokenOpts build() { - return new PatchUserTokenOpts(patch, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/ProviderKey.java b/src/main/java/com/courier/api/resources/users/tokens/types/ProviderKey.java deleted file mode 100644 index 2f15f84a..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/ProviderKey.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum ProviderKey { - FIREBASE_FCM("firebase-fcm"), - - APN("apn"), - - EXPO("expo"), - - ONESIGNAL("onesignal"); - - private final String value; - - ProviderKey(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokenOpts.java b/src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokenOpts.java deleted file mode 100644 index caba45fc..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokenOpts.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PutUserTokenOpts.Builder.class) -public final class PutUserTokenOpts { - private final String userId; - - private final UserToken token; - - private final Map additionalProperties; - - private PutUserTokenOpts(String userId, UserToken token, Map additionalProperties) { - this.userId = userId; - this.token = token; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @JsonProperty("token") - public UserToken getToken() { - return token; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PutUserTokenOpts && equalTo((PutUserTokenOpts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PutUserTokenOpts other) { - return userId.equals(other.userId) && token.equals(other.token); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.token); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - TokenStage userId(String userId); - - Builder from(PutUserTokenOpts other); - } - - public interface TokenStage { - _FinalStage token(UserToken token); - } - - public interface _FinalStage { - PutUserTokenOpts build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, TokenStage, _FinalStage { - private String userId; - - private UserToken token; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PutUserTokenOpts other) { - userId(other.getUserId()); - token(other.getToken()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public TokenStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - @JsonSetter("token") - public _FinalStage token(UserToken token) { - this.token = token; - return this; - } - - @java.lang.Override - public PutUserTokenOpts build() { - return new PutUserTokenOpts(userId, token, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokensOpts.java b/src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokensOpts.java deleted file mode 100644 index 01b56f6e..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/PutUserTokensOpts.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = PutUserTokensOpts.Builder.class) -public final class PutUserTokensOpts { - private final String userId; - - private final List tokens; - - private final Map additionalProperties; - - private PutUserTokensOpts(String userId, List tokens, Map additionalProperties) { - this.userId = userId; - this.tokens = tokens; - this.additionalProperties = additionalProperties; - } - - @JsonProperty("user_id") - public String getUserId() { - return userId; - } - - @JsonProperty("tokens") - public List getTokens() { - return tokens; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof PutUserTokensOpts && equalTo((PutUserTokensOpts) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(PutUserTokensOpts other) { - return userId.equals(other.userId) && tokens.equals(other.tokens); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.userId, this.tokens); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static UserIdStage builder() { - return new Builder(); - } - - public interface UserIdStage { - _FinalStage userId(String userId); - - Builder from(PutUserTokensOpts other); - } - - public interface _FinalStage { - PutUserTokensOpts build(); - - _FinalStage tokens(List tokens); - - _FinalStage addTokens(UserToken tokens); - - _FinalStage addAllTokens(List tokens); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements UserIdStage, _FinalStage { - private String userId; - - private List tokens = new ArrayList<>(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(PutUserTokensOpts other) { - userId(other.getUserId()); - tokens(other.getTokens()); - return this; - } - - @java.lang.Override - @JsonSetter("user_id") - public _FinalStage userId(String userId) { - this.userId = userId; - return this; - } - - @java.lang.Override - public _FinalStage addAllTokens(List tokens) { - this.tokens.addAll(tokens); - return this; - } - - @java.lang.Override - public _FinalStage addTokens(UserToken tokens) { - this.tokens.add(tokens); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tokens", nulls = Nulls.SKIP) - public _FinalStage tokens(List tokens) { - this.tokens.clear(); - this.tokens.addAll(tokens); - return this; - } - - @java.lang.Override - public PutUserTokensOpts build() { - return new PutUserTokensOpts(userId, tokens, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/TokenStatus.java b/src/main/java/com/courier/api/resources/users/tokens/types/TokenStatus.java deleted file mode 100644 index b4945d99..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/TokenStatus.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.fasterxml.jackson.annotation.JsonValue; - -public enum TokenStatus { - ACTIVE("active"), - - UNKNOWN("unknown"), - - FAILED("failed"), - - REVOKED("revoked"); - - private final String value; - - TokenStatus(String value) { - this.value = value; - } - - @JsonValue - @java.lang.Override - public String toString() { - return this.value; - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/Tracking.java b/src/main/java/com/courier/api/resources/users/tokens/types/Tracking.java deleted file mode 100644 index f96da834..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/Tracking.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = Tracking.Builder.class) -public final class Tracking { - private final Optional osVersion; - - private final Optional ip; - - private final Optional lat; - - private final Optional long_; - - private final Map additionalProperties; - - private Tracking( - Optional osVersion, - Optional ip, - Optional lat, - Optional long_, - Map additionalProperties) { - this.osVersion = osVersion; - this.ip = ip; - this.lat = lat; - this.long_ = long_; - this.additionalProperties = additionalProperties; - } - - /** - * @return The operating system version - */ - @JsonProperty("os_version") - public Optional getOsVersion() { - return osVersion; - } - - /** - * @return The IP address of the device - */ - @JsonProperty("ip") - public Optional getIp() { - return ip; - } - - /** - * @return The latitude of the device - */ - @JsonProperty("lat") - public Optional getLat() { - return lat; - } - - /** - * @return The longitude of the device - */ - @JsonProperty("long") - public Optional getLong() { - return long_; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof Tracking && equalTo((Tracking) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(Tracking other) { - return osVersion.equals(other.osVersion) - && ip.equals(other.ip) - && lat.equals(other.lat) - && long_.equals(other.long_); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.osVersion, this.ip, this.lat, this.long_); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static Builder builder() { - return new Builder(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder { - private Optional osVersion = Optional.empty(); - - private Optional ip = Optional.empty(); - - private Optional lat = Optional.empty(); - - private Optional long_ = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - public Builder from(Tracking other) { - osVersion(other.getOsVersion()); - ip(other.getIp()); - lat(other.getLat()); - long_(other.getLong()); - return this; - } - - @JsonSetter(value = "os_version", nulls = Nulls.SKIP) - public Builder osVersion(Optional osVersion) { - this.osVersion = osVersion; - return this; - } - - public Builder osVersion(String osVersion) { - this.osVersion = Optional.of(osVersion); - return this; - } - - @JsonSetter(value = "ip", nulls = Nulls.SKIP) - public Builder ip(Optional ip) { - this.ip = ip; - return this; - } - - public Builder ip(String ip) { - this.ip = Optional.of(ip); - return this; - } - - @JsonSetter(value = "lat", nulls = Nulls.SKIP) - public Builder lat(Optional lat) { - this.lat = lat; - return this; - } - - public Builder lat(String lat) { - this.lat = Optional.of(lat); - return this; - } - - @JsonSetter(value = "long", nulls = Nulls.SKIP) - public Builder long_(Optional long_) { - this.long_ = long_; - return this; - } - - public Builder long_(String long_) { - this.long_ = Optional.of(long_); - return this; - } - - public Tracking build() { - return new Tracking(osVersion, ip, lat, long_, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/resources/users/tokens/types/UserToken.java b/src/main/java/com/courier/api/resources/users/tokens/types/UserToken.java deleted file mode 100644 index 4331e01a..00000000 --- a/src/main/java/com/courier/api/resources/users/tokens/types/UserToken.java +++ /dev/null @@ -1,296 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.resources.users.tokens.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.annotation.Nulls; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = UserToken.Builder.class) -public final class UserToken implements IUserToken { - private final Optional token; - - private final ProviderKey providerKey; - - private final Optional expiryDate; - - private final Optional properties; - - private final Optional device; - - private final Optional tracking; - - private final Map additionalProperties; - - private UserToken( - Optional token, - ProviderKey providerKey, - Optional expiryDate, - Optional properties, - Optional device, - Optional tracking, - Map additionalProperties) { - this.token = token; - this.providerKey = providerKey; - this.expiryDate = expiryDate; - this.properties = properties; - this.device = device; - this.tracking = tracking; - this.additionalProperties = additionalProperties; - } - - /** - * @return Full body of the token. Must match token in URL. - */ - @JsonProperty("token") - @java.lang.Override - public Optional getToken() { - return token; - } - - @JsonProperty("provider_key") - @java.lang.Override - public ProviderKey getProviderKey() { - return providerKey; - } - - /** - * @return ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable expiration. - */ - @JsonProperty("expiry_date") - @java.lang.Override - public Optional getExpiryDate() { - return expiryDate; - } - - /** - * @return Properties sent to the provider along with the token - */ - @JsonProperty("properties") - @java.lang.Override - public Optional getProperties() { - return properties; - } - - /** - * @return Information about the device the token is associated with. - */ - @JsonProperty("device") - @java.lang.Override - public Optional getDevice() { - return device; - } - - /** - * @return Information about the device the token is associated with. - */ - @JsonProperty("tracking") - @java.lang.Override - public Optional getTracking() { - return tracking; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof UserToken && equalTo((UserToken) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(UserToken other) { - return token.equals(other.token) - && providerKey.equals(other.providerKey) - && expiryDate.equals(other.expiryDate) - && properties.equals(other.properties) - && device.equals(other.device) - && tracking.equals(other.tracking); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.token, this.providerKey, this.expiryDate, this.properties, this.device, this.tracking); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static ProviderKeyStage builder() { - return new Builder(); - } - - public interface ProviderKeyStage { - _FinalStage providerKey(ProviderKey providerKey); - - Builder from(UserToken other); - } - - public interface _FinalStage { - UserToken build(); - - _FinalStage token(Optional token); - - _FinalStage token(String token); - - _FinalStage expiryDate(Optional expiryDate); - - _FinalStage expiryDate(ExpiryDate expiryDate); - - _FinalStage properties(Optional properties); - - _FinalStage properties(Object properties); - - _FinalStage device(Optional device); - - _FinalStage device(Device device); - - _FinalStage tracking(Optional tracking); - - _FinalStage tracking(Tracking tracking); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements ProviderKeyStage, _FinalStage { - private ProviderKey providerKey; - - private Optional tracking = Optional.empty(); - - private Optional device = Optional.empty(); - - private Optional properties = Optional.empty(); - - private Optional expiryDate = Optional.empty(); - - private Optional token = Optional.empty(); - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(UserToken other) { - token(other.getToken()); - providerKey(other.getProviderKey()); - expiryDate(other.getExpiryDate()); - properties(other.getProperties()); - device(other.getDevice()); - tracking(other.getTracking()); - return this; - } - - @java.lang.Override - @JsonSetter("provider_key") - public _FinalStage providerKey(ProviderKey providerKey) { - this.providerKey = providerKey; - return this; - } - - /** - *

Information about the device the token is associated with.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage tracking(Tracking tracking) { - this.tracking = Optional.of(tracking); - return this; - } - - @java.lang.Override - @JsonSetter(value = "tracking", nulls = Nulls.SKIP) - public _FinalStage tracking(Optional tracking) { - this.tracking = tracking; - return this; - } - - /** - *

Information about the device the token is associated with.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage device(Device device) { - this.device = Optional.of(device); - return this; - } - - @java.lang.Override - @JsonSetter(value = "device", nulls = Nulls.SKIP) - public _FinalStage device(Optional device) { - this.device = device; - return this; - } - - /** - *

Properties sent to the provider along with the token

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage properties(Object properties) { - this.properties = Optional.of(properties); - return this; - } - - @java.lang.Override - @JsonSetter(value = "properties", nulls = Nulls.SKIP) - public _FinalStage properties(Optional properties) { - this.properties = properties; - return this; - } - - /** - *

ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable expiration.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage expiryDate(ExpiryDate expiryDate) { - this.expiryDate = Optional.of(expiryDate); - return this; - } - - @java.lang.Override - @JsonSetter(value = "expiry_date", nulls = Nulls.SKIP) - public _FinalStage expiryDate(Optional expiryDate) { - this.expiryDate = expiryDate; - return this; - } - - /** - *

Full body of the token. Must match token in URL.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - public _FinalStage token(String token) { - this.token = Optional.of(token); - return this; - } - - @java.lang.Override - @JsonSetter(value = "token", nulls = Nulls.SKIP) - public _FinalStage token(Optional token) { - this.token = token; - return this; - } - - @java.lang.Override - public UserToken build() { - return new UserToken(token, providerKey, expiryDate, properties, device, tracking, additionalProperties); - } - } -} diff --git a/src/main/java/com/courier/api/types/SendMessageResponse.java b/src/main/java/com/courier/api/types/SendMessageResponse.java deleted file mode 100644 index 483254d2..00000000 --- a/src/main/java/com/courier/api/types/SendMessageResponse.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api.types; - -import com.courier.api.core.ObjectMappers; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSetter; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonDeserialize(builder = SendMessageResponse.Builder.class) -public final class SendMessageResponse { - private final String requestId; - - private final Map additionalProperties; - - private SendMessageResponse(String requestId, Map additionalProperties) { - this.requestId = requestId; - this.additionalProperties = additionalProperties; - } - - /** - * @return A successful call to POST /send returns a 202 status code along with a requestId in the response body. - *

For send requests that have a single recipient, the requestId is assigned to the derived message as its message_id. Therefore the requestId can be supplied to the Message's API for single recipient messages.

- *

For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier assigns a unique id to each derived message as its message_id. Therefore the requestId cannot be supplied to the Message's API for single-recipient messages.

- */ - @JsonProperty("requestId") - public String getRequestId() { - return requestId; - } - - @java.lang.Override - public boolean equals(Object other) { - if (this == other) return true; - return other instanceof SendMessageResponse && equalTo((SendMessageResponse) other); - } - - @JsonAnyGetter - public Map getAdditionalProperties() { - return this.additionalProperties; - } - - private boolean equalTo(SendMessageResponse other) { - return requestId.equals(other.requestId); - } - - @java.lang.Override - public int hashCode() { - return Objects.hash(this.requestId); - } - - @java.lang.Override - public String toString() { - return ObjectMappers.stringify(this); - } - - public static RequestIdStage builder() { - return new Builder(); - } - - public interface RequestIdStage { - _FinalStage requestId(String requestId); - - Builder from(SendMessageResponse other); - } - - public interface _FinalStage { - SendMessageResponse build(); - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Builder implements RequestIdStage, _FinalStage { - private String requestId; - - @JsonAnySetter - private Map additionalProperties = new HashMap<>(); - - private Builder() {} - - @java.lang.Override - public Builder from(SendMessageResponse other) { - requestId(other.getRequestId()); - return this; - } - - /** - *

A successful call to POST /send returns a 202 status code along with a requestId in the response body.

- *

For send requests that have a single recipient, the requestId is assigned to the derived message as its message_id. Therefore the requestId can be supplied to the Message's API for single recipient messages.

- *

For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier assigns a unique id to each derived message as its message_id. Therefore the requestId cannot be supplied to the Message's API for single-recipient messages.

- * @return Reference to {@code this} so that method calls can be chained together. - */ - @java.lang.Override - @JsonSetter("requestId") - public _FinalStage requestId(String requestId) { - this.requestId = requestId; - return this; - } - - @java.lang.Override - public SendMessageResponse build() { - return new SendMessageResponse(requestId, additionalProperties); - } - } -} diff --git a/src/test/java/com/courier/api/TestClient.java b/src/test/java/com/courier/api/TestClient.java deleted file mode 100644 index f567ea8b..00000000 --- a/src/test/java/com/courier/api/TestClient.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ -package com.courier.api; - -public final class TestClient { - public void test() { - // Add tests here and mark this file in .fernignore - assert true; - } -} From d4cde450dc82626223aee050c5c848f70fe79382 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:04:59 +0000 Subject: [PATCH 02/33] chore: update SDK settings --- .github/workflows/publish-sonatype.yml | 41 ++++++++++++ .github/workflows/release-doctor.yml | 24 +++++++ .release-please-manifest.json | 3 + .stats.yml | 2 +- README.md | 14 +++- bin/check-release-environment | 33 +++++++++ build.gradle.kts | 2 +- .../main/kotlin/courier.publish.gradle.kts | 8 +-- .../main/kotlin/com/courier/api/core/Check.kt | 2 +- release-please-config.json | 67 +++++++++++++++++++ 10 files changed, 188 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish-sonatype.yml create mode 100644 .github/workflows/release-doctor.yml create mode 100644 .release-please-manifest.json create mode 100644 bin/check-release-environment create mode 100644 release-please-config.json diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml new file mode 100644 index 00000000..bb1398a4 --- /dev/null +++ b/.github/workflows/publish-sonatype.yml @@ -0,0 +1,41 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to Sonatype in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/trycourier/courier-java/actions/workflows/publish-sonatype.yml +name: Publish Sonatype +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: | + 8 + 21 + cache: gradle + + - name: Set up Gradle + uses: gradle/gradle-build-action@v2 + + - name: Publish to Sonatype + run: |- + export -- GPG_SIGNING_KEY_ID + printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD" + GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')" + ./gradlew publish --no-configuration-cache + env: + SONATYPE_USERNAME: ${{ secrets.COURIER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.COURIER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.COURIER_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.COURIER_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} \ No newline at end of file diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 00000000..ba006aee --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,24 @@ +name: Release Doctor +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'trycourier/courier-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + SONATYPE_USERNAME: ${{ secrets.COURIER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.COURIER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.COURIER_SONATYPE_GPG_SIGNING_KEY || secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.COURIER_SONATYPE_GPG_SIGNING_PASSWORD || secrets.GPG_SIGNING_PASSWORD }} diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..1332969b --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index a30affc9..7e55a881 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: cdd0e8b97754393a5262fb5e52e2ddcf +config_hash: 381e1c6d531344004ac7898cebe4b842 diff --git a/README.md b/README.md index cb8be759..2799ad1b 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,26 @@ # Courier Java API Library + + [![Maven Central](https://img.shields.io/maven-central/v/com.courier.api/courier-java)](https://central.sonatype.com/artifact/com.courier.api/courier-java/0.0.1) [![javadoc](https://javadoc.io/badge2/com.courier.api/courier-java/0.0.1/javadoc.svg)](https://javadoc.io/doc/com.courier.api/courier-java/0.0.1) + + The Courier Java SDK provides convenient access to the Courier REST API from applications written in Java. It is generated with [Stainless](https://www.stainless.com/). + + Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.courier.api/courier-java/0.0.1). + + ## Installation + + ### Gradle ```kotlin @@ -27,6 +37,8 @@ implementation("com.courier.api:courier-java:0.0.1") ``` + + ## Requirements This library requires Java 8 or later. @@ -650,4 +662,4 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/courier-java/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/trycourier/courier-java/issues) with questions, bugs, or suggestions. diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 00000000..3a6a7b4a --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${SONATYPE_USERNAME}" ]; then + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_KEY}" ]; then + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +if [ -z "${GPG_SIGNING_PASSWORD}" ]; then + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" diff --git a/build.gradle.kts b/build.gradle.kts index 4170b798..cf01d13e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.courier.api" - version = "0.0.1" + version = "0.0.1" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/courier.publish.gradle.kts b/buildSrc/src/main/kotlin/courier.publish.gradle.kts index a3deea52..e36e7d24 100644 --- a/buildSrc/src/main/kotlin/courier.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/courier.publish.gradle.kts @@ -11,7 +11,7 @@ configure { pom { name.set("Courier") description.set("An SDK library for courier") - url.set("https://www.github.com/stainless-sdks/courier-java") + url.set("https://www.github.com/trycourier/courier-java") licenses { license { @@ -26,9 +26,9 @@ configure { } scm { - connection.set("scm:git:git://github.com/stainless-sdks/courier-java.git") - developerConnection.set("scm:git:git://github.com/stainless-sdks/courier-java.git") - url.set("https://github.com/stainless-sdks/courier-java") + connection.set("scm:git:git://github.com/trycourier/courier-java.git") + developerConnection.set("scm:git:git://github.com/trycourier/courier-java.git") + url.set("https://github.com/trycourier/courier-java") } versionMapping { diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt index c1e1eaf5..fee5b0d4 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/core/Check.kt @@ -77,7 +77,7 @@ This can happen if you are either: Double-check that you are depending on compatible Jackson versions. -See https://www.github.com/stainless-sdks/courier-java#jackson for more information. +See https://www.github.com/trycourier/courier-java#jackson for more information. """ .trimIndent() } diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..8f987198 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "simple", + "extra-files": [ + "README.md", + "build.gradle.kts" + ] +} \ No newline at end of file From 64faf55675cd272801e6665f9e5a192f9ae05b8a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:05:12 +0000 Subject: [PATCH 03/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 7e55a881..d32da0ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: 381e1c6d531344004ac7898cebe4b842 +config_hash: c84a706be3f7921abb3279d7364a2d7b From b43f9e583c0f404aa9ed0db7ed28b1ceba85d686 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:10:30 +0000 Subject: [PATCH 04/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index d32da0ff..21c97a60 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: c84a706be3f7921abb3279d7364a2d7b +config_hash: d97e46bac2e674b08f6e1f661c9c837d From 722eb567e13dc69ecf1c464a5cbb296c2fc69d97 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 18:55:09 +0000 Subject: [PATCH 05/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 21c97a60..cad74b14 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: d97e46bac2e674b08f6e1f661c9c837d +config_hash: f4c65a60addbed19f59da9b66b7f9998 From f1f5c520a050781c88b8c5c90918fcd7c948f38b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 20:33:22 +0000 Subject: [PATCH 06/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index cad74b14..27731e1b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: f4c65a60addbed19f59da9b66b7f9998 +config_hash: 95eeff6eb3e84bae51819c372640d9ae From ab3ef5d4292e846a80b39ae7c608305830637f64 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:19:57 +0000 Subject: [PATCH 07/33] feat(api): manual updates Send name change --- .stats.yml | 2 +- README.md | 66 +++++------ ...dMessageParams.kt => SendMessageParams.kt} | 24 ++-- ...sageResponse.kt => SendMessageResponse.kt} | 24 ++-- .../api/services/async/SendServiceAsync.kt | 36 +++--- .../services/async/SendServiceAsyncImpl.kt | 24 ++-- .../api/services/blocking/SendService.kt | 30 ++--- .../api/services/blocking/SendServiceImpl.kt | 24 ++-- ...ParamsTest.kt => SendMessageParamsTest.kt} | 8 +- .../models/send/SendMessageResponseTest.kt | 32 ++++++ .../send/SendSendMessageResponseTest.kt | 34 ------ .../courier/api/services/ErrorHandlingTest.kt | 104 +++++++++--------- .../courier/api/services/ServiceParamsTest.kt | 8 +- .../services/async/SendServiceAsyncTest.kt | 8 +- .../api/services/blocking/SendServiceTest.kt | 8 +- 15 files changed, 215 insertions(+), 217 deletions(-) rename courier-java-core/src/main/kotlin/com/courier/api/models/send/{SendSendMessageParams.kt => SendMessageParams.kt} (95%) rename courier-java-core/src/main/kotlin/com/courier/api/models/send/{SendSendMessageResponse.kt => SendMessageResponse.kt} (89%) rename courier-java-core/src/test/kotlin/com/courier/api/models/send/{SendSendMessageParamsTest.kt => SendMessageParamsTest.kt} (99%) create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 27731e1b..56b45225 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: 95eeff6eb3e84bae51819c372640d9ae +config_hash: d99e176269a6a45a76f40d093dbdf91d diff --git a/README.md b/README.md index 2799ad1b..3c6fff31 100644 --- a/README.md +++ b/README.md @@ -51,14 +51,14 @@ import com.courier.api.client.okhttp.CourierOkHttpClient; import com.courier.api.models.send.Content; import com.courier.api.models.send.ElementalNode; import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClient client = CourierOkHttpClient.fromEnv(); -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(Message.ContentMessage.builder() .content(Content.ElementalContent.builder() .addElement(ElementalNode.UnionMember0.builder().build()) @@ -66,7 +66,7 @@ SendSendMessageParams params = SendSendMessageParams.builder() .build()) .build()) .build(); -SendSendMessageResponse response = client.send().sendMessage(params); +SendMessageResponse response = client.send().message(params); ``` ## Client configuration @@ -139,7 +139,7 @@ The `withOptions()` method does not affect the original client or service. To send a request to the Courier API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.send().sendMessage(...)` should be called with an instance of `SendSendMessageParams`, and it will return an instance of `SendSendMessageResponse`. +For example, `client.send().message(...)` should be called with an instance of `SendMessageParams`, and it will return an instance of `SendMessageResponse`. ## Immutability @@ -159,15 +159,15 @@ import com.courier.api.client.okhttp.CourierOkHttpClient; import com.courier.api.models.send.Content; import com.courier.api.models.send.ElementalNode; import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; import java.util.concurrent.CompletableFuture; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClient client = CourierOkHttpClient.fromEnv(); -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(Message.ContentMessage.builder() .content(Content.ElementalContent.builder() .addElement(ElementalNode.UnionMember0.builder().build()) @@ -175,7 +175,7 @@ SendSendMessageParams params = SendSendMessageParams.builder() .build()) .build()) .build(); -CompletableFuture response = client.async().send().sendMessage(params); +CompletableFuture response = client.async().send().message(params); ``` Or create an asynchronous client from the beginning: @@ -186,15 +186,15 @@ import com.courier.api.client.okhttp.CourierOkHttpClientAsync; import com.courier.api.models.send.Content; import com.courier.api.models.send.ElementalNode; import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; import java.util.concurrent.CompletableFuture; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClientAsync client = CourierOkHttpClientAsync.fromEnv(); -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(Message.ContentMessage.builder() .content(Content.ElementalContent.builder() .addElement(ElementalNode.UnionMember0.builder().build()) @@ -202,7 +202,7 @@ SendSendMessageParams params = SendSendMessageParams.builder() .build()) .build()) .build(); -CompletableFuture response = client.send().sendMessage(params); +CompletableFuture response = client.send().message(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -219,10 +219,10 @@ import com.courier.api.core.http.HttpResponseFor; import com.courier.api.models.send.Content; import com.courier.api.models.send.ElementalNode; import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(Message.ContentMessage.builder() .content(Content.ElementalContent.builder() .addElement(ElementalNode.UnionMember0.builder().build()) @@ -230,7 +230,7 @@ SendSendMessageParams params = SendSendMessageParams.builder() .build()) .build()) .build(); -HttpResponseFor response = client.send().withRawResponse().sendMessage(params); +HttpResponseFor response = client.send().withRawResponse().message(params); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -239,9 +239,9 @@ Headers headers = response.headers(); You can still deserialize the response into an instance of a Java class if needed: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse parsedResponse = response.parse(); +SendMessageResponse parsedResponse = response.parse(); ``` ## Error handling @@ -337,9 +337,9 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse response = client.send().sendMessage( +SendMessageResponse response = client.send().message( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() ); ``` @@ -444,9 +444,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -474,9 +474,9 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(JsonValue.from(42)) .build(); ``` @@ -526,9 +526,9 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](courier- ```java import com.courier.api.core.JsonMissing; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(JsonMissing.of()) .build(); ``` @@ -541,7 +541,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.courier.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.send().sendMessage(params)._additionalProperties(); +Map additionalProperties = client.send().message(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -572,7 +572,7 @@ import com.courier.api.core.JsonField; import com.courier.api.models.send.Message; import java.util.Optional; -JsonField message = client.send().sendMessage(params)._message(); +JsonField message = client.send().message(params)._message(); if (message.isMissing()) { // The property is absent from the JSON response @@ -597,17 +597,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Co If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse response = client.send().sendMessage(params).validate(); +SendMessageResponse response = client.send().message(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse response = client.send().sendMessage( +SendMessageResponse response = client.send().message( params, RequestOptions.builder().responseValidation(true).build() ); ``` diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt similarity index 95% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt index dde35b57..26f5c60f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt @@ -20,7 +20,7 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** Use the send API to send a message to one or more recipients. */ -class SendSendMessageParams +class SendMessageParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -55,7 +55,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SendSendMessageParams]. + * Returns a mutable builder for constructing an instance of [SendMessageParams]. * * The following fields are required: * ```java @@ -65,7 +65,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SendSendMessageParams]. */ + /** A builder for [SendMessageParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -73,10 +73,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(sendSendMessageParams: SendSendMessageParams) = apply { - body = sendSendMessageParams.body.toBuilder() - additionalHeaders = sendSendMessageParams.additionalHeaders.toBuilder() - additionalQueryParams = sendSendMessageParams.additionalQueryParams.toBuilder() + internal fun from(sendMessageParams: SendMessageParams) = apply { + body = sendMessageParams.body.toBuilder() + additionalHeaders = sendMessageParams.additionalHeaders.toBuilder() + additionalQueryParams = sendMessageParams.additionalQueryParams.toBuilder() } /** @@ -223,7 +223,7 @@ private constructor( } /** - * Returns an immutable instance of [SendSendMessageParams]. + * Returns an immutable instance of [SendMessageParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -234,8 +234,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): SendSendMessageParams = - SendSendMessageParams( + fun build(): SendMessageParams = + SendMessageParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -416,7 +416,7 @@ private constructor( return true } - return other is SendSendMessageParams && + return other is SendMessageParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -425,5 +425,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "SendSendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "SendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt similarity index 89% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt index 1a094b8c..62d7e7fd 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt @@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects -class SendSendMessageResponse +class SendMessageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val requestId: JsonField, @@ -66,7 +66,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SendSendMessageResponse]. + * Returns a mutable builder for constructing an instance of [SendMessageResponse]. * * The following fields are required: * ```java @@ -76,16 +76,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SendSendMessageResponse]. */ + /** A builder for [SendMessageResponse]. */ class Builder internal constructor() { private var requestId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(sendSendMessageResponse: SendSendMessageResponse) = apply { - requestId = sendSendMessageResponse.requestId - additionalProperties = sendSendMessageResponse.additionalProperties.toMutableMap() + internal fun from(sendMessageResponse: SendMessageResponse) = apply { + requestId = sendMessageResponse.requestId + additionalProperties = sendMessageResponse.additionalProperties.toMutableMap() } /** @@ -131,7 +131,7 @@ private constructor( } /** - * Returns an immutable instance of [SendSendMessageResponse]. + * Returns an immutable instance of [SendMessageResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -142,8 +142,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): SendSendMessageResponse = - SendSendMessageResponse( + fun build(): SendMessageResponse = + SendMessageResponse( checkRequired("requestId", requestId), additionalProperties.toMutableMap(), ) @@ -151,7 +151,7 @@ private constructor( private var validated: Boolean = false - fun validate(): SendSendMessageResponse = apply { + fun validate(): SendMessageResponse = apply { if (validated) { return@apply } @@ -180,7 +180,7 @@ private constructor( return true } - return other is SendSendMessageResponse && + return other is SendMessageResponse && requestId == other.requestId && additionalProperties == other.additionalProperties } @@ -190,5 +190,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SendSendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" + "SendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt index 6e194a5c..3d9e4a0e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt @@ -5,8 +5,8 @@ package com.courier.api.services.async import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -25,14 +25,14 @@ interface SendServiceAsync { fun withOptions(modifier: Consumer): SendServiceAsync /** Use the send API to send a message to one or more recipients. */ - fun sendMessage(params: SendSendMessageParams): CompletableFuture = - sendMessage(params, RequestOptions.none()) + fun message(params: SendMessageParams): CompletableFuture = + message(params, RequestOptions.none()) - /** @see sendMessage */ - fun sendMessage( - params: SendSendMessageParams, + /** @see message */ + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** A view of [SendServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -46,17 +46,17 @@ interface SendServiceAsync { /** * Returns a raw HTTP response for `post /send`, but is otherwise the same as - * [SendServiceAsync.sendMessage]. + * [SendServiceAsync.message]. */ - fun sendMessage( - params: SendSendMessageParams - ): CompletableFuture> = - sendMessage(params, RequestOptions.none()) - - /** @see sendMessage */ - fun sendMessage( - params: SendSendMessageParams, + fun message( + params: SendMessageParams + ): CompletableFuture> = + message(params, RequestOptions.none()) + + /** @see message */ + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt index 67cf12db..9d5042b7 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt @@ -15,8 +15,8 @@ import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepareAsync -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -32,12 +32,12 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): SendServiceAsync = SendServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /send - withRawResponse().sendMessage(params, requestOptions).thenApply { it.parse() } + withRawResponse().message(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SendServiceAsync.WithRawResponse { @@ -52,13 +52,13 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - private val sendMessageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val messageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -73,7 +73,7 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { sendMessageHandler.handle(it) } + .use { messageHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt index ac6f2552..b4fd838f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt @@ -5,8 +5,8 @@ package com.courier.api.services.blocking import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -25,14 +25,14 @@ interface SendService { fun withOptions(modifier: Consumer): SendService /** Use the send API to send a message to one or more recipients. */ - fun sendMessage(params: SendSendMessageParams): SendSendMessageResponse = - sendMessage(params, RequestOptions.none()) + fun message(params: SendMessageParams): SendMessageResponse = + message(params, RequestOptions.none()) - /** @see sendMessage */ - fun sendMessage( - params: SendSendMessageParams, + /** @see message */ + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SendSendMessageResponse + ): SendMessageResponse /** A view of [SendService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -46,17 +46,17 @@ interface SendService { /** * Returns a raw HTTP response for `post /send`, but is otherwise the same as - * [SendService.sendMessage]. + * [SendService.message]. */ @MustBeClosed - fun sendMessage(params: SendSendMessageParams): HttpResponseFor = - sendMessage(params, RequestOptions.none()) + fun message(params: SendMessageParams): HttpResponseFor = + message(params, RequestOptions.none()) - /** @see sendMessage */ + /** @see message */ @MustBeClosed - fun sendMessage( - params: SendSendMessageParams, + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt index 74328ce2..00735db5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt @@ -15,8 +15,8 @@ import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepare -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import java.util.function.Consumer class SendServiceImpl internal constructor(private val clientOptions: ClientOptions) : SendService { @@ -30,12 +30,12 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): SendService = SendServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): SendSendMessageResponse = + ): SendMessageResponse = // post /send - withRawResponse().sendMessage(params, requestOptions).parse() + withRawResponse().message(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SendService.WithRawResponse { @@ -50,13 +50,13 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) - private val sendMessageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val messageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -69,7 +69,7 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { sendMessageHandler.handle(it) } + .use { messageHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt similarity index 99% rename from courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index 35068e0f..09280c1e 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -6,11 +6,11 @@ import com.courier.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class SendSendMessageParamsTest { +internal class SendMessageParamsTest { @Test fun create() { - SendSendMessageParams.builder() + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -208,7 +208,7 @@ internal class SendSendMessageParamsTest { @Test fun body() { val params = - SendSendMessageParams.builder() + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -609,7 +609,7 @@ internal class SendSendMessageParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - SendSendMessageParams.builder() + SendMessageParams.builder() .message( Message.ContentMessage.builder() .content( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt new file mode 100644 index 00000000..77c1eb0f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SendMessageResponseTest { + + @Test + fun create() { + val sendMessageResponse = SendMessageResponse.builder().requestId("requestId").build() + + assertThat(sendMessageResponse.requestId()).isEqualTo("requestId") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sendMessageResponse = SendMessageResponse.builder().requestId("requestId").build() + + val roundtrippedSendMessageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sendMessageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSendMessageResponse).isEqualTo(sendMessageResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt deleted file mode 100644 index 5912fb9f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SendSendMessageResponseTest { - - @Test - fun create() { - val sendSendMessageResponse = - SendSendMessageResponse.builder().requestId("requestId").build() - - assertThat(sendSendMessageResponse.requestId()).isEqualTo("requestId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val sendSendMessageResponse = - SendSendMessageResponse.builder().requestId("requestId").build() - - val roundtrippedSendSendMessageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(sendSendMessageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedSendSendMessageResponse).isEqualTo(sendSendMessageResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index 2f385f95..1926589d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -23,7 +23,7 @@ import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post @@ -67,7 +67,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage400() { + fun sendMessage400() { val sendService = client.send() stubFor( post(anyUrl()) @@ -78,8 +78,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -299,7 +299,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage400WithRawResponse() { + fun sendMessage400WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -310,8 +310,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -531,7 +531,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage401() { + fun sendMessage401() { val sendService = client.send() stubFor( post(anyUrl()) @@ -542,8 +542,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -763,7 +763,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage401WithRawResponse() { + fun sendMessage401WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -774,8 +774,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -995,7 +995,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage403() { + fun sendMessage403() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1006,8 +1006,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -1227,7 +1227,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage403WithRawResponse() { + fun sendMessage403WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1238,8 +1238,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -1459,7 +1459,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage404() { + fun sendMessage404() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1470,8 +1470,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -1691,7 +1691,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage404WithRawResponse() { + fun sendMessage404WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1702,8 +1702,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -1923,7 +1923,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage422() { + fun sendMessage422() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1934,8 +1934,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -2155,7 +2155,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage422WithRawResponse() { + fun sendMessage422WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -2166,8 +2166,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -2387,7 +2387,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage429() { + fun sendMessage429() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2398,8 +2398,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -2619,7 +2619,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage429WithRawResponse() { + fun sendMessage429WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -2630,8 +2630,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -2851,7 +2851,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage500() { + fun sendMessage500() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2862,8 +2862,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -3083,7 +3083,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage500WithRawResponse() { + fun sendMessage500WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -3094,8 +3094,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -3315,7 +3315,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage999() { + fun sendMessage999() { val sendService = client.send() stubFor( post(anyUrl()) @@ -3326,8 +3326,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -3547,7 +3547,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage999WithRawResponse() { + fun sendMessage999WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -3558,8 +3558,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") @@ -3779,7 +3779,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessageInvalidJsonBody() { + fun sendMessageInvalidJsonBody() { val sendService = client.send() stubFor( post(anyUrl()) @@ -3788,8 +3788,8 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index e694c478..cbd00c20 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -12,7 +12,7 @@ import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo @@ -46,12 +46,12 @@ internal class ServiceParamsTest { @Disabled("Prism tests are disabled") @Test - fun sendMessage() { + fun message() { val sendService = client.send() stubFor(post(anyUrl()).willReturn(ok("{}"))) - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 5097f433..17ca5300 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -12,7 +12,7 @@ import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -23,7 +23,7 @@ internal class SendServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun sendMessage() { + fun message() { val client = CourierOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -32,8 +32,8 @@ internal class SendServiceAsyncTest { val sendServiceAsync = client.send() val responseFuture = - sendServiceAsync.sendMessage( - SendSendMessageParams.builder() + sendServiceAsync.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index 0dc3c6e8..86d83405 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -12,7 +12,7 @@ import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -23,7 +23,7 @@ internal class SendServiceTest { @Disabled("Prism tests are disabled") @Test - fun sendMessage() { + fun message() { val client = CourierOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -32,8 +32,8 @@ internal class SendServiceTest { val sendService = client.send() val response = - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( Message.ContentMessage.builder() .brandId("brand_id") From 129defa8479a626a5fe42780524c6658099ffe5d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:32:29 +0000 Subject: [PATCH 08/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 56b45225..857df84a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: d99e176269a6a45a76f40d093dbdf91d +config_hash: 378bde789aaf92394a1aa4fe02fe0063 From 7d7fc48a3d4ee8be4e0bd49d50b346268923736e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:36:25 +0000 Subject: [PATCH 09/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 857df84a..faebbcb8 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: 378bde789aaf92394a1aa4fe02fe0063 +config_hash: 5e00923835ae1232d2c1ee8b18be2548 From 95f6365ae0dda696c3c95d0bdaca1ee4a1f22503 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 1 Oct 2025 21:43:46 +0000 Subject: [PATCH 10/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index faebbcb8..70b71825 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: 5e00923835ae1232d2c1ee8b18be2548 +config_hash: 6308a26568cc14808d687505c6cd4280 From e4986bcd194638319398f2375e0a5304cbda49dd Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 16:48:04 +0000 Subject: [PATCH 11/33] feat(api): manual updates --- .stats.yml | 2 +- README.md | 56 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/.stats.yml b/.stats.yml index 70b71825..4b15b6a4 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: 6308a26568cc14808d687505c6cd4280 +config_hash: effd99dd6c72790f75bceb1021a91e47 diff --git a/README.md b/README.md index 3c6fff31..e3fb92d0 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,9 @@ This library requires Java 8 or later. ```java import com.courier.api.client.CourierClient; import com.courier.api.client.okhttp.CourierOkHttpClient; -import com.courier.api.models.send.Content; -import com.courier.api.models.send.ElementalNode; +import com.courier.api.core.JsonValue; +import com.courier.api.models.send.BaseMessage; +import com.courier.api.models.send.BaseMessageSendTo; import com.courier.api.models.send.Message; import com.courier.api.models.send.SendMessageParams; import com.courier.api.models.send.SendMessageResponse; @@ -59,10 +60,11 @@ import com.courier.api.models.send.SendMessageResponse; CourierClient client = CourierOkHttpClient.fromEnv(); SendMessageParams params = SendMessageParams.builder() - .message(Message.ContentMessage.builder() - .content(Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) - .version("version") + .message(Message.TemplateMessage.builder() + .to(BaseMessageSendTo.To.UnionMember1.builder().build()) + .template("your_template") + .data(BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build()) .build()) .build(); @@ -156,8 +158,9 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.courier.api.client.CourierClient; import com.courier.api.client.okhttp.CourierOkHttpClient; -import com.courier.api.models.send.Content; -import com.courier.api.models.send.ElementalNode; +import com.courier.api.core.JsonValue; +import com.courier.api.models.send.BaseMessage; +import com.courier.api.models.send.BaseMessageSendTo; import com.courier.api.models.send.Message; import com.courier.api.models.send.SendMessageParams; import com.courier.api.models.send.SendMessageResponse; @@ -168,10 +171,11 @@ import java.util.concurrent.CompletableFuture; CourierClient client = CourierOkHttpClient.fromEnv(); SendMessageParams params = SendMessageParams.builder() - .message(Message.ContentMessage.builder() - .content(Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) - .version("version") + .message(Message.TemplateMessage.builder() + .to(BaseMessageSendTo.To.UnionMember1.builder().build()) + .template("your_template") + .data(BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build()) .build()) .build(); @@ -183,8 +187,9 @@ Or create an asynchronous client from the beginning: ```java import com.courier.api.client.CourierClientAsync; import com.courier.api.client.okhttp.CourierOkHttpClientAsync; -import com.courier.api.models.send.Content; -import com.courier.api.models.send.ElementalNode; +import com.courier.api.core.JsonValue; +import com.courier.api.models.send.BaseMessage; +import com.courier.api.models.send.BaseMessageSendTo; import com.courier.api.models.send.Message; import com.courier.api.models.send.SendMessageParams; import com.courier.api.models.send.SendMessageResponse; @@ -195,10 +200,11 @@ import java.util.concurrent.CompletableFuture; CourierClientAsync client = CourierOkHttpClientAsync.fromEnv(); SendMessageParams params = SendMessageParams.builder() - .message(Message.ContentMessage.builder() - .content(Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) - .version("version") + .message(Message.TemplateMessage.builder() + .to(BaseMessageSendTo.To.UnionMember1.builder().build()) + .template("your_template") + .data(BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build()) .build()) .build(); @@ -214,19 +220,21 @@ The SDK defines methods that deserialize responses into instances of Java classe To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java +import com.courier.api.core.JsonValue; import com.courier.api.core.http.Headers; import com.courier.api.core.http.HttpResponseFor; -import com.courier.api.models.send.Content; -import com.courier.api.models.send.ElementalNode; +import com.courier.api.models.send.BaseMessage; +import com.courier.api.models.send.BaseMessageSendTo; import com.courier.api.models.send.Message; import com.courier.api.models.send.SendMessageParams; import com.courier.api.models.send.SendMessageResponse; SendMessageParams params = SendMessageParams.builder() - .message(Message.ContentMessage.builder() - .content(Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) - .version("version") + .message(Message.TemplateMessage.builder() + .to(BaseMessageSendTo.To.UnionMember1.builder().build()) + .template("your_template") + .data(BaseMessage.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build()) .build()) .build(); From 58574e801b6a428424e4fba995cdbfa0c1d5c448 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 18:30:24 +0000 Subject: [PATCH 12/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 4b15b6a4..3a90d69d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: effd99dd6c72790f75bceb1021a91e47 +config_hash: e7f646e730e7b27205b2bd6a6dc3e572 From f6bfa5c660e604543bba1371fde1601f47432da3 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 19:54:14 +0000 Subject: [PATCH 13/33] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 3a90d69d..a4f42243 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: e7f646e730e7b27205b2bd6a6dc3e572 +config_hash: 5d1f1698a0d16c5edb2c695dd127b335 From 1a3eab10a8b1eba2ed8bbdd82dffb81efae0155f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 21:29:45 +0000 Subject: [PATCH 14/33] feat(api): manual updates Hiding Elemental Channel Node --- .stats.yml | 4 +- .../com/courier/api/models/send/Content.kt | 5 +- .../api/models/send/ElementalChannelNode.kt | 572 ------------------ .../api/models/send/ElementalGroupNode.kt | 5 +- .../courier/api/models/send/ElementalNode.kt | 542 ++--------------- .../models/send/ElementalChannelNodeTest.kt | 98 --- .../api/models/send/ElementalNodeTest.kt | 71 +-- 7 files changed, 80 insertions(+), 1217 deletions(-) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt diff --git a/.stats.yml b/.stats.yml index a4f42243..23f20807 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml -openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-ebaec6ae38b7c903923797cc52f2ca25842ead289d62de22dd5ed527d8e8e994.yml +openapi_spec_hash: a29421ec84cecc5d172f5a41e29d9d6a config_hash: 5d1f1698a0d16c5edb2c695dd127b335 diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt index b1857ad5..b43ce5b2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -339,9 +339,8 @@ private constructor( fun addElement(unionMember1: ElementalNode.UnionMember1) = addElement(ElementalNode.ofUnionMember1(unionMember1)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) + /** Alias for calling [addElement] with `ElementalNode.ofType(type)`. */ + fun addElement(type: ElementalNode.Type) = addElement(ElementalNode.ofType(type)) /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ fun addElement(unionMember3: ElementalNode.UnionMember3) = diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt deleted file mode 100644 index 68c66523..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt +++ /dev/null @@ -1,572 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ElementalChannelNode -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val channel: JsonField, - private val channels: JsonField>, - private val elements: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val raw: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(channel, channels, elements, if_, loop, raw, ref, mutableMapOf()) - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` is - * `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun elements(): Optional> = elements.getOptional("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun raw(): Optional = raw.getOptional("raw") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [raw]. - * - * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalChannelNode]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalChannelNode]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var channels: JsonField>? = null - private var elements: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var raw: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalChannelNode: ElementalChannelNode) = apply { - channel = elementalChannelNode.channel - channels = elementalChannelNode.channels.map { it.toMutableList() } - elements = elementalChannelNode.elements.map { it.toMutableList() } - if_ = elementalChannelNode.if_ - loop = elementalChannelNode.loop - raw = elementalChannelNode.raw - ref = elementalChannelNode.ref - additionalProperties = elementalChannelNode.additionalProperties.toMutableMap() - } - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - */ - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` - * is `required`. - */ - fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) - - /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ - fun elements(elements: Optional>) = elements(elements.getOrNull()) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - */ - fun raw(raw: Raw?) = raw(JsonField.ofNullable(raw)) - - /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ - fun raw(raw: Optional) = raw(raw.getOrNull()) - - /** - * Sets [Builder.raw] to an arbitrary JSON value. - * - * You should usually call [Builder.raw] with a well-typed [Raw] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. - */ - fun raw(raw: JsonField) = apply { this.raw = raw } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalChannelNode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalChannelNode = - ElementalChannelNode( - checkRequired("channel", channel), - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - (elements ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - raw, - ref, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalChannelNode = apply { - if (validated) { - return@apply - } - - channel() - channels() - elements().ifPresent { it.forEach { it.validate() } } - if_() - loop() - raw().ifPresent { it.validate() } - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (raw.asKnown().getOrNull()?.validity() ?: 0) + - (if (ref.asKnown().isPresent) 1 else 0) - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. - */ - class Raw - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Raw]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Raw]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(raw: Raw) = apply { - additionalProperties = raw.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Raw]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Raw = Raw(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Raw = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Raw && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Raw{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalChannelNode && - channel == other.channel && - channels == other.channels && - elements == other.elements && - if_ == other.if_ && - loop == other.loop && - raw == other.raw && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channel, channels, elements, if_, loop, raw, ref, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalChannelNode{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt index c0d905c7..7c229219 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt @@ -191,9 +191,8 @@ private constructor( fun addElement(unionMember1: ElementalNode.UnionMember1) = addElement(ElementalNode.ofUnionMember1(unionMember1)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) + /** Alias for calling [addElement] with `ElementalNode.ofType(type)`. */ + fun addElement(type: ElementalNode.Type) = addElement(ElementalNode.ofType(type)) /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ fun addElement(unionMember3: ElementalNode.UnionMember3) = diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt index 17b2304e..4b6eada5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt @@ -32,13 +32,8 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is sent - * through email, and a more concise message in a push notification. Channel elements are only valid - * as top-level elements; you cannot nest channel elements. If there is a channel element specified - * at the top-level of the document, all sibling elements must be channel elements. Note: As an - * alternative, most elements support a `channel` property. Which allows you to selectively display - * an individual element on a per channel basis. See the + * Allows you to group elements together. This can be useful when used in combination with "if" or + * "loop". See * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for * more details. */ @@ -48,7 +43,7 @@ class ElementalNode private constructor( private val unionMember0: UnionMember0? = null, private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, + private val type: Type? = null, private val unionMember3: UnionMember3? = null, private val unionMember4: UnionMember4? = null, private val unionMember5: UnionMember5? = null, @@ -61,18 +56,7 @@ private constructor( fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + fun type(): Optional = Optional.ofNullable(type) fun unionMember3(): Optional = Optional.ofNullable(unionMember3) @@ -94,7 +78,7 @@ private constructor( fun isUnionMember1(): Boolean = unionMember1 != null - fun isUnionMember2(): Boolean = unionMember2 != null + fun isType(): Boolean = type != null fun isUnionMember3(): Boolean = unionMember3 != null @@ -110,18 +94,7 @@ private constructor( fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + fun asType(): Type = type.getOrThrow("type") fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") @@ -145,7 +118,7 @@ private constructor( when { unionMember0 != null -> visitor.visitUnionMember0(unionMember0) unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + type != null -> visitor.visitType(type) unionMember3 != null -> visitor.visitUnionMember3(unionMember3) unionMember4 != null -> visitor.visitUnionMember4(unionMember4) unionMember5 != null -> visitor.visitUnionMember5(unionMember5) @@ -171,8 +144,8 @@ private constructor( unionMember1.validate() } - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() + override fun visitType(type: Type) { + type.validate() } override fun visitUnionMember3(unionMember3: UnionMember3) { @@ -220,7 +193,7 @@ private constructor( override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() - override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + override fun visitType(type: Type) = type.validity() override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() @@ -244,7 +217,7 @@ private constructor( return other is ElementalNode && unionMember0 == other.unionMember0 && unionMember1 == other.unionMember1 && - unionMember2 == other.unionMember2 && + type == other.type && unionMember3 == other.unionMember3 && unionMember4 == other.unionMember4 && unionMember5 == other.unionMember5 && @@ -256,7 +229,7 @@ private constructor( Objects.hash( unionMember0, unionMember1, - unionMember2, + type, unionMember3, unionMember4, unionMember5, @@ -268,7 +241,7 @@ private constructor( when { unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" - unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" + type != null -> "ElementalNode{type=$type}" unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" @@ -286,20 +259,7 @@ private constructor( @JvmStatic fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) - /** - * The channel element allows a notification to be customized based on which channel it is - * sent through. For example, you may want to display a detailed message when the - * notification is sent through email, and a more concise message in a push notification. - * Channel elements are only valid as top-level elements; you cannot nest channel elements. - * If there is a channel element specified at the top-level of the document, all sibling - * elements must be channel elements. Note: As an alternative, most elements support a - * `channel` property. Which allows you to selectively display an individual element on a - * per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) + @JvmStatic fun ofType(type: Type) = ElementalNode(type = type) @JvmStatic fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) @@ -332,19 +292,7 @@ private constructor( fun visitUnionMember1(unionMember1: UnionMember1): T - /** - * The channel element allows a notification to be customized based on which channel it is - * sent through. For example, you may want to display a detailed message when the - * notification is sent through email, and a more concise message in a push notification. - * Channel elements are only valid as top-level elements; you cannot nest channel elements. - * If there is a channel element specified at the top-level of the document, all sibling - * elements must be channel elements. Note: As an alternative, most elements support a - * `channel` property. Which allows you to selectively display an individual element on a - * per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun visitUnionMember2(unionMember2: UnionMember2): T + fun visitType(type: Type): T fun visitUnionMember3(unionMember3: UnionMember3): T @@ -389,8 +337,8 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { ElementalNode(unionMember1 = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember2 = it, _json = json) + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(type = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { ElementalNode(unionMember3 = it, _json = json) @@ -433,7 +381,7 @@ private constructor( when { value.unionMember0 != null -> generator.writeObject(value.unionMember0) value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.type != null -> generator.writeObject(value.type) value.unionMember3 != null -> generator.writeObject(value.unionMember3) value.unionMember4 != null -> generator.writeObject(value.unionMember4) value.unionMember5 != null -> generator.writeObject(value.unionMember5) @@ -1295,176 +1243,30 @@ private constructor( "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" } - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - class UnionMember2 + class Type @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val channel: JsonField, - private val channels: JsonField>, - private val elements: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val raw: JsonField, - private val ref: JsonField, - private val type: JsonField, + private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("raw") - @ExcludeMissing - raw: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channel, channels, elements, if_, loop, raw, ref, type, mutableMapOf()) - - fun toElementalChannelNode(): ElementalChannelNode = - ElementalChannelNode.builder() - .channel(channel) - .channels(channels) - .elements(elements) - .if_(if_) - .loop(loop) - .raw(raw) - .ref(ref) - .build() + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` - * is `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun elements(): Optional> = elements.getOptional("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun raw(): Optional = raw.getOptional("raw") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [raw]. - * - * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + fun type(): InnerType = type.getRequired("type") /** * Returns the raw JSON value of [type]. * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -1481,219 +1283,38 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnionMember2]. + * Returns a mutable builder for constructing an instance of [Type]. * * The following fields are required: * ```java - * .channel() + * .type() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnionMember2]. */ + /** A builder for [Type]. */ class Builder internal constructor() { - private var channel: JsonField? = null - private var channels: JsonField>? = null - private var elements: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var raw: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - channel = unionMember2.channel - channels = unionMember2.channels.map { it.toMutableList() } - elements = unionMember2.elements.map { it.toMutableList() } - if_ = unionMember2.if_ - loop = unionMember2.loop - raw = unionMember2.raw - ref = unionMember2.ref - type = unionMember2.type - additionalProperties = unionMember2.additionalProperties.toMutableMap() + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties = type.additionalProperties.toMutableMap() } - /** - * The channel the contents of this element should be applied to. Can be `email`, - * `push`, `direct_message`, `sms` or a provider such as slack - */ - fun channel(channel: String) = channel(JsonField.of(channel)) + fun type(type: InnerType) = type(JsonField.of(type)) /** - * Sets [Builder.channel] to an arbitrary JSON value. + * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.channel] with a well-typed [String] value instead. + * You should usually call [Builder.type] with a well-typed [InnerType] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, - * `elements` is `required`. - */ - fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) - - /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ - fun elements(elements: Optional>) = elements(elements.getOrNull()) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - */ - fun raw(raw: ElementalChannelNode.Raw?) = raw(JsonField.ofNullable(raw)) - - /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ - fun raw(raw: Optional) = raw(raw.getOrNull()) - - /** - * Sets [Builder.raw] to an arbitrary JSON value. - * - * You should usually call [Builder.raw] with a well-typed [ElementalChannelNode.Raw] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun raw(raw: JsonField) = apply { this.raw = raw } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1715,46 +1336,29 @@ private constructor( } /** - * Returns an immutable instance of [UnionMember2]. + * Returns an immutable instance of [Type]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .channel() + * .type() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnionMember2 = - UnionMember2( - checkRequired("channel", channel), - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - (elements ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - raw, - ref, - type, - additionalProperties.toMutableMap(), - ) + fun build(): Type = + Type(checkRequired("type", type), additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): UnionMember2 = apply { + fun validate(): Type = apply { if (validated) { return@apply } - channel() - channels() - elements().ifPresent { it.forEach { it.validate() } } - if_() - loop() - raw().ifPresent { it.validate() } - ref() - type().ifPresent { it.validate() } + type().validate() validated = true } @@ -1772,18 +1376,10 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (raw.asKnown().getOrNull()?.validity() ?: 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + class InnerType @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -1799,18 +1395,18 @@ private constructor( @JvmField val CHANNEL = of("channel") - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) } - /** An enum containing [Type]'s known values. */ + /** An enum containing [InnerType]'s known values. */ enum class Known { CHANNEL } /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Type] can contain an unknown value in a couple of cases: + * An instance of [InnerType] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, if * the SDK is on an older version than the API, then the API may respond with new * members that the SDK is unaware of. @@ -1818,7 +1414,10 @@ private constructor( */ enum class Value { CHANNEL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ + /** + * An enum member indicating that [InnerType] was instantiated with an unknown + * value. + */ _UNKNOWN, } @@ -1847,7 +1446,7 @@ private constructor( fun known(): Known = when (this) { CHANNEL -> Known.CHANNEL - else -> throw CourierInvalidDataException("Unknown Type: $value") + else -> throw CourierInvalidDataException("Unknown InnerType: $value") } /** @@ -1866,7 +1465,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Type = apply { + fun validate(): InnerType = apply { if (validated) { return@apply } @@ -1896,7 +1495,7 @@ private constructor( return true } - return other is Type && value == other.value + return other is InnerType && value == other.value } override fun hashCode() = value.hashCode() @@ -1909,36 +1508,16 @@ private constructor( return true } - return other is UnionMember2 && - channel == other.channel && - channels == other.channels && - elements == other.elements && - if_ == other.if_ && - loop == other.loop && - raw == other.raw && - ref == other.ref && + return other is Type && type == other.type && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash( - channel, - channels, - elements, - if_, - loop, - raw, - ref, - type, - additionalProperties, - ) - } + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "UnionMember2{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" } class UnionMember3 @@ -3422,9 +3001,8 @@ private constructor( fun addElement(unionMember1: UnionMember1) = addElement(ElementalNode.ofUnionMember1(unionMember1)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) + /** Alias for calling [addElement] with `ElementalNode.ofType(type)`. */ + fun addElement(type: Type) = addElement(ElementalNode.ofType(type)) /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ fun addElement(unionMember3: UnionMember3) = diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt deleted file mode 100644 index 4587d04e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalChannelNodeTest { - - @Test - fun create() { - val elementalChannelNode = - ElementalChannelNode.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .build() - - assertThat(elementalChannelNode.channel()).isEqualTo("channel") - assertThat(elementalChannelNode.channels().getOrNull()).containsExactly("string") - assertThat(elementalChannelNode.elements().getOrNull()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalChannelNode.if_()).contains("if") - assertThat(elementalChannelNode.loop()).contains("loop") - assertThat(elementalChannelNode.raw()) - .contains( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(elementalChannelNode.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalChannelNode = - ElementalChannelNode.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .build() - - val roundtrippedElementalChannelNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalChannelNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalChannelNode).isEqualTo(elementalChannelNode) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt index df5c7d9d..dac763a8 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt @@ -29,7 +29,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).contains(unionMember0) assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).isEmpty @@ -75,7 +75,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).contains(unionMember1) - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).isEmpty @@ -107,36 +107,14 @@ internal class ElementalNodeTest { } @Test - fun ofUnionMember2() { - val unionMember2 = - ElementalNode.UnionMember2.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .type(ElementalNode.UnionMember2.Type.CHANNEL) - .build() + fun ofType() { + val type = ElementalNode.Type.builder().type(ElementalNode.Type.InnerType.CHANNEL).build() - val elementalNode = ElementalNode.ofUnionMember2(unionMember2) + val elementalNode = ElementalNode.ofType(type) assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).contains(unionMember2) + assertThat(elementalNode.type()).contains(type) assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).isEmpty @@ -145,32 +123,11 @@ internal class ElementalNodeTest { } @Test - fun ofUnionMember2Roundtrip() { + fun ofTypeRoundtrip() { val jsonMapper = jsonMapper() val elementalNode = - ElementalNode.ofUnionMember2( - ElementalNode.UnionMember2.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .type(ElementalNode.UnionMember2.Type.CHANNEL) - .build() + ElementalNode.ofType( + ElementalNode.Type.builder().type(ElementalNode.Type.InnerType.CHANNEL).build() ) val roundtrippedElementalNode = @@ -197,7 +154,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).contains(unionMember3) assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).isEmpty @@ -243,7 +200,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).contains(unionMember4) assertThat(elementalNode.unionMember5()).isEmpty @@ -289,7 +246,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).contains(unionMember5) @@ -344,7 +301,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).isEmpty @@ -399,7 +356,7 @@ internal class ElementalNodeTest { assertThat(elementalNode.unionMember0()).isEmpty assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.type()).isEmpty assertThat(elementalNode.unionMember3()).isEmpty assertThat(elementalNode.unionMember4()).isEmpty assertThat(elementalNode.unionMember5()).isEmpty From 5c5e61819a03f950fc01468e21f1aa58b3f9a49a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 22:17:37 +0000 Subject: [PATCH 15/33] feat(api): manual updates Commented out circular elements --- .stats.yml | 6 +- .../com/courier/api/models/send/Content.kt | 3000 ++++++++++++- .../api/models/send/ElementalGroupNode.kt | 384 -- .../courier/api/models/send/ElementalNode.kt | 3760 ----------------- .../courier/api/models/send/ContentTest.kt | 8 +- .../api/models/send/ElementalGroupNodeTest.kt | 78 - .../api/models/send/ElementalNodeTest.kt | 407 -- .../courier/api/models/send/MessageTest.kt | 8 +- .../api/models/send/SendMessageParamsTest.kt | 24 +- .../courier/api/services/ErrorHandlingTest.kt | 137 +- .../courier/api/services/ServiceParamsTest.kt | 7 +- .../services/async/SendServiceAsyncTest.kt | 8 +- .../api/services/blocking/SendServiceTest.kt | 8 +- .../api/proguard/ProGuardCompatibilityTest.kt | 5 +- 14 files changed, 3108 insertions(+), 4732 deletions(-) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt diff --git a/.stats.yml b/.stats.yml index 23f20807..9b3d648e 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-ebaec6ae38b7c903923797cc52f2ca25842ead289d62de22dd5ed527d8e8e994.yml -openapi_spec_hash: a29421ec84cecc5d172f5a41e29d9d6a -config_hash: 5d1f1698a0d16c5edb2c695dd127b335 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-b84818fa607269611adaa248025376e56ab1e7549ebc22b6729350916c4482f7.yml +openapi_spec_hash: 1a0cfa85d6efc14912ff791420c6ba7c +config_hash: 456d0fb8f37050fdcc150cfd504433d4 diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt index b43ce5b2..bff90392 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -4,6 +4,7 @@ package com.courier.api.models.send import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing @@ -217,7 +218,7 @@ private constructor( class ElementalContent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val elements: JsonField>, + private val elements: JsonField>, private val version: JsonField, private val brand: JsonValue, private val additionalProperties: MutableMap, @@ -227,7 +228,7 @@ private constructor( private constructor( @JsonProperty("elements") @ExcludeMissing - elements: JsonField> = JsonMissing.of(), + elements: JsonField> = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), ) : this(elements, version, brand, mutableMapOf()) @@ -236,7 +237,7 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun elements(): List = elements.getRequired("elements") + fun elements(): List = elements.getRequired("elements") /** * For example, "2022-01-01" @@ -255,7 +256,7 @@ private constructor( */ @JsonProperty("elements") @ExcludeMissing - fun _elements(): JsonField> = elements + fun _elements(): JsonField> = elements /** * Returns the raw JSON value of [version]. @@ -293,7 +294,7 @@ private constructor( /** A builder for [ElementalContent]. */ class Builder internal constructor() { - private var elements: JsonField>? = null + private var elements: JsonField>? = null private var version: JsonField? = null private var brand: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -306,61 +307,54 @@ private constructor( additionalProperties = elementalContent.additionalProperties.toMutableMap() } - fun elements(elements: List) = elements(JsonField.of(elements)) + fun elements(elements: List) = elements(JsonField.of(elements)) /** * Sets [Builder.elements] to an arbitrary JSON value. * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun elements(elements: JsonField>) = apply { + fun elements(elements: JsonField>) = apply { this.elements = elements.map { it.toMutableList() } } /** - * Adds a single [ElementalNode] to [elements]. + * Adds a single [Element] to [elements]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addElement(element: ElementalNode) = apply { + fun addElement(element: Element) = apply { elements = (elements ?: JsonField.of(mutableListOf())).also { checkKnown("elements", it).add(element) } } - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) + /** Alias for calling [addElement] with `Element.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: Element.UnionMember0) = + addElement(Element.ofUnionMember0(unionMember0)) - /** Alias for calling [addElement] with `ElementalNode.ofType(type)`. */ - fun addElement(type: ElementalNode.Type) = addElement(ElementalNode.ofType(type)) + /** Alias for calling [addElement] with `Element.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: Element.UnionMember1) = + addElement(Element.ofUnionMember1(unionMember1)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) + /** Alias for calling [addElement] with `Element.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: Element.UnionMember2) = + addElement(Element.ofUnionMember2(unionMember2)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) + /** Alias for calling [addElement] with `Element.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: Element.UnionMember3) = + addElement(Element.ofUnionMember3(unionMember3)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) + /** Alias for calling [addElement] with `Element.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: Element.UnionMember4) = + addElement(Element.ofUnionMember4(unionMember4)) - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) + /** Alias for calling [addElement] with `Element.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: Element.UnionMember5) = + addElement(Element.ofUnionMember5(unionMember5)) /** For example, "2022-01-01" */ fun version(version: String) = version(JsonField.of(version)) @@ -448,6 +442,2938 @@ private constructor( (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (version.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Element.Deserializer::class) + @JsonSerialize(using = Element.Serializer::class) + class Element + private constructor( + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val unionMember3: UnionMember3? = null, + private val unionMember4: UnionMember4? = null, + private val unionMember5: UnionMember5? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun unionMember4(): Optional = Optional.ofNullable(unionMember4) + + fun unionMember5(): Optional = Optional.ofNullable(unionMember5) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUnionMember3(): Boolean = unionMember3 != null + + fun isUnionMember4(): Boolean = unionMember4 != null + + fun isUnionMember5(): Boolean = unionMember5 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") + + fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) + unionMember4 != null -> visitor.visitUnionMember4(unionMember4) + unionMember5 != null -> visitor.visitUnionMember5(unionMember5) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Element = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } + + override fun visitUnionMember4(unionMember4: UnionMember4) { + unionMember4.validate() + } + + override fun visitUnionMember5(unionMember5: UnionMember5) { + unionMember5.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = + unionMember2.validity() + + override fun visitUnionMember3(unionMember3: UnionMember3) = + unionMember3.validity() + + override fun visitUnionMember4(unionMember4: UnionMember4) = + unionMember4.validity() + + override fun visitUnionMember5(unionMember5: UnionMember5) = + unionMember5.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Element && + unionMember0 == other.unionMember0 && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + unionMember3 == other.unionMember3 && + unionMember4 == other.unionMember4 && + unionMember5 == other.unionMember5 + } + + override fun hashCode(): Int = + Objects.hash( + unionMember0, + unionMember1, + unionMember2, + unionMember3, + unionMember4, + unionMember5, + ) + + override fun toString(): String = + when { + unionMember0 != null -> "Element{unionMember0=$unionMember0}" + unionMember1 != null -> "Element{unionMember1=$unionMember1}" + unionMember2 != null -> "Element{unionMember2=$unionMember2}" + unionMember3 != null -> "Element{unionMember3=$unionMember3}" + unionMember4 != null -> "Element{unionMember4=$unionMember4}" + unionMember5 != null -> "Element{unionMember5=$unionMember5}" + _json != null -> "Element{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Element") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + Element(unionMember0 = unionMember0) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + Element(unionMember1 = unionMember1) + + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = + Element(unionMember2 = unionMember2) + + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = + Element(unionMember3 = unionMember3) + + @JvmStatic + fun ofUnionMember4(unionMember4: UnionMember4) = + Element(unionMember4 = unionMember4) + + @JvmStatic + fun ofUnionMember5(unionMember5: UnionMember5) = + Element(unionMember5 = unionMember5) + } + + /** + * An interface that defines how to map each variant of [Element] to a value of type + * [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUnionMember3(unionMember3: UnionMember3): T + + fun visitUnionMember4(unionMember4: UnionMember4): T + + fun visitUnionMember5(unionMember5: UnionMember5): T + + /** + * Maps an unknown variant of [Element] to a value of type [T]. + * + * An instance of [Element] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Element: $json") + } + } + + internal class Deserializer : BaseDeserializer(Element::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Element { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember4 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember5 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Element(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Element::class) { + + override fun serialize( + value: Element, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) + value.unionMember4 != null -> generator.writeObject(value.unionMember4) + value.unionMember5 != null -> generator.writeObject(value.unionMember5) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Element") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + channels = unionMember0.channels.map { it.toMutableList() } + if_ = unionMember0.if_ + loop = unionMember0.loop + ref = unionMember0.ref + type = unionMember0.type + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + channels = unionMember1.channels.map { it.toMutableList() } + if_ = unionMember1.if_ + loop = unionMember1.loop + ref = unionMember1.ref + type = unionMember1.type + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val META = of("meta") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + META + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + META, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + META -> Value.META + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + META -> Known.META + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + channels = unionMember2.channels.map { it.toMutableList() } + if_ = unionMember2.if_ + loop = unionMember2.loop + ref = unionMember2.ref + type = unionMember2.type + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = + UnionMember2( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IMAGE, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IMAGE -> Value.IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + IMAGE -> Known.IMAGE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + channels = unionMember3.channels.map { it.toMutableList() } + if_ = unionMember3.if_ + loop = unionMember3.loop + ref = unionMember3.ref + type = unionMember3.type + additionalProperties = unionMember3.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = + UnionMember3( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ACTION = of("action") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACTION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTION, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTION -> Value.ACTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACTION -> Known.ACTION + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember4 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember4]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember4: UnionMember4) = apply { + channels = unionMember4.channels.map { it.toMutableList() } + if_ = unionMember4.if_ + loop = unionMember4.loop + ref = unionMember4.ref + type = unionMember4.type + additionalProperties = unionMember4.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember4]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember4 = + UnionMember4( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember4 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val DIVIDER = of("divider") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIVIDER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDER, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDER -> Value.DIVIDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DIVIDER -> Known.DIVIDER + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember4 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember5 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember5]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember5: UnionMember5) = apply { + channels = unionMember5.channels.map { it.toMutableList() } + if_ = unionMember5.if_ + loop = unionMember5.loop + ref = unionMember5.ref + type = unionMember5.type + additionalProperties = unionMember5.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember5]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember5 = + UnionMember5( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember5 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val QUOTE = of("quote") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + QUOTE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + QUOTE, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUOTE -> Value.QUOTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + QUOTE -> Known.QUOTE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember5 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt deleted file mode 100644 index 7c229219..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt +++ /dev/null @@ -1,384 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ElementalGroupNode -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val elements: JsonField>, - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(elements, channels, if_, loop, ref, mutableMapOf()) - - /** - * Sub elements to render. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalGroupNode]. - * - * The following fields are required: - * ```java - * .elements() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalGroupNode]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalGroupNode: ElementalGroupNode) = apply { - elements = elementalGroupNode.elements.map { it.toMutableList() } - channels = elementalGroupNode.channels.map { it.toMutableList() } - if_ = elementalGroupNode.if_ - loop = elementalGroupNode.loop - ref = elementalGroupNode.ref - additionalProperties = elementalGroupNode.additionalProperties.toMutableMap() - } - - /** Sub elements to render. */ - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofType(type)`. */ - fun addElement(type: ElementalNode.Type) = addElement(ElementalNode.ofType(type)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalGroupNode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalGroupNode = - ElementalGroupNode( - checkRequired("elements", elements).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalGroupNode = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - channels() - if_() - loop() - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalGroupNode && - elements == other.elements && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, channels, if_, loop, ref, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalGroupNode{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt deleted file mode 100644 index 4b6eada5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt +++ /dev/null @@ -1,3760 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Allows you to group elements together. This can be useful when used in combination with "if" or - * "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for - * more details. - */ -@JsonDeserialize(using = ElementalNode.Deserializer::class) -@JsonSerialize(using = ElementalNode.Serializer::class) -class ElementalNode -private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val type: Type? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val unionMember6: UnionMember6? = null, - private val unionMember7: UnionMember7? = null, - private val _json: JsonValue? = null, -) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun type(): Optional = Optional.ofNullable(type) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun unionMember6(): Optional = Optional.ofNullable(unionMember6) - - fun unionMember7(): Optional = Optional.ofNullable(unionMember7) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isType(): Boolean = type != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun isUnionMember5(): Boolean = unionMember5 != null - - fun isUnionMember6(): Boolean = unionMember6 != null - - fun isUnionMember7(): Boolean = unionMember7 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asType(): Type = type.getOrThrow("type") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") - - fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - type != null -> visitor.visitType(type) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - unionMember6 != null -> visitor.visitUnionMember6(unionMember6) - unionMember7 != null -> visitor.visitUnionMember7(unionMember7) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ElementalNode = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } - - override fun visitType(type: Type) { - type.validate() - } - - override fun visitUnionMember3(unionMember3: UnionMember3) { - unionMember3.validate() - } - - override fun visitUnionMember4(unionMember4: UnionMember4) { - unionMember4.validate() - } - - override fun visitUnionMember5(unionMember5: UnionMember5) { - unionMember5.validate() - } - - override fun visitUnionMember6(unionMember6: UnionMember6) { - unionMember6.validate() - } - - override fun visitUnionMember7(unionMember7: UnionMember7) { - unionMember7.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - - override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() - - override fun visitType(type: Type) = type.validity() - - override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() - - override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() - - override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() - - override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() - - override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalNode && - unionMember0 == other.unionMember0 && - unionMember1 == other.unionMember1 && - type == other.type && - unionMember3 == other.unionMember3 && - unionMember4 == other.unionMember4 && - unionMember5 == other.unionMember5 && - unionMember6 == other.unionMember6 && - unionMember7 == other.unionMember7 - } - - override fun hashCode(): Int = - Objects.hash( - unionMember0, - unionMember1, - type, - unionMember3, - unionMember4, - unionMember5, - unionMember6, - unionMember7, - ) - - override fun toString(): String = - when { - unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" - unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" - type != null -> "ElementalNode{type=$type}" - unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" - unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" - unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" - unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" - unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" - _json != null -> "ElementalNode{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ElementalNode") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) - - @JvmStatic fun ofType(type: Type) = ElementalNode(type = type) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) - - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) - - /** - * Allows you to group elements together. This can be useful when used in combination with - * "if" or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - @JvmStatic - fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) - - @JvmStatic - fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) - } - - /** - * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. - */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitType(type: Type): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun visitUnionMember5(unionMember5: UnionMember5): T - - /** - * Allows you to group elements together. This can be useful when used in combination with - * "if" or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun visitUnionMember6(unionMember6: UnionMember6): T - - fun visitUnionMember7(unionMember7: UnionMember7): T - - /** - * Maps an unknown variant of [ElementalNode] to a value of type [T]. - * - * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown ElementalNode: $json") - } - } - - internal class Deserializer : BaseDeserializer(ElementalNode::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(type = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember4 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember5 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember6 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember7 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> ElementalNode(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ElementalNode::class) { - - override fun serialize( - value: ElementalNode, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.type != null -> generator.writeObject(value.type) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value.unionMember6 != null -> generator.writeObject(value.unionMember6) - value.unionMember7 != null -> generator.writeObject(value.unionMember7) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ElementalNode") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - channels = unionMember0.channels.map { it.toMutableList() } - if_ = unionMember0.if_ - loop = unionMember0.loop - ref = unionMember0.ref - type = unionMember0.type - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember0 = - UnionMember0( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TEXT = of("text") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TEXT - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TEXT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - channels = unionMember1.channels.map { it.toMutableList() } - if_ = unionMember1.if_ - loop = unionMember1.loop - ref = unionMember1.ref - type = unionMember1.type - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val META = of("meta") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - META - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - META, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - META -> Value.META - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - META -> Known.META - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class Type - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of() - ) : this(type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): InnerType = type.getRequired("type") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Type]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Type]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties = type.additionalProperties.toMutableMap() - } - - fun type(type: InnerType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [InnerType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Type]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Type = - Type(checkRequired("type", type), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - type().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) - - class InnerType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHANNEL = of("channel") - - @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) - } - - /** An enum containing [InnerType]'s known values. */ - enum class Known { - CHANNEL - } - - /** - * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [InnerType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHANNEL, - /** - * An enum member indicating that [InnerType] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHANNEL -> Value.CHANNEL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CHANNEL -> Known.CHANNEL - else -> throw CourierInvalidDataException("Unknown InnerType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): InnerType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InnerType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Type{type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember3 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember3]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - channels = unionMember3.channels.map { it.toMutableList() } - if_ = unionMember3.if_ - loop = unionMember3.loop - ref = unionMember3.ref - type = unionMember3.type - additionalProperties = unionMember3.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember3]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember3 = - UnionMember3( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember3 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val IMAGE = of("image") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMAGE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IMAGE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IMAGE -> Value.IMAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IMAGE -> Known.IMAGE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember4 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember4]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - channels = unionMember4.channels.map { it.toMutableList() } - if_ = unionMember4.if_ - loop = unionMember4.loop - ref = unionMember4.ref - type = unionMember4.type - additionalProperties = unionMember4.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember4]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember4 = - UnionMember4( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember4 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTION = of("action") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ACTION - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTION -> Value.ACTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTION -> Known.ACTION - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember5 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember5]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - channels = unionMember5.channels.map { it.toMutableList() } - if_ = unionMember5.if_ - loop = unionMember5.loop - ref = unionMember5.ref - type = unionMember5.type - additionalProperties = unionMember5.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember5]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember5 = - UnionMember5( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember5 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DIVIDER = of("divider") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - DIVIDER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDER -> Value.DIVIDER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DIVIDER -> Known.DIVIDER - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember5 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - class UnionMember6 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val elements: JsonField>, - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(elements, channels, if_, loop, ref, type, mutableMapOf()) - - fun toElementalGroupNode(): ElementalGroupNode = - ElementalGroupNode.builder() - .elements(elements) - .channels(channels) - .if_(if_) - .loop(loop) - .ref(ref) - .build() - - /** - * Sub elements to render. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember6]. - * - * The following fields are required: - * ```java - * .elements() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember6]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember6: UnionMember6) = apply { - elements = unionMember6.elements.map { it.toMutableList() } - channels = unionMember6.channels.map { it.toMutableList() } - if_ = unionMember6.if_ - loop = unionMember6.loop - ref = unionMember6.ref - type = unionMember6.type - additionalProperties = unionMember6.additionalProperties.toMutableMap() - } - - /** Sub elements to render. */ - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofType(type)`. */ - fun addElement(type: Type) = addElement(ElementalNode.ofType(type)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember6]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember6 = - UnionMember6( - checkRequired("elements", elements).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember6 = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUP = of("group") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GROUP - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUP, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUP -> Value.GROUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUP -> Known.GROUP - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember6 && - elements == other.elements && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember6{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember7 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember7]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember7: UnionMember7) = apply { - channels = unionMember7.channels.map { it.toMutableList() } - if_ = unionMember7.if_ - loop = unionMember7.loop - ref = unionMember7.ref - type = unionMember7.type - additionalProperties = unionMember7.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember7]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember7 = - UnionMember7( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember7 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUOTE = of("quote") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - QUOTE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - QUOTE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - QUOTE -> Value.QUOTE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - QUOTE -> Known.QUOTE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember7 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt index 37c66cfa..698992ba 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt @@ -19,12 +19,12 @@ internal class ContentTest { val elemental = Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -44,12 +44,12 @@ internal class ContentTest { Content.ofElemental( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt deleted file mode 100644 index bf51afd4..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalGroupNodeTest { - - @Test - fun create() { - val elementalGroupNode = - ElementalGroupNode.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .build() - - assertThat(elementalGroupNode.elements()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalGroupNode.channels().getOrNull()).containsExactly("string") - assertThat(elementalGroupNode.if_()).contains("if") - assertThat(elementalGroupNode.loop()).contains("loop") - assertThat(elementalGroupNode.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalGroupNode = - ElementalGroupNode.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .build() - - val roundtrippedElementalGroupNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalGroupNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalGroupNode).isEqualTo(elementalGroupNode) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt deleted file mode 100644 index dac763a8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt +++ /dev/null @@ -1,407 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class ElementalNodeTest { - - @Test - fun ofUnionMember0() { - val unionMember0 = - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - - val elementalNode = ElementalNode.ofUnionMember0(unionMember0) - - assertThat(elementalNode.unionMember0()).contains(unionMember0) - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember0Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember1() { - val unionMember1 = - ElementalNode.UnionMember1.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember1.Type.META) - .build() - - val elementalNode = ElementalNode.ofUnionMember1(unionMember1) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).contains(unionMember1) - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember1Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember1( - ElementalNode.UnionMember1.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember1.Type.META) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofType() { - val type = ElementalNode.Type.builder().type(ElementalNode.Type.InnerType.CHANNEL).build() - - val elementalNode = ElementalNode.ofType(type) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).contains(type) - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofTypeRoundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofType( - ElementalNode.Type.builder().type(ElementalNode.Type.InnerType.CHANNEL).build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember3() { - val unionMember3 = - ElementalNode.UnionMember3.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember3.Type.IMAGE) - .build() - - val elementalNode = ElementalNode.ofUnionMember3(unionMember3) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).contains(unionMember3) - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember3Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember3( - ElementalNode.UnionMember3.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember3.Type.IMAGE) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember4() { - val unionMember4 = - ElementalNode.UnionMember4.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember4.Type.ACTION) - .build() - - val elementalNode = ElementalNode.ofUnionMember4(unionMember4) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).contains(unionMember4) - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember4Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember4( - ElementalNode.UnionMember4.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember4.Type.ACTION) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember5() { - val unionMember5 = - ElementalNode.UnionMember5.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember5.Type.DIVIDER) - .build() - - val elementalNode = ElementalNode.ofUnionMember5(unionMember5) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).contains(unionMember5) - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember5Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember5( - ElementalNode.UnionMember5.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember5.Type.DIVIDER) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember6() { - val unionMember6 = - ElementalNode.UnionMember6.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember6.Type.GROUP) - .build() - - val elementalNode = ElementalNode.ofUnionMember6(unionMember6) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).contains(unionMember6) - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember6Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember6( - ElementalNode.UnionMember6.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember6.Type.GROUP) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember7() { - val unionMember7 = - ElementalNode.UnionMember7.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember7.Type.QUOTE) - .build() - - val elementalNode = ElementalNode.ofUnionMember7(unionMember7) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.type()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).contains(unionMember7) - } - - @Test - fun ofUnionMember7Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember7( - ElementalNode.UnionMember7.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember7.Type.QUOTE) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val elementalNode = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { elementalNode.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt index cfd8399f..74630fb4 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt @@ -186,12 +186,12 @@ internal class MessageTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -387,12 +387,12 @@ internal class MessageTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index 09280c1e..33c061a9 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -188,12 +188,12 @@ internal class SendMessageParamsTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -389,12 +389,14 @@ internal class SendMessageParamsTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0.Type.TEXT + ) .build() ) .version("version") @@ -589,12 +591,14 @@ internal class SendMessageParamsTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0.Type.TEXT + ) .build() ) .version("version") @@ -614,7 +618,9 @@ internal class SendMessageParamsTest { Message.ContentMessage.builder() .content( Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) + .addElement( + Content.ElementalContent.Element.UnionMember0.builder().build() + ) .version("version") .build() ) @@ -630,7 +636,9 @@ internal class SendMessageParamsTest { Message.ContentMessage.builder() .content( Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) + .addElement( + Content.ElementalContent.Element.UnionMember0.builder().build() + ) .version("version") .build() ) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index 1926589d..a568d663 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -19,7 +19,6 @@ import com.courier.api.errors.UnprocessableEntityException import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -275,12 +274,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -507,12 +510,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -739,12 +746,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -971,12 +982,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -1203,12 +1218,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -1435,12 +1454,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -1667,12 +1690,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -1899,12 +1926,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -2131,12 +2162,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -2363,12 +2398,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -2595,12 +2634,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -2827,12 +2870,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -3059,12 +3106,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -3291,12 +3342,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -3523,12 +3578,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -3755,12 +3814,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") @@ -3985,12 +4048,16 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0 + .Type + .TEXT + ) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index cbd00c20..a8bd356b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -8,7 +8,6 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -232,12 +231,14 @@ internal class ServiceParamsTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0.Type.TEXT + ) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 17ca5300..e8201459 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -8,7 +8,6 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -221,12 +220,15 @@ internal class SendServiceAsyncTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0.Type + .TEXT + ) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index 86d83405..f0675180 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -8,7 +8,6 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -221,12 +220,15 @@ internal class SendServiceTest { .content( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type( + Content.ElementalContent.Element.UnionMember0.Type + .TEXT + ) .build() ) .version("version") diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt index 40930df0..cecefd3f 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -7,7 +7,6 @@ import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod import com.courier.api.models.send.Utm @@ -240,12 +239,12 @@ internal class ProGuardCompatibilityTest { Content.ofElemental( Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") From 33a23f3e6c64100af51e328215bc7d2a93fef331 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 22:39:43 +0000 Subject: [PATCH 16/33] feat(api): manual updates Uncommented node --- .stats.yml | 6 +- .../com/courier/api/models/send/Content.kt | 3001 +----------- .../api/models/send/ElementalChannelNode.kt | 572 +++ .../api/models/send/ElementalGroupNode.kt | 385 ++ .../courier/api/models/send/ElementalNode.kt | 4182 +++++++++++++++++ .../courier/api/models/send/ContentTest.kt | 8 +- .../models/send/ElementalChannelNodeTest.kt | 98 + .../api/models/send/ElementalGroupNodeTest.kt | 78 + .../api/models/send/ElementalNodeTest.kt | 450 ++ .../courier/api/models/send/MessageTest.kt | 8 +- .../api/models/send/SendMessageParamsTest.kt | 24 +- .../courier/api/services/ErrorHandlingTest.kt | 137 +- .../courier/api/services/ServiceParamsTest.kt | 7 +- .../services/async/SendServiceAsyncTest.kt | 8 +- .../api/services/blocking/SendServiceTest.kt | 8 +- .../api/proguard/ProGuardCompatibilityTest.kt | 5 +- 16 files changed, 5869 insertions(+), 3108 deletions(-) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt diff --git a/.stats.yml b/.stats.yml index 9b3d648e..a4f42243 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 75 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-b84818fa607269611adaa248025376e56ab1e7549ebc22b6729350916c4482f7.yml -openapi_spec_hash: 1a0cfa85d6efc14912ff791420c6ba7c -config_hash: 456d0fb8f37050fdcc150cfd504433d4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml +openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 +config_hash: 5d1f1698a0d16c5edb2c695dd127b335 diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt index bff90392..b1857ad5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -4,7 +4,6 @@ package com.courier.api.models.send import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing @@ -218,7 +217,7 @@ private constructor( class ElementalContent @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val elements: JsonField>, + private val elements: JsonField>, private val version: JsonField, private val brand: JsonValue, private val additionalProperties: MutableMap, @@ -228,7 +227,7 @@ private constructor( private constructor( @JsonProperty("elements") @ExcludeMissing - elements: JsonField> = JsonMissing.of(), + elements: JsonField> = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), ) : this(elements, version, brand, mutableMapOf()) @@ -237,7 +236,7 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun elements(): List = elements.getRequired("elements") + fun elements(): List = elements.getRequired("elements") /** * For example, "2022-01-01" @@ -256,7 +255,7 @@ private constructor( */ @JsonProperty("elements") @ExcludeMissing - fun _elements(): JsonField> = elements + fun _elements(): JsonField> = elements /** * Returns the raw JSON value of [version]. @@ -294,7 +293,7 @@ private constructor( /** A builder for [ElementalContent]. */ class Builder internal constructor() { - private var elements: JsonField>? = null + private var elements: JsonField>? = null private var version: JsonField? = null private var brand: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -307,54 +306,62 @@ private constructor( additionalProperties = elementalContent.additionalProperties.toMutableMap() } - fun elements(elements: List) = elements(JsonField.of(elements)) + fun elements(elements: List) = elements(JsonField.of(elements)) /** * Sets [Builder.elements] to an arbitrary JSON value. * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun elements(elements: JsonField>) = apply { + fun elements(elements: JsonField>) = apply { this.elements = elements.map { it.toMutableList() } } /** - * Adds a single [Element] to [elements]. + * Adds a single [ElementalNode] to [elements]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addElement(element: Element) = apply { + fun addElement(element: ElementalNode) = apply { elements = (elements ?: JsonField.of(mutableListOf())).also { checkKnown("elements", it).add(element) } } - /** Alias for calling [addElement] with `Element.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: Element.UnionMember0) = - addElement(Element.ofUnionMember0(unionMember0)) + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) - /** Alias for calling [addElement] with `Element.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: Element.UnionMember1) = - addElement(Element.ofUnionMember1(unionMember1)) + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) - /** Alias for calling [addElement] with `Element.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: Element.UnionMember2) = - addElement(Element.ofUnionMember2(unionMember2)) + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) - /** Alias for calling [addElement] with `Element.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: Element.UnionMember3) = - addElement(Element.ofUnionMember3(unionMember3)) + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) - /** Alias for calling [addElement] with `Element.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: Element.UnionMember4) = - addElement(Element.ofUnionMember4(unionMember4)) + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) - /** Alias for calling [addElement] with `Element.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: Element.UnionMember5) = - addElement(Element.ofUnionMember5(unionMember5)) + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) /** For example, "2022-01-01" */ fun version(version: String) = version(JsonField.of(version)) @@ -442,2938 +449,6 @@ private constructor( (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (version.asKnown().isPresent) 1 else 0) - @JsonDeserialize(using = Element.Deserializer::class) - @JsonSerialize(using = Element.Serializer::class) - class Element - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val _json: JsonValue? = null, - ) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun isUnionMember5(): Boolean = unionMember5 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Element = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } - - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() - } - - override fun visitUnionMember3(unionMember3: UnionMember3) { - unionMember3.validate() - } - - override fun visitUnionMember4(unionMember4: UnionMember4) { - unionMember4.validate() - } - - override fun visitUnionMember5(unionMember5: UnionMember5) { - unionMember5.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() - - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() - - override fun visitUnionMember2(unionMember2: UnionMember2) = - unionMember2.validity() - - override fun visitUnionMember3(unionMember3: UnionMember3) = - unionMember3.validity() - - override fun visitUnionMember4(unionMember4: UnionMember4) = - unionMember4.validity() - - override fun visitUnionMember5(unionMember5: UnionMember5) = - unionMember5.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Element && - unionMember0 == other.unionMember0 && - unionMember1 == other.unionMember1 && - unionMember2 == other.unionMember2 && - unionMember3 == other.unionMember3 && - unionMember4 == other.unionMember4 && - unionMember5 == other.unionMember5 - } - - override fun hashCode(): Int = - Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - ) - - override fun toString(): String = - when { - unionMember0 != null -> "Element{unionMember0=$unionMember0}" - unionMember1 != null -> "Element{unionMember1=$unionMember1}" - unionMember2 != null -> "Element{unionMember2=$unionMember2}" - unionMember3 != null -> "Element{unionMember3=$unionMember3}" - unionMember4 != null -> "Element{unionMember4=$unionMember4}" - unionMember5 != null -> "Element{unionMember5=$unionMember5}" - _json != null -> "Element{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Element") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Element(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Element(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - Element(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Element(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Element(unionMember4 = unionMember4) - - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = - Element(unionMember5 = unionMember5) - } - - /** - * An interface that defines how to map each variant of [Element] to a value of type - * [T]. - */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun visitUnionMember5(unionMember5: UnionMember5): T - - /** - * Maps an unknown variant of [Element] to a value of type [T]. - * - * An instance of [Element] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Element: $json") - } - } - - internal class Deserializer : BaseDeserializer(Element::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Element { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember2 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember4 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember5 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Element(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Element::class) { - - override fun serialize( - value: Element, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Element") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - channels = unionMember0.channels.map { it.toMutableList() } - if_ = unionMember0.if_ - loop = unionMember0.loop - ref = unionMember0.ref - type = unionMember0.type - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember0 = - UnionMember0( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TEXT = of("text") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TEXT - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TEXT, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - channels = unionMember1.channels.map { it.toMutableList() } - if_ = unionMember1.if_ - loop = unionMember1.loop - ref = unionMember1.ref - type = unionMember1.type - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val META = of("meta") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - META - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - META, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - META -> Value.META - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - META -> Known.META - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember2 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember2]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - channels = unionMember2.channels.map { it.toMutableList() } - if_ = unionMember2.if_ - loop = unionMember2.loop - ref = unionMember2.ref - type = unionMember2.type - additionalProperties = unionMember2.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember2]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember2 = - UnionMember2( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember2 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val IMAGE = of("image") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMAGE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IMAGE, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IMAGE -> Value.IMAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - IMAGE -> Known.IMAGE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember2{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember3 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember3]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - channels = unionMember3.channels.map { it.toMutableList() } - if_ = unionMember3.if_ - loop = unionMember3.loop - ref = unionMember3.ref - type = unionMember3.type - additionalProperties = unionMember3.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember3]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember3 = - UnionMember3( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember3 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ACTION = of("action") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ACTION - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTION -> Value.ACTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ACTION -> Known.ACTION - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember4 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember4]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - channels = unionMember4.channels.map { it.toMutableList() } - if_ = unionMember4.if_ - loop = unionMember4.loop - ref = unionMember4.ref - type = unionMember4.type - additionalProperties = unionMember4.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember4]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember4 = - UnionMember4( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember4 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DIVIDER = of("divider") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - DIVIDER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDER, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDER -> Value.DIVIDER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DIVIDER -> Known.DIVIDER - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember5 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember5]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - channels = unionMember5.channels.map { it.toMutableList() } - if_ = unionMember5.if_ - loop = unionMember5.loop - ref = unionMember5.ref - type = unionMember5.type - additionalProperties = unionMember5.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember5]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember5 = - UnionMember5( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember5 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val QUOTE = of("quote") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - QUOTE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - QUOTE, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - QUOTE -> Value.QUOTE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - QUOTE -> Known.QUOTE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember5 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt new file mode 100644 index 00000000..68c66523 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt @@ -0,0 +1,572 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ElementalChannelNode +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val channel: JsonField, + private val channels: JsonField>, + private val elements: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val raw: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(channel, channels, elements, if_, loop, raw, ref, mutableMapOf()) + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` is + * `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elements(): Optional> = elements.getOptional("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalChannelNode]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalChannelNode]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channels: JsonField>? = null + private var elements: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalChannelNode: ElementalChannelNode) = apply { + channel = elementalChannelNode.channel + channels = elementalChannelNode.channels.map { it.toMutableList() } + elements = elementalChannelNode.elements.map { it.toMutableList() } + if_ = elementalChannelNode.if_ + loop = elementalChannelNode.loop + raw = elementalChannelNode.raw + ref = elementalChannelNode.ref + additionalProperties = elementalChannelNode.additionalProperties.toMutableMap() + } + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` + * is `required`. + */ + fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) + + /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ + fun elements(elements: Optional>) = elements(elements.getOrNull()) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + */ + fun raw(raw: Raw?) = raw(JsonField.ofNullable(raw)) + + /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ + fun raw(raw: Optional) = raw(raw.getOrNull()) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [Raw] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalChannelNode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalChannelNode = + ElementalChannelNode( + checkRequired("channel", channel), + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + (elements ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + raw, + ref, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalChannelNode = apply { + if (validated) { + return@apply + } + + channel() + channels() + elements().ifPresent { it.forEach { it.validate() } } + if_() + loop() + raw().ifPresent { it.validate() } + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (raw.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. + */ + class Raw + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Raw]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Raw]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(raw: Raw) = apply { + additionalProperties = raw.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Raw]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Raw = Raw(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Raw = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Raw && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Raw{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalChannelNode && + channel == other.channel && + channels == other.channels && + elements == other.elements && + if_ == other.if_ && + loop == other.loop && + raw == other.raw && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, channels, elements, if_, loop, raw, ref, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalChannelNode{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt new file mode 100644 index 00000000..c0d905c7 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ElementalGroupNode +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val elements: JsonField>, + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(elements, channels, if_, loop, ref, mutableMapOf()) + + /** + * Sub elements to render. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalGroupNode]. + * + * The following fields are required: + * ```java + * .elements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalGroupNode]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalGroupNode: ElementalGroupNode) = apply { + elements = elementalGroupNode.elements.map { it.toMutableList() } + channels = elementalGroupNode.channels.map { it.toMutableList() } + if_ = elementalGroupNode.if_ + loop = elementalGroupNode.loop + ref = elementalGroupNode.ref + additionalProperties = elementalGroupNode.additionalProperties.toMutableMap() + } + + /** Sub elements to render. */ + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalGroupNode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalGroupNode = + ElementalGroupNode( + checkRequired("elements", elements).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalGroupNode = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + channels() + if_() + loop() + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalGroupNode && + elements == other.elements && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, channels, if_, loop, ref, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalGroupNode{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt new file mode 100644 index 00000000..17b2304e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt @@ -0,0 +1,4182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is sent + * through email, and a more concise message in a push notification. Channel elements are only valid + * as top-level elements; you cannot nest channel elements. If there is a channel element specified + * at the top-level of the document, all sibling elements must be channel elements. Note: As an + * alternative, most elements support a `channel` property. Which allows you to selectively display + * an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for + * more details. + */ +@JsonDeserialize(using = ElementalNode.Deserializer::class) +@JsonSerialize(using = ElementalNode.Serializer::class) +class ElementalNode +private constructor( + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val unionMember3: UnionMember3? = null, + private val unionMember4: UnionMember4? = null, + private val unionMember5: UnionMember5? = null, + private val unionMember6: UnionMember6? = null, + private val unionMember7: UnionMember7? = null, + private val _json: JsonValue? = null, +) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun unionMember4(): Optional = Optional.ofNullable(unionMember4) + + fun unionMember5(): Optional = Optional.ofNullable(unionMember5) + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun unionMember6(): Optional = Optional.ofNullable(unionMember6) + + fun unionMember7(): Optional = Optional.ofNullable(unionMember7) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUnionMember3(): Boolean = unionMember3 != null + + fun isUnionMember4(): Boolean = unionMember4 != null + + fun isUnionMember5(): Boolean = unionMember5 != null + + fun isUnionMember6(): Boolean = unionMember6 != null + + fun isUnionMember7(): Boolean = unionMember7 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") + + fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") + + fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) + unionMember4 != null -> visitor.visitUnionMember4(unionMember4) + unionMember5 != null -> visitor.visitUnionMember5(unionMember5) + unionMember6 != null -> visitor.visitUnionMember6(unionMember6) + unionMember7 != null -> visitor.visitUnionMember7(unionMember7) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ElementalNode = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } + + override fun visitUnionMember4(unionMember4: UnionMember4) { + unionMember4.validate() + } + + override fun visitUnionMember5(unionMember5: UnionMember5) { + unionMember5.validate() + } + + override fun visitUnionMember6(unionMember6: UnionMember6) { + unionMember6.validate() + } + + override fun visitUnionMember7(unionMember7: UnionMember7) { + unionMember7.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + + override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() + + override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() + + override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() + + override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() + + override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalNode && + unionMember0 == other.unionMember0 && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + unionMember3 == other.unionMember3 && + unionMember4 == other.unionMember4 && + unionMember5 == other.unionMember5 && + unionMember6 == other.unionMember6 && + unionMember7 == other.unionMember7 + } + + override fun hashCode(): Int = + Objects.hash( + unionMember0, + unionMember1, + unionMember2, + unionMember3, + unionMember4, + unionMember5, + unionMember6, + unionMember7, + ) + + override fun toString(): String = + when { + unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" + unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" + unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" + unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" + unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" + unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" + unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" + unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" + _json != null -> "ElementalNode{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ElementalNode") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) + + /** + * The channel element allows a notification to be customized based on which channel it is + * sent through. For example, you may want to display a detailed message when the + * notification is sent through email, and a more concise message in a push notification. + * Channel elements are only valid as top-level elements; you cannot nest channel elements. + * If there is a channel element specified at the top-level of the document, all sibling + * elements must be channel elements. Note: As an alternative, most elements support a + * `channel` property. Which allows you to selectively display an individual element on a + * per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) + + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) + + @JvmStatic + fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) + + @JvmStatic + fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) + + /** + * Allows you to group elements together. This can be useful when used in combination with + * "if" or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + @JvmStatic + fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) + + @JvmStatic + fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) + } + + /** + * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * The channel element allows a notification to be customized based on which channel it is + * sent through. For example, you may want to display a detailed message when the + * notification is sent through email, and a more concise message in a push notification. + * Channel elements are only valid as top-level elements; you cannot nest channel elements. + * If there is a channel element specified at the top-level of the document, all sibling + * elements must be channel elements. Note: As an alternative, most elements support a + * `channel` property. Which allows you to selectively display an individual element on a + * per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUnionMember3(unionMember3: UnionMember3): T + + fun visitUnionMember4(unionMember4: UnionMember4): T + + fun visitUnionMember5(unionMember5: UnionMember5): T + + /** + * Allows you to group elements together. This can be useful when used in combination with + * "if" or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun visitUnionMember6(unionMember6: UnionMember6): T + + fun visitUnionMember7(unionMember7: UnionMember7): T + + /** + * Maps an unknown variant of [ElementalNode] to a value of type [T]. + * + * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ElementalNode: $json") + } + } + + internal class Deserializer : BaseDeserializer(ElementalNode::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember4 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember5 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember6 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember7 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ElementalNode(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ElementalNode::class) { + + override fun serialize( + value: ElementalNode, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) + value.unionMember4 != null -> generator.writeObject(value.unionMember4) + value.unionMember5 != null -> generator.writeObject(value.unionMember5) + value.unionMember6 != null -> generator.writeObject(value.unionMember6) + value.unionMember7 != null -> generator.writeObject(value.unionMember7) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ElementalNode") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + channels = unionMember0.channels.map { it.toMutableList() } + if_ = unionMember0.if_ + loop = unionMember0.loop + ref = unionMember0.ref + type = unionMember0.type + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + channels = unionMember1.channels.map { it.toMutableList() } + if_ = unionMember1.if_ + loop = unionMember1.loop + ref = unionMember1.ref + type = unionMember1.type + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val META = of("meta") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + META + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + META, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + META -> Value.META + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + META -> Known.META + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val channels: JsonField>, + private val elements: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val raw: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("raw") + @ExcludeMissing + raw: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channel, channels, elements, if_, loop, raw, ref, type, mutableMapOf()) + + fun toElementalChannelNode(): ElementalChannelNode = + ElementalChannelNode.builder() + .channel(channel) + .channels(channels) + .elements(elements) + .if_(if_) + .loop(loop) + .raw(raw) + .ref(ref) + .build() + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` + * is `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elements(): Optional> = elements.getOptional("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember2]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channels: JsonField>? = null + private var elements: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + channel = unionMember2.channel + channels = unionMember2.channels.map { it.toMutableList() } + elements = unionMember2.elements.map { it.toMutableList() } + if_ = unionMember2.if_ + loop = unionMember2.loop + raw = unionMember2.raw + ref = unionMember2.ref + type = unionMember2.type + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + /** + * The channel the contents of this element should be applied to. Can be `email`, + * `push`, `direct_message`, `sms` or a provider such as slack + */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, + * `elements` is `required`. + */ + fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) + + /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ + fun elements(elements: Optional>) = elements(elements.getOrNull()) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + */ + fun raw(raw: ElementalChannelNode.Raw?) = raw(JsonField.ofNullable(raw)) + + /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ + fun raw(raw: Optional) = raw(raw.getOrNull()) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [ElementalChannelNode.Raw] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember2 = + UnionMember2( + checkRequired("channel", channel), + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + (elements ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + raw, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + channel() + channels() + elements().ifPresent { it.forEach { it.validate() } } + if_() + loop() + raw().ifPresent { it.validate() } + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (raw.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHANNEL = of("channel") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CHANNEL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHANNEL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHANNEL -> Value.CHANNEL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHANNEL -> Known.CHANNEL + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + channel == other.channel && + channels == other.channels && + elements == other.elements && + if_ == other.if_ && + loop == other.loop && + raw == other.raw && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + channel, + channels, + elements, + if_, + loop, + raw, + ref, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + channels = unionMember3.channels.map { it.toMutableList() } + if_ = unionMember3.if_ + loop = unionMember3.loop + ref = unionMember3.ref + type = unionMember3.type + additionalProperties = unionMember3.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = + UnionMember3( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IMAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IMAGE -> Value.IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IMAGE -> Known.IMAGE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember4 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember4]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember4: UnionMember4) = apply { + channels = unionMember4.channels.map { it.toMutableList() } + if_ = unionMember4.if_ + loop = unionMember4.loop + ref = unionMember4.ref + type = unionMember4.type + additionalProperties = unionMember4.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember4]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember4 = + UnionMember4( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember4 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTION = of("action") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACTION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTION, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTION -> Value.ACTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTION -> Known.ACTION + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember4 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember5 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember5]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember5: UnionMember5) = apply { + channels = unionMember5.channels.map { it.toMutableList() } + if_ = unionMember5.if_ + loop = unionMember5.loop + ref = unionMember5.ref + type = unionMember5.type + additionalProperties = unionMember5.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember5]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember5 = + UnionMember5( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember5 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DIVIDER = of("divider") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIVIDER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDER -> Value.DIVIDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DIVIDER -> Known.DIVIDER + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember5 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + class UnionMember6 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val elements: JsonField>, + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(elements, channels, if_, loop, ref, type, mutableMapOf()) + + fun toElementalGroupNode(): ElementalGroupNode = + ElementalGroupNode.builder() + .elements(elements) + .channels(channels) + .if_(if_) + .loop(loop) + .ref(ref) + .build() + + /** + * Sub elements to render. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember6]. + * + * The following fields are required: + * ```java + * .elements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember6]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember6: UnionMember6) = apply { + elements = unionMember6.elements.map { it.toMutableList() } + channels = unionMember6.channels.map { it.toMutableList() } + if_ = unionMember6.if_ + loop = unionMember6.loop + ref = unionMember6.ref + type = unionMember6.type + additionalProperties = unionMember6.additionalProperties.toMutableMap() + } + + /** Sub elements to render. */ + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember6]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember6 = + UnionMember6( + checkRequired("elements", elements).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember6 = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUP = of("group") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GROUP + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUP, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUP -> Value.GROUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUP -> Known.GROUP + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember6 && + elements == other.elements && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember6{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember7 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember7]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember7: UnionMember7) = apply { + channels = unionMember7.channels.map { it.toMutableList() } + if_ = unionMember7.if_ + loop = unionMember7.loop + ref = unionMember7.ref + type = unionMember7.type + additionalProperties = unionMember7.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember7]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember7 = + UnionMember7( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember7 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val QUOTE = of("quote") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + QUOTE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + QUOTE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUOTE -> Value.QUOTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUOTE -> Known.QUOTE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember7 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt index 698992ba..37c66cfa 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt @@ -19,12 +19,12 @@ internal class ContentTest { val elemental = Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -44,12 +44,12 @@ internal class ContentTest { Content.ofElemental( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt new file mode 100644 index 00000000..4587d04e --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalChannelNodeTest { + + @Test + fun create() { + val elementalChannelNode = + ElementalChannelNode.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .build() + + assertThat(elementalChannelNode.channel()).isEqualTo("channel") + assertThat(elementalChannelNode.channels().getOrNull()).containsExactly("string") + assertThat(elementalChannelNode.elements().getOrNull()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalChannelNode.if_()).contains("if") + assertThat(elementalChannelNode.loop()).contains("loop") + assertThat(elementalChannelNode.raw()) + .contains( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(elementalChannelNode.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalChannelNode = + ElementalChannelNode.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .build() + + val roundtrippedElementalChannelNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalChannelNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalChannelNode).isEqualTo(elementalChannelNode) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt new file mode 100644 index 00000000..bf51afd4 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalGroupNodeTest { + + @Test + fun create() { + val elementalGroupNode = + ElementalGroupNode.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .build() + + assertThat(elementalGroupNode.elements()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalGroupNode.channels().getOrNull()).containsExactly("string") + assertThat(elementalGroupNode.if_()).contains("if") + assertThat(elementalGroupNode.loop()).contains("loop") + assertThat(elementalGroupNode.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalGroupNode = + ElementalGroupNode.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .build() + + val roundtrippedElementalGroupNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalGroupNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalGroupNode).isEqualTo(elementalGroupNode) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt new file mode 100644 index 00000000..df5c7d9d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt @@ -0,0 +1,450 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ElementalNodeTest { + + @Test + fun ofUnionMember0() { + val unionMember0 = + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + + val elementalNode = ElementalNode.ofUnionMember0(unionMember0) + + assertThat(elementalNode.unionMember0()).contains(unionMember0) + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember1() { + val unionMember1 = + ElementalNode.UnionMember1.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember1.Type.META) + .build() + + val elementalNode = ElementalNode.ofUnionMember1(unionMember1) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).contains(unionMember1) + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember1Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember1( + ElementalNode.UnionMember1.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember1.Type.META) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember2() { + val unionMember2 = + ElementalNode.UnionMember2.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .type(ElementalNode.UnionMember2.Type.CHANNEL) + .build() + + val elementalNode = ElementalNode.ofUnionMember2(unionMember2) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).contains(unionMember2) + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember2Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember2( + ElementalNode.UnionMember2.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .type(ElementalNode.UnionMember2.Type.CHANNEL) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember3() { + val unionMember3 = + ElementalNode.UnionMember3.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember3.Type.IMAGE) + .build() + + val elementalNode = ElementalNode.ofUnionMember3(unionMember3) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).contains(unionMember3) + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember3Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember3( + ElementalNode.UnionMember3.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember3.Type.IMAGE) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember4() { + val unionMember4 = + ElementalNode.UnionMember4.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember4.Type.ACTION) + .build() + + val elementalNode = ElementalNode.ofUnionMember4(unionMember4) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).contains(unionMember4) + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember4Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember4( + ElementalNode.UnionMember4.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember4.Type.ACTION) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember5() { + val unionMember5 = + ElementalNode.UnionMember5.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember5.Type.DIVIDER) + .build() + + val elementalNode = ElementalNode.ofUnionMember5(unionMember5) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).contains(unionMember5) + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember5Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember5( + ElementalNode.UnionMember5.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember5.Type.DIVIDER) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember6() { + val unionMember6 = + ElementalNode.UnionMember6.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember6.Type.GROUP) + .build() + + val elementalNode = ElementalNode.ofUnionMember6(unionMember6) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).contains(unionMember6) + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember6Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember6( + ElementalNode.UnionMember6.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember6.Type.GROUP) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember7() { + val unionMember7 = + ElementalNode.UnionMember7.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember7.Type.QUOTE) + .build() + + val elementalNode = ElementalNode.ofUnionMember7(unionMember7) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).contains(unionMember7) + } + + @Test + fun ofUnionMember7Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember7( + ElementalNode.UnionMember7.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember7.Type.QUOTE) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val elementalNode = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { elementalNode.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt index 74630fb4..cfd8399f 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt @@ -186,12 +186,12 @@ internal class MessageTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -387,12 +387,12 @@ internal class MessageTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index 33c061a9..09280c1e 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -188,12 +188,12 @@ internal class SendMessageParamsTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -389,14 +389,12 @@ internal class SendMessageParamsTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0.Type.TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -591,14 +589,12 @@ internal class SendMessageParamsTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0.Type.TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -618,9 +614,7 @@ internal class SendMessageParamsTest { Message.ContentMessage.builder() .content( Content.ElementalContent.builder() - .addElement( - Content.ElementalContent.Element.UnionMember0.builder().build() - ) + .addElement(ElementalNode.UnionMember0.builder().build()) .version("version") .build() ) @@ -636,9 +630,7 @@ internal class SendMessageParamsTest { Message.ContentMessage.builder() .content( Content.ElementalContent.builder() - .addElement( - Content.ElementalContent.Element.UnionMember0.builder().build() - ) + .addElement(ElementalNode.UnionMember0.builder().build()) .version("version") .build() ) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index a568d663..1926589d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -19,6 +19,7 @@ import com.courier.api.errors.UnprocessableEntityException import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -274,16 +275,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -510,16 +507,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -746,16 +739,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -982,16 +971,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -1218,16 +1203,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -1454,16 +1435,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -1690,16 +1667,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -1926,16 +1899,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -2162,16 +2131,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -2398,16 +2363,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -2634,16 +2595,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -2870,16 +2827,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -3106,16 +3059,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -3342,16 +3291,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -3578,16 +3523,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -3814,16 +3755,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -4048,16 +3985,12 @@ internal class ErrorHandlingTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0 - .Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index a8bd356b..cbd00c20 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -8,6 +8,7 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -231,14 +232,12 @@ internal class ServiceParamsTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0.Type.TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index e8201459..17ca5300 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -220,15 +221,12 @@ internal class SendServiceAsyncTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0.Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index f0675180..86d83405 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -8,6 +8,7 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod @@ -220,15 +221,12 @@ internal class SendServiceTest { .content( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type( - Content.ElementalContent.Element.UnionMember0.Type - .TEXT - ) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt index cecefd3f..40930df0 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -7,6 +7,7 @@ import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content +import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.MessageContext import com.courier.api.models.send.RoutingMethod import com.courier.api.models.send.Utm @@ -239,12 +240,12 @@ internal class ProGuardCompatibilityTest { Content.ofElemental( Content.ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") From 2f68cbe54d8ed9f6ae5dc5c060e3067131acf3fb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 23:03:47 +0000 Subject: [PATCH 17/33] feat(api): manual updates Imported Mintlify Spec --- .stats.yml | 8 +- README.md | 6 +- .../api/models/auth/AuthIssueTokenParams.kt | 233 +-- .../InvokeInvokeAdHocParams.kt} | 29 +- .../InvokeInvokeByTemplateParams.kt} | 34 +- .../api/models/bulk/InboundBulkMessage.kt | 4 +- .../models/inbound/InboundTrackEventParams.kt | 8 +- .../com/courier/api/models/lists/List.kt | 50 +- .../api/models/lists/ListRestoreParams.kt | 66 +- ...ntentParams.kt => MessageContentParams.kt} | 26 +- ...tResponse.kt => MessageContentResponse.kt} | 24 +- .../api/models/messages/MessageDetails.kt | 18 + .../courier/api/models/send/BaseMessage.kt | 1691 ++++------------- .../com/courier/api/models/send/Content.kt | 261 +-- .../com/courier/api/models/send/Message.kt | 4 +- .../courier/api/models/send/RoutingMethod.kt | 132 -- .../kotlin/com/courier/api/models/send/Utm.kt | 293 --- .../BaseTemplateTenantAssociation.kt | 329 ++++ .../templates}/ElementalChannelNode.kt | 2 +- .../tenants/templates/ElementalContent.kt | 274 +++ .../templates}/ElementalGroupNode.kt | 2 +- .../templates}/ElementalNode.kt | 2 +- .../tenants/templates/TemplateListParams.kt | 236 +++ .../tenants/templates/TemplateListResponse.kt | 1030 ++++++++++ .../templates/TemplateRetrieveParams.kt | 217 +++ ...SingleParams.kt => TokenRetrieveParams.kt} | 26 +- ...leResponse.kt => TokenRetrieveResponse.kt} | 38 +- .../services/async/AutomationServiceAsync.kt | 92 - .../async/AutomationServiceAsyncImpl.kt | 100 - .../api/services/async/ListServiceAsync.kt | 63 +- .../services/async/ListServiceAsyncImpl.kt | 18 +- .../api/services/async/MessageServiceAsync.kt | 103 +- .../services/async/MessageServiceAsyncImpl.kt | 24 +- .../api/services/async/TenantServiceAsync.kt | 5 + .../services/async/TenantServiceAsyncImpl.kt | 12 + .../async/automations/InvokeServiceAsync.kt | 91 + .../automations/InvokeServiceAsyncImpl.kt | 100 + .../async/tenants/TemplateServiceAsync.kt | 174 ++ .../async/tenants/TemplateServiceAsyncImpl.kt | 136 ++ .../services/async/users/TokenServiceAsync.kt | 115 +- .../async/users/TokenServiceAsyncImpl.kt | 84 +- .../services/blocking/AutomationService.kt | 94 - .../blocking/AutomationServiceImpl.kt | 93 - .../api/services/blocking/ListService.kt | 56 +- .../api/services/blocking/ListServiceImpl.kt | 19 +- .../api/services/blocking/MessageService.kt | 95 +- .../services/blocking/MessageServiceImpl.kt | 24 +- .../api/services/blocking/TenantService.kt | 5 + .../services/blocking/TenantServiceImpl.kt | 12 + .../blocking/automations/InvokeService.kt | 94 + .../blocking/automations/InvokeServiceImpl.kt | 93 + .../blocking/tenants/TemplateService.kt | 169 ++ .../blocking/tenants/TemplateServiceImpl.kt | 129 ++ .../services/blocking/users/TokenService.kt | 114 +- .../blocking/users/TokenServiceImpl.kt | 78 +- .../models/auth/AuthIssueTokenParamsTest.kt | 13 +- .../InvokeInvokeAdHocParamsTest.kt} | 47 +- .../InvokeInvokeByTemplateParamsTest.kt} | 13 +- .../models/bulk/BulkCreateJobParamsTest.kt | 165 +- .../bulk/BulkRetrieveJobResponseTest.kt | 182 +- .../api/models/bulk/InboundBulkMessageTest.kt | 143 +- .../api/models/lists/ListListResponseTest.kt | 22 +- .../api/models/lists/ListRestoreParamsTest.kt | 25 +- .../com/courier/api/models/lists/ListTest.kt | 10 +- ...amsTest.kt => MessageContentParamsTest.kt} | 6 +- ...eTest.kt => MessageContentResponseTest.kt} | 38 +- .../api/models/messages/MessageDetailsTest.kt | 6 +- .../messages/MessageListResponseTest.kt | 6 +- .../messages/MessageRetrieveResponseTest.kt | 6 +- .../api/models/send/BaseMessageTest.kt | 131 +- .../courier/api/models/send/ContentTest.kt | 6 +- .../courier/api/models/send/MessageTest.kt | 182 +- .../api/models/send/SendMessageParamsTest.kt | 243 +-- .../models/send/SendMessageResponseTest.kt | 8 +- .../com/courier/api/models/send/UtmTest.kt | 47 - .../BaseTemplateTenantAssociationTest.kt | 51 + .../templates}/ElementalChannelNodeTest.kt | 2 +- .../tenants/templates/ElementalContentTest.kt | 72 + .../templates}/ElementalGroupNodeTest.kt | 2 +- .../templates}/ElementalNodeTest.kt | 2 +- .../templates/TemplateListParamsTest.kt | 44 + .../templates/TemplateListResponseTest.kt | 110 ++ .../templates/TemplateRetrieveParamsTest.kt | 25 + ...ramsTest.kt => TokenRetrieveParamsTest.kt} | 6 +- ...seTest.kt => TokenRetrieveResponseTest.kt} | 39 +- .../courier/api/services/ErrorHandlingTest.kt | 1482 +++------------ .../courier/api/services/ServiceParamsTest.kt | 80 +- .../services/async/AuthServiceAsyncTest.kt | 5 +- .../services/async/BulkServiceAsyncTest.kt | 60 +- .../services/async/ListServiceAsyncTest.kt | 14 +- .../services/async/MessageServiceAsyncTest.kt | 4 +- .../services/async/SendServiceAsyncTest.kt | 86 +- .../InvokeServiceAsyncTest.kt} | 27 +- .../async/tenants/TemplateServiceAsyncTest.kt | 60 + .../async/users/TokenServiceAsyncTest.kt | 40 +- .../api/services/blocking/AuthServiceTest.kt | 5 +- .../api/services/blocking/BulkServiceTest.kt | 60 +- .../api/services/blocking/ListServiceTest.kt | 109 +- .../services/blocking/MessageServiceTest.kt | 4 +- .../api/services/blocking/SendServiceTest.kt | 86 +- .../InvokeServiceTest.kt} | 27 +- .../blocking/tenants/TemplateServiceTest.kt | 58 + .../blocking/users/TokenServiceTest.kt | 38 +- .../api/proguard/ProGuardCompatibilityTest.kt | 64 +- 104 files changed, 5140 insertions(+), 6056 deletions(-) rename courier-java-core/src/main/kotlin/com/courier/api/models/automations/{AutomationInvokeAdHocParams.kt => invoke/InvokeInvokeAdHocParams.kt} (99%) rename courier-java-core/src/main/kotlin/com/courier/api/models/automations/{AutomationInvokeByTemplateParams.kt => invoke/InvokeInvokeByTemplateParams.kt} (85%) rename courier-java-core/src/main/kotlin/com/courier/api/models/messages/{MessageGetContentParams.kt => MessageContentParams.kt} (87%) rename courier-java-core/src/main/kotlin/com/courier/api/models/messages/{MessageGetContentResponse.kt => MessageContentResponse.kt} (98%) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/{send => tenants/templates}/ElementalChannelNode.kt (99%) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/{send => tenants/templates}/ElementalGroupNode.kt (99%) rename courier-java-core/src/main/kotlin/com/courier/api/models/{send => tenants/templates}/ElementalNode.kt (99%) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/{TokenRetrieveSingleParams.kt => TokenRetrieveParams.kt} (88%) rename courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/{TokenRetrieveSingleResponse.kt => TokenRetrieveResponse.kt} (94%) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt rename courier-java-core/src/test/kotlin/com/courier/api/models/automations/{AutomationInvokeAdHocParamsTest.kt => invoke/InvokeInvokeAdHocParamsTest.kt} (73%) rename courier-java-core/src/test/kotlin/com/courier/api/models/automations/{AutomationInvokeByTemplateParamsTest.kt => invoke/InvokeInvokeByTemplateParamsTest.kt} (88%) rename courier-java-core/src/test/kotlin/com/courier/api/models/messages/{MessageGetContentParamsTest.kt => MessageContentParamsTest.kt} (66%) rename courier-java-core/src/test/kotlin/com/courier/api/models/messages/{MessageGetContentResponseTest.kt => MessageContentResponseTest.kt} (67%) delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt rename courier-java-core/src/test/kotlin/com/courier/api/models/{send => tenants/templates}/ElementalChannelNodeTest.kt (98%) create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt rename courier-java-core/src/test/kotlin/com/courier/api/models/{send => tenants/templates}/ElementalGroupNodeTest.kt (98%) rename courier-java-core/src/test/kotlin/com/courier/api/models/{send => tenants/templates}/ElementalNodeTest.kt (99%) create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt rename courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/{TokenRetrieveSingleParamsTest.kt => TokenRetrieveParamsTest.kt} (67%) rename courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/{TokenRetrieveSingleResponseTest.kt => TokenRetrieveResponseTest.kt} (71%) rename courier-java-core/src/test/kotlin/com/courier/api/services/async/{AutomationServiceAsyncTest.kt => automations/InvokeServiceAsyncTest.kt} (79%) create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt rename courier-java-core/src/test/kotlin/com/courier/api/services/blocking/{AutomationServiceTest.kt => automations/InvokeServiceTest.kt} (78%) create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt diff --git a/.stats.yml b/.stats.yml index a4f42243..1091de1b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 75 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-9edfa04d0cd081138f4834ed9b8d45403d7ee75a5f02f8eecc8e45575df21bb8.yml -openapi_spec_hash: 195e8cd1061046ffc3009f50262d92b2 -config_hash: 5d1f1698a0d16c5edb2c695dd127b335 +configured_endpoints: 77 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-f2aedc1eadc5dfc25984cacada32b0b603b441282b70c7f246545eeb10e1100f.yml +openapi_spec_hash: 9f40fc40e0269789116564dd953e71ef +config_hash: e3d76c7c10d5045dce1d5c823e778b93 diff --git a/README.md b/README.md index e3fb92d0..ea98fbba 100644 --- a/README.md +++ b/README.md @@ -467,10 +467,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.automations.AutomationInvokeAdHocParams; +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams; -AutomationInvokeAdHocParams params = AutomationInvokeAdHocParams.builder() - .automation(AutomationInvokeAdHocParams.Automation.builder() +InvokeInvokeAdHocParams params = InvokeInvokeAdHocParams.builder() + .automation(InvokeInvokeAdHocParams.Automation.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt index ac7bae84..62d595ac 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt @@ -2,7 +2,6 @@ package com.courier.api.models.auth -import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing @@ -18,7 +17,6 @@ import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects -import kotlin.jvm.optionals.getOrNull /** Returns a new access token. */ class AuthIssueTokenParams @@ -38,7 +36,7 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun scope(): Scope = body.scope() + fun scope(): String = body.scope() /** * Returns the raw JSON value of [expiresIn]. @@ -52,7 +50,7 @@ private constructor( * * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. */ - fun _scope(): JsonField = body._scope() + fun _scope(): JsonField = body._scope() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -113,15 +111,15 @@ private constructor( */ fun expiresIn(expiresIn: JsonField) = apply { body.expiresIn(expiresIn) } - fun scope(scope: Scope) = apply { body.scope(scope) } + fun scope(scope: String) = apply { body.scope(scope) } /** * Sets [Builder.scope] to an arbitrary JSON value. * - * You should usually call [Builder.scope] with a well-typed [Scope] value instead. This + * You should usually call [Builder.scope] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun scope(scope: JsonField) = apply { body.scope(scope) } + fun scope(scope: JsonField) = apply { body.scope(scope) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -271,7 +269,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val expiresIn: JsonField, - private val scope: JsonField, + private val scope: JsonField, private val additionalProperties: MutableMap, ) { @@ -280,7 +278,7 @@ private constructor( @JsonProperty("expires_in") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), - @JsonProperty("scope") @ExcludeMissing scope: JsonField = JsonMissing.of(), + @JsonProperty("scope") @ExcludeMissing scope: JsonField = JsonMissing.of(), ) : this(expiresIn, scope, mutableMapOf()) /** @@ -293,7 +291,7 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun scope(): Scope = scope.getRequired("scope") + fun scope(): String = scope.getRequired("scope") /** * Returns the raw JSON value of [expiresIn]. @@ -307,7 +305,7 @@ private constructor( * * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -339,7 +337,7 @@ private constructor( class Builder internal constructor() { private var expiresIn: JsonField? = null - private var scope: JsonField? = null + private var scope: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -360,16 +358,16 @@ private constructor( */ fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } - fun scope(scope: Scope) = scope(JsonField.of(scope)) + fun scope(scope: String) = scope(JsonField.of(scope)) /** * Sets [Builder.scope] to an arbitrary JSON value. * - * You should usually call [Builder.scope] with a well-typed [Scope] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.scope] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun scope(scope: JsonField) = apply { this.scope = scope } + fun scope(scope: JsonField) = apply { this.scope = scope } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -419,7 +417,7 @@ private constructor( } expiresIn() - scope().validate() + scope() validated = true } @@ -440,7 +438,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (expiresIn.asKnown().isPresent) 1 else 0) + - (scope.asKnown().getOrNull()?.validity() ?: 0) + (if (scope.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -461,203 +459,6 @@ private constructor( "Body{expiresIn=$expiresIn, scope=$scope, additionalProperties=$additionalProperties}" } - class Scope @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val READ_PREFERENCES = of("read:preferences") - - @JvmField val WRITE_PREFERENCES = of("write:preferences") - - @JvmField val READ_USER_TOKENS = of("read:user-tokens") - - @JvmField val WRITE_USER_TOKENS = of("write:user-tokens") - - @JvmField val READ_BRANDS = of("read:brands") - - @JvmField val WRITE_BRANDS = of("write:brands") - - @JvmField val READ_BRANDS_ID = of("read:brands{:id}") - - @JvmField val WRITE_BRANDS_ID = of("write:brands{:id}") - - @JvmField val WRITE_TRACK = of("write:track") - - @JvmField val INBOX_READ_MESSAGES = of("inbox:read:messages") - - @JvmField val INBOX_WRITE_MESSAGES = of("inbox:write:messages") - - @JvmField val INBOX_WRITE_EVENT = of("inbox:write:event") - - @JvmField val INBOX_WRITE_EVENTS = of("inbox:write:events") - - @JvmField val USER_ID_YOUR_USER_ID = of("user_id:\$YOUR_USER_ID") - - @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) - } - - /** An enum containing [Scope]'s known values. */ - enum class Known { - READ_PREFERENCES, - WRITE_PREFERENCES, - READ_USER_TOKENS, - WRITE_USER_TOKENS, - READ_BRANDS, - WRITE_BRANDS, - READ_BRANDS_ID, - WRITE_BRANDS_ID, - WRITE_TRACK, - INBOX_READ_MESSAGES, - INBOX_WRITE_MESSAGES, - INBOX_WRITE_EVENT, - INBOX_WRITE_EVENTS, - USER_ID_YOUR_USER_ID, - } - - /** - * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Scope] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - READ_PREFERENCES, - WRITE_PREFERENCES, - READ_USER_TOKENS, - WRITE_USER_TOKENS, - READ_BRANDS, - WRITE_BRANDS, - READ_BRANDS_ID, - WRITE_BRANDS_ID, - WRITE_TRACK, - INBOX_READ_MESSAGES, - INBOX_WRITE_MESSAGES, - INBOX_WRITE_EVENT, - INBOX_WRITE_EVENTS, - USER_ID_YOUR_USER_ID, - /** An enum member indicating that [Scope] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - READ_PREFERENCES -> Value.READ_PREFERENCES - WRITE_PREFERENCES -> Value.WRITE_PREFERENCES - READ_USER_TOKENS -> Value.READ_USER_TOKENS - WRITE_USER_TOKENS -> Value.WRITE_USER_TOKENS - READ_BRANDS -> Value.READ_BRANDS - WRITE_BRANDS -> Value.WRITE_BRANDS - READ_BRANDS_ID -> Value.READ_BRANDS_ID - WRITE_BRANDS_ID -> Value.WRITE_BRANDS_ID - WRITE_TRACK -> Value.WRITE_TRACK - INBOX_READ_MESSAGES -> Value.INBOX_READ_MESSAGES - INBOX_WRITE_MESSAGES -> Value.INBOX_WRITE_MESSAGES - INBOX_WRITE_EVENT -> Value.INBOX_WRITE_EVENT - INBOX_WRITE_EVENTS -> Value.INBOX_WRITE_EVENTS - USER_ID_YOUR_USER_ID -> Value.USER_ID_YOUR_USER_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - READ_PREFERENCES -> Known.READ_PREFERENCES - WRITE_PREFERENCES -> Known.WRITE_PREFERENCES - READ_USER_TOKENS -> Known.READ_USER_TOKENS - WRITE_USER_TOKENS -> Known.WRITE_USER_TOKENS - READ_BRANDS -> Known.READ_BRANDS - WRITE_BRANDS -> Known.WRITE_BRANDS - READ_BRANDS_ID -> Known.READ_BRANDS_ID - WRITE_BRANDS_ID -> Known.WRITE_BRANDS_ID - WRITE_TRACK -> Known.WRITE_TRACK - INBOX_READ_MESSAGES -> Known.INBOX_READ_MESSAGES - INBOX_WRITE_MESSAGES -> Known.INBOX_WRITE_MESSAGES - INBOX_WRITE_EVENT -> Known.INBOX_WRITE_EVENT - INBOX_WRITE_EVENTS -> Known.INBOX_WRITE_EVENTS - USER_ID_YOUR_USER_ID -> Known.USER_ID_YOUR_USER_ID - else -> throw CourierInvalidDataException("Unknown Scope: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Scope = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scope && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt index 19dc6816..b4128f1d 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.automations +package com.courier.api.models.automations.invoke import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer @@ -18,9 +18,6 @@ import com.courier.api.core.http.Headers import com.courier.api.core.http.QueryParams import com.courier.api.core.toImmutable import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.automations.invoke.AutomationInvokeParams -import com.courier.api.models.automations.invoke.AutomationStep -import com.courier.api.models.automations.invoke.MergeAlgorithm import com.courier.api.models.send.Message import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -43,7 +40,7 @@ import kotlin.jvm.optionals.getOrNull * steps. For information about what steps are available, checkout the ad hoc automation guide * [here](https://www.courier.com/docs/automations/steps/). */ -class AutomationInvokeAdHocParams +class InvokeInvokeAdHocParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -130,7 +127,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AutomationInvokeAdHocParams]. + * Returns a mutable builder for constructing an instance of [InvokeInvokeAdHocParams]. * * The following fields are required: * ```java @@ -140,7 +137,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AutomationInvokeAdHocParams]. */ + /** A builder for [InvokeInvokeAdHocParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -148,10 +145,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(automationInvokeAdHocParams: AutomationInvokeAdHocParams) = apply { - body = automationInvokeAdHocParams.body.toBuilder() - additionalHeaders = automationInvokeAdHocParams.additionalHeaders.toBuilder() - additionalQueryParams = automationInvokeAdHocParams.additionalQueryParams.toBuilder() + internal fun from(invokeInvokeAdHocParams: InvokeInvokeAdHocParams) = apply { + body = invokeInvokeAdHocParams.body.toBuilder() + additionalHeaders = invokeInvokeAdHocParams.additionalHeaders.toBuilder() + additionalQueryParams = invokeInvokeAdHocParams.additionalQueryParams.toBuilder() } /** @@ -353,7 +350,7 @@ private constructor( } /** - * Returns an immutable instance of [AutomationInvokeAdHocParams]. + * Returns an immutable instance of [InvokeInvokeAdHocParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -364,8 +361,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AutomationInvokeAdHocParams = - AutomationInvokeAdHocParams( + fun build(): InvokeInvokeAdHocParams = + InvokeInvokeAdHocParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -9447,7 +9444,7 @@ private constructor( return true } - return other is AutomationInvokeAdHocParams && + return other is InvokeInvokeAdHocParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -9456,5 +9453,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "AutomationInvokeAdHocParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InvokeInvokeAdHocParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt similarity index 85% rename from courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt index 77213618..88e652c3 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt @@ -1,19 +1,18 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.automations +package com.courier.api.models.automations.invoke import com.courier.api.core.JsonValue import com.courier.api.core.Params import com.courier.api.core.checkRequired import com.courier.api.core.http.Headers import com.courier.api.core.http.QueryParams -import com.courier.api.models.automations.invoke.AutomationInvokeParams import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Invoke an automation run from an automation template. */ -class AutomationInvokeByTemplateParams +class InvokeInvokeByTemplateParams private constructor( private val templateId: String?, private val automationInvokeParams: AutomationInvokeParams, @@ -39,8 +38,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [AutomationInvokeByTemplateParams]. + * Returns a mutable builder for constructing an instance of [InvokeInvokeByTemplateParams]. * * The following fields are required: * ```java @@ -50,7 +48,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [AutomationInvokeByTemplateParams]. */ + /** A builder for [InvokeInvokeByTemplateParams]. */ class Builder internal constructor() { private var templateId: String? = null @@ -59,14 +57,12 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(automationInvokeByTemplateParams: AutomationInvokeByTemplateParams) = - apply { - templateId = automationInvokeByTemplateParams.templateId - automationInvokeParams = automationInvokeByTemplateParams.automationInvokeParams - additionalHeaders = automationInvokeByTemplateParams.additionalHeaders.toBuilder() - additionalQueryParams = - automationInvokeByTemplateParams.additionalQueryParams.toBuilder() - } + internal fun from(invokeInvokeByTemplateParams: InvokeInvokeByTemplateParams) = apply { + templateId = invokeInvokeByTemplateParams.templateId + automationInvokeParams = invokeInvokeByTemplateParams.automationInvokeParams + additionalHeaders = invokeInvokeByTemplateParams.additionalHeaders.toBuilder() + additionalQueryParams = invokeInvokeByTemplateParams.additionalQueryParams.toBuilder() + } fun templateId(templateId: String?) = apply { this.templateId = templateId } @@ -176,7 +172,7 @@ private constructor( } /** - * Returns an immutable instance of [AutomationInvokeByTemplateParams]. + * Returns an immutable instance of [InvokeInvokeByTemplateParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -187,8 +183,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): AutomationInvokeByTemplateParams = - AutomationInvokeByTemplateParams( + fun build(): InvokeInvokeByTemplateParams = + InvokeInvokeByTemplateParams( templateId, checkRequired("automationInvokeParams", automationInvokeParams), additionalHeaders.build(), @@ -213,7 +209,7 @@ private constructor( return true } - return other is AutomationInvokeByTemplateParams && + return other is InvokeInvokeByTemplateParams && templateId == other.templateId && automationInvokeParams == other.automationInvokeParams && additionalHeaders == other.additionalHeaders && @@ -224,5 +220,5 @@ private constructor( Objects.hash(templateId, automationInvokeParams, additionalHeaders, additionalQueryParams) override fun toString() = - "AutomationInvokeByTemplateParams{templateId=$templateId, automationInvokeParams=$automationInvokeParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InvokeInvokeByTemplateParams{templateId=$templateId, automationInvokeParams=$automationInvokeParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt index 966be3c5..67d16aa5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt @@ -16,6 +16,7 @@ import com.courier.api.errors.CourierInvalidDataException import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content import com.courier.api.models.send.MessageContext +import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -2109,8 +2110,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: Content.ElementalContent) = - content(Content.ofElemental(elemental)) + fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) /** * Alias for calling [content] with diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt index 3bba25fb..8f548040 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt @@ -61,7 +61,7 @@ private constructor( fun type(): Type = body.type() /** - * The user id associated with the track + * The user id associatiated with the track * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -207,7 +207,7 @@ private constructor( */ fun type(type: JsonField) = apply { body.type(type) } - /** The user id associated with the track */ + /** The user id associatiated with the track */ fun userId(userId: String?) = apply { body.userId(userId) } /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ @@ -422,7 +422,7 @@ private constructor( fun type(): Type = type.getRequired("type") /** - * The user id associated with the track + * The user id associatiated with the track * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -568,7 +568,7 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } - /** The user id associated with the track */ + /** The user id associatiated with the track */ fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt index 8d0f1d60..b7713493 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt @@ -22,8 +22,8 @@ class List private constructor( private val id: JsonField, private val name: JsonField, - private val created: JsonField, - private val updated: JsonField, + private val created: JsonField, + private val updated: JsonField, private val additionalProperties: MutableMap, ) { @@ -31,8 +31,8 @@ private constructor( private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), - @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), + @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), + @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), ) : this(id, name, created, updated, mutableMapOf()) /** @@ -51,13 +51,13 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun created(): Optional = created.getOptional("created") + fun created(): Optional = created.getOptional("created") /** * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun updated(): Optional = updated.getOptional("updated") + fun updated(): Optional = updated.getOptional("updated") /** * Returns the raw JSON value of [id]. @@ -78,14 +78,14 @@ private constructor( * * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created + @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created /** * Returns the raw JSON value of [updated]. * * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated + @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -118,8 +118,8 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null - private var created: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() + private var created: JsonField = JsonMissing.of() + private var updated: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -151,45 +151,31 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun created(created: Long?) = created(JsonField.ofNullable(created)) - - /** - * Alias for [Builder.created]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun created(created: Long) = created(created as Long?) + fun created(created: String?) = created(JsonField.ofNullable(created)) /** Alias for calling [Builder.created] with `created.orElse(null)`. */ - fun created(created: Optional) = created(created.getOrNull()) + fun created(created: Optional) = created(created.getOrNull()) /** * Sets [Builder.created] to an arbitrary JSON value. * - * You should usually call [Builder.created] with a well-typed [Long] value instead. This + * You should usually call [Builder.created] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun created(created: JsonField) = apply { this.created = created } + fun created(created: JsonField) = apply { this.created = created } - fun updated(updated: Long?) = updated(JsonField.ofNullable(updated)) - - /** - * Alias for [Builder.updated]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun updated(updated: Long) = updated(updated as Long?) + fun updated(updated: String?) = updated(JsonField.ofNullable(updated)) /** Alias for calling [Builder.updated] with `updated.orElse(null)`. */ - fun updated(updated: Optional) = updated(updated.getOrNull()) + fun updated(updated: Optional) = updated(updated.getOrNull()) /** * Sets [Builder.updated] to an arbitrary JSON value. * - * You should usually call [Builder.updated] with a well-typed [Long] value instead. This + * You should usually call [Builder.updated] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun updated(updated: JsonField) = apply { this.updated = updated } + fun updated(updated: JsonField) = apply { this.updated = updated } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt index 6a9060ed..f2571912 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt @@ -4,9 +4,9 @@ package com.courier.api.models.lists import com.courier.api.core.JsonValue import com.courier.api.core.Params +import com.courier.api.core.checkRequired import com.courier.api.core.http.Headers import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -15,15 +15,14 @@ import kotlin.jvm.optionals.getOrNull class ListRestoreParams private constructor( private val listId: String?, + private val body: JsonValue, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, ) : Params { fun listId(): Optional = Optional.ofNullable(listId) - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties + fun body(): JsonValue = body /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -35,9 +34,14 @@ private constructor( companion object { - @JvmStatic fun none(): ListRestoreParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ListRestoreParams]. */ + /** + * Returns a mutable builder for constructing an instance of [ListRestoreParams]. + * + * The following fields are required: + * ```java + * .body() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -45,16 +49,16 @@ private constructor( class Builder internal constructor() { private var listId: String? = null + private var body: JsonValue? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(listRestoreParams: ListRestoreParams) = apply { listId = listRestoreParams.listId + body = listRestoreParams.body additionalHeaders = listRestoreParams.additionalHeaders.toBuilder() additionalQueryParams = listRestoreParams.additionalQueryParams.toBuilder() - additionalBodyProperties = listRestoreParams.additionalBodyProperties.toMutableMap() } fun listId(listId: String?) = apply { this.listId = listId } @@ -62,6 +66,8 @@ private constructor( /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ fun listId(listId: Optional) = listId(listId.getOrNull()) + fun body(body: JsonValue) = apply { this.body = body } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -160,44 +166,28 @@ private constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - /** * Returns an immutable instance of [ListRestoreParams]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): ListRestoreParams = ListRestoreParams( listId, + checkRequired("body", body), additionalHeaders.build(), additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), ) } - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + fun _body(): JsonValue = body fun _pathParam(index: Int): String = when (index) { @@ -216,14 +206,14 @@ private constructor( return other is ListRestoreParams && listId == other.listId && + body == other.body && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties + additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(listId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + Objects.hash(listId, body, additionalHeaders, additionalQueryParams) override fun toString() = - "ListRestoreParams{listId=$listId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "ListRestoreParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt similarity index 87% rename from courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt index 3ecf9592..d05ee1e6 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt @@ -10,7 +10,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Get message content */ -class MessageGetContentParams +class MessageContentParams private constructor( private val messageId: String?, private val additionalHeaders: Headers, @@ -29,13 +29,13 @@ private constructor( companion object { - @JvmStatic fun none(): MessageGetContentParams = builder().build() + @JvmStatic fun none(): MessageContentParams = builder().build() - /** Returns a mutable builder for constructing an instance of [MessageGetContentParams]. */ + /** Returns a mutable builder for constructing an instance of [MessageContentParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [MessageGetContentParams]. */ + /** A builder for [MessageContentParams]. */ class Builder internal constructor() { private var messageId: String? = null @@ -43,10 +43,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(messageGetContentParams: MessageGetContentParams) = apply { - messageId = messageGetContentParams.messageId - additionalHeaders = messageGetContentParams.additionalHeaders.toBuilder() - additionalQueryParams = messageGetContentParams.additionalQueryParams.toBuilder() + internal fun from(messageContentParams: MessageContentParams) = apply { + messageId = messageContentParams.messageId + additionalHeaders = messageContentParams.additionalHeaders.toBuilder() + additionalQueryParams = messageContentParams.additionalQueryParams.toBuilder() } fun messageId(messageId: String?) = apply { this.messageId = messageId } @@ -153,12 +153,12 @@ private constructor( } /** - * Returns an immutable instance of [MessageGetContentParams]. + * Returns an immutable instance of [MessageContentParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): MessageGetContentParams = - MessageGetContentParams( + fun build(): MessageContentParams = + MessageContentParams( messageId, additionalHeaders.build(), additionalQueryParams.build(), @@ -180,7 +180,7 @@ private constructor( return true } - return other is MessageGetContentParams && + return other is MessageContentParams && messageId == other.messageId && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -189,5 +189,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(messageId, additionalHeaders, additionalQueryParams) override fun toString() = - "MessageGetContentParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "MessageContentParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt similarity index 98% rename from courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt index afee9a38..d27bc382 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageGetContentResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt @@ -18,7 +18,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -class MessageGetContentResponse +class MessageContentResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val results: JsonField>, @@ -60,7 +60,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [MessageGetContentResponse]. + * Returns a mutable builder for constructing an instance of [MessageContentResponse]. * * The following fields are required: * ```java @@ -70,16 +70,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [MessageGetContentResponse]. */ + /** A builder for [MessageContentResponse]. */ class Builder internal constructor() { private var results: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(messageGetContentResponse: MessageGetContentResponse) = apply { - results = messageGetContentResponse.results.map { it.toMutableList() } - additionalProperties = messageGetContentResponse.additionalProperties.toMutableMap() + internal fun from(messageContentResponse: MessageContentResponse) = apply { + results = messageContentResponse.results.map { it.toMutableList() } + additionalProperties = messageContentResponse.additionalProperties.toMutableMap() } /** An array of render output of a previously sent message. */ @@ -128,7 +128,7 @@ private constructor( } /** - * Returns an immutable instance of [MessageGetContentResponse]. + * Returns an immutable instance of [MessageContentResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -139,8 +139,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): MessageGetContentResponse = - MessageGetContentResponse( + fun build(): MessageContentResponse = + MessageContentResponse( checkRequired("results", results).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -148,7 +148,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MessageGetContentResponse = apply { + fun validate(): MessageContentResponse = apply { if (validated) { return@apply } @@ -1001,7 +1001,7 @@ private constructor( return true } - return other is MessageGetContentResponse && + return other is MessageContentResponse && results == other.results && additionalProperties == other.additionalProperties } @@ -1011,5 +1011,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MessageGetContentResponse{results=$results, additionalProperties=$additionalProperties}" + "MessageContentResponse{results=$results, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt index 62e8c4b7..fcdf2c21 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt @@ -810,12 +810,18 @@ private constructor( companion object { + @JvmField val BOUNCED = of("BOUNCED") + + @JvmField val FAILED = of("FAILED") + @JvmField val FILTERED = of("FILTERED") @JvmField val NO_CHANNELS = of("NO_CHANNELS") @JvmField val NO_PROVIDERS = of("NO_PROVIDERS") + @JvmField val OPT_IN_REQUIRED = of("OPT_IN_REQUIRED") + @JvmField val PROVIDER_ERROR = of("PROVIDER_ERROR") @JvmField val UNPUBLISHED = of("UNPUBLISHED") @@ -827,9 +833,12 @@ private constructor( /** An enum containing [Reason]'s known values. */ enum class Known { + BOUNCED, + FAILED, FILTERED, NO_CHANNELS, NO_PROVIDERS, + OPT_IN_REQUIRED, PROVIDER_ERROR, UNPUBLISHED, UNSUBSCRIBED, @@ -845,9 +854,12 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BOUNCED, + FAILED, FILTERED, NO_CHANNELS, NO_PROVIDERS, + OPT_IN_REQUIRED, PROVIDER_ERROR, UNPUBLISHED, UNSUBSCRIBED, @@ -864,9 +876,12 @@ private constructor( */ fun value(): Value = when (this) { + BOUNCED -> Value.BOUNCED + FAILED -> Value.FAILED FILTERED -> Value.FILTERED NO_CHANNELS -> Value.NO_CHANNELS NO_PROVIDERS -> Value.NO_PROVIDERS + OPT_IN_REQUIRED -> Value.OPT_IN_REQUIRED PROVIDER_ERROR -> Value.PROVIDER_ERROR UNPUBLISHED -> Value.UNPUBLISHED UNSUBSCRIBED -> Value.UNSUBSCRIBED @@ -884,9 +899,12 @@ private constructor( */ fun known(): Known = when (this) { + BOUNCED -> Known.BOUNCED + FAILED -> Known.FAILED FILTERED -> Known.FILTERED NO_CHANNELS -> Known.NO_CHANNELS NO_PROVIDERS -> Known.NO_PROVIDERS + OPT_IN_REQUIRED -> Known.OPT_IN_REQUIRED PROVIDER_ERROR -> Known.PROVIDER_ERROR UNPUBLISHED -> Known.UNPUBLISHED UNSUBSCRIBED -> Known.UNSUBSCRIBED diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt index 9c8edb31..e4ef9a8f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt @@ -15,6 +15,8 @@ import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow import com.courier.api.core.toImmutable import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.notifications.MessageRouting +import com.courier.api.models.notifications.MessageRoutingChannel import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -1655,6 +1657,311 @@ private constructor( (if (traceId.asKnown().isPresent) 1 else 0) + (utm.asKnown().getOrNull()?.validity() ?: 0) + /** + * Identify the campaign that refers traffic to a specific website, and attributes the + * browser's website session. + */ + class Utm + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val campaign: JsonField, + private val content: JsonField, + private val medium: JsonField, + private val source: JsonField, + private val term: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("campaign") + @ExcludeMissing + campaign: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("medium") + @ExcludeMissing + medium: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), + ) : this(campaign, content, medium, source, term, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun campaign(): Optional = campaign.getOptional("campaign") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun medium(): Optional = medium.getOptional("medium") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun term(): Optional = term.getOptional("term") + + /** + * Returns the raw JSON value of [campaign]. + * + * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [medium]. + * + * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [term]. + * + * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Utm]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Utm]. */ + class Builder internal constructor() { + + private var campaign: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var medium: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var term: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(utm: Utm) = apply { + campaign = utm.campaign + content = utm.content + medium = utm.medium + source = utm.source + term = utm.term + additionalProperties = utm.additionalProperties.toMutableMap() + } + + fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) + + /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ + fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) + + /** + * Sets [Builder.campaign] to an arbitrary JSON value. + * + * You should usually call [Builder.campaign] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun campaign(campaign: JsonField) = apply { this.campaign = campaign } + + fun content(content: String?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) + + /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ + fun medium(medium: Optional) = medium(medium.getOrNull()) + + /** + * Sets [Builder.medium] to an arbitrary JSON value. + * + * You should usually call [Builder.medium] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun medium(medium: JsonField) = apply { this.medium = medium } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun term(term: String?) = term(JsonField.ofNullable(term)) + + /** Alias for calling [Builder.term] with `term.orElse(null)`. */ + fun term(term: Optional) = term(term.getOrNull()) + + /** + * Sets [Builder.term] to an arbitrary JSON value. + * + * You should usually call [Builder.term] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun term(term: JsonField) = apply { this.term = term } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Utm]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Utm = + Utm( + campaign, + content, + medium, + source, + term, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Utm = apply { + if (validated) { + return@apply + } + + campaign() + content() + medium() + source() + term() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (campaign.asKnown().isPresent) 1 else 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (if (medium.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (term.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Utm && + campaign == other.campaign && + content == other.content && + medium == other.medium && + source == other.source && + term == other.term && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(campaign, content, medium, source, term, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1960,8 +2267,8 @@ private constructor( class Routing @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val channels: JsonField>, - private val method: JsonField, + private val channels: JsonField>, + private val method: JsonField, private val additionalProperties: MutableMap, ) { @@ -1969,10 +2276,8 @@ private constructor( private constructor( @JsonProperty("channels") @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("method") - @ExcludeMissing - method: JsonField = JsonMissing.of(), + channels: JsonField> = JsonMissing.of(), + @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), ) : this(channels, method, mutableMapOf()) /** @@ -1983,13 +2288,13 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun channels(): List = channels.getRequired("channels") + fun channels(): List = channels.getRequired("channels") /** * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun method(): RoutingMethod = method.getRequired("method") + fun method(): Method = method.getRequired("method") /** * Returns the raw JSON value of [channels]. @@ -1998,14 +2303,14 @@ private constructor( */ @JsonProperty("channels") @ExcludeMissing - fun _channels(): JsonField> = channels + fun _channels(): JsonField> = channels /** * Returns the raw JSON value of [method]. * * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2036,8 +2341,8 @@ private constructor( /** A builder for [Routing]. */ class Builder internal constructor() { - private var channels: JsonField>? = null - private var method: JsonField? = null + private var channels: JsonField>? = null + private var method: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2052,55 +2357,51 @@ private constructor( * define sub-routing methods, which can be useful for defining advanced push * notification delivery strategies. */ - fun channels(channels: List) = channels(JsonField.of(channels)) + fun channels(channels: List) = channels(JsonField.of(channels)) /** * Sets [Builder.channels] to an arbitrary JSON value. * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.channels] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. */ - fun channels(channels: JsonField>) = apply { + fun channels(channels: JsonField>) = apply { this.channels = channels.map { it.toMutableList() } } /** - * Adds a single [Channel] to [channels]. + * Adds a single [MessageRoutingChannel] to [channels]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addChannel(channel: Channel) = apply { + fun addChannel(channel: MessageRoutingChannel) = apply { channels = (channels ?: JsonField.of(mutableListOf())).also { checkKnown("channels", it).add(channel) } } - /** Alias for calling [addChannel] with `Channel.ofRoutingStrategy(routingStrategy)`. */ - fun addChannel(routingStrategy: Channel.RoutingStrategyChannel) = - addChannel(Channel.ofRoutingStrategy(routingStrategy)) + /** Alias for calling [addChannel] with `MessageRoutingChannel.ofString(string)`. */ + fun addChannel(string: String) = addChannel(MessageRoutingChannel.ofString(string)) /** * Alias for calling [addChannel] with - * `Channel.ofRoutingStrategyProvider(routingStrategyProvider)`. + * `MessageRoutingChannel.ofMessageRouting(messageRouting)`. */ - fun addChannel(routingStrategyProvider: Channel.RoutingStrategyProvider) = - addChannel(Channel.ofRoutingStrategyProvider(routingStrategyProvider)) + fun addChannel(messageRouting: MessageRouting) = + addChannel(MessageRoutingChannel.ofMessageRouting(messageRouting)) - /** Alias for calling [addChannel] with `Channel.ofString(string)`. */ - fun addChannel(string: String) = addChannel(Channel.ofString(string)) - - fun method(method: RoutingMethod) = method(JsonField.of(method)) + fun method(method: Method) = method(JsonField.of(method)) /** * Sets [Builder.method] to an arbitrary JSON value. * - * You should usually call [Builder.method] with a well-typed [RoutingMethod] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.method] with a well-typed [Method] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun method(method: JsonField) = apply { this.method = method } + fun method(method: JsonField) = apply { this.method = method } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2173,71 +2474,103 @@ private constructor( (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (method.asKnown().getOrNull()?.validity() ?: 0) - @JsonDeserialize(using = Channel.Deserializer::class) - @JsonSerialize(using = Channel.Serializer::class) - class Channel - private constructor( - private val routingStrategy: RoutingStrategyChannel? = null, - private val routingStrategyProvider: RoutingStrategyProvider? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun routingStrategy(): Optional = - Optional.ofNullable(routingStrategy) + class Method @JsonCreator private constructor(private val value: JsonField) : Enum { - fun routingStrategyProvider(): Optional = - Optional.ofNullable(routingStrategyProvider) + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - fun string(): Optional = Optional.ofNullable(string) + companion object { - fun isRoutingStrategy(): Boolean = routingStrategy != null + @JvmField val ALL = of("all") - fun isRoutingStrategyProvider(): Boolean = routingStrategyProvider != null + @JvmField val SINGLE = of("single") - fun isString(): Boolean = string != null + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } - fun asRoutingStrategy(): RoutingStrategyChannel = - routingStrategy.getOrThrow("routingStrategy") + /** An enum containing [Method]'s known values. */ + enum class Known { + ALL, + SINGLE, + } - fun asRoutingStrategyProvider(): RoutingStrategyProvider = - routingStrategyProvider.getOrThrow("routingStrategyProvider") + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + SINGLE, + /** + * An enum member indicating that [Method] was instantiated with an unknown value. + */ + _UNKNOWN, + } - fun asString(): String = string.getOrThrow("string") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + SINGLE -> Value.SINGLE + else -> Value._UNKNOWN + } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + SINGLE -> Known.SINGLE + else -> throw CourierInvalidDataException("Unknown Method: $value") + } - fun accept(visitor: Visitor): T = - when { - routingStrategy != null -> visitor.visitRoutingStrategy(routingStrategy) - routingStrategyProvider != null -> - visitor.visitRoutingStrategyProvider(routingStrategyProvider) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): Channel = apply { + fun validate(): Method = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitRoutingStrategy(routingStrategy: RoutingStrategyChannel) { - routingStrategy.validate() - } - - override fun visitRoutingStrategyProvider( - routingStrategyProvider: RoutingStrategyProvider - ) { - routingStrategyProvider.validate() - } - - override fun visitString(string: String) {} - } - ) + known() validated = true } @@ -2255,1211 +2588,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitRoutingStrategy(routingStrategy: RoutingStrategyChannel) = - routingStrategy.validity() - - override fun visitRoutingStrategyProvider( - routingStrategyProvider: RoutingStrategyProvider - ) = routingStrategyProvider.validity() - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Channel && - routingStrategy == other.routingStrategy && - routingStrategyProvider == other.routingStrategyProvider && - string == other.string - } - - override fun hashCode(): Int = - Objects.hash(routingStrategy, routingStrategyProvider, string) - - override fun toString(): String = - when { - routingStrategy != null -> "Channel{routingStrategy=$routingStrategy}" - routingStrategyProvider != null -> - "Channel{routingStrategyProvider=$routingStrategyProvider}" - string != null -> "Channel{string=$string}" - _json != null -> "Channel{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Channel") - } - - companion object { - - @JvmStatic - fun ofRoutingStrategy(routingStrategy: RoutingStrategyChannel) = - Channel(routingStrategy = routingStrategy) - - @JvmStatic - fun ofRoutingStrategyProvider(routingStrategyProvider: RoutingStrategyProvider) = - Channel(routingStrategyProvider = routingStrategyProvider) - - @JvmStatic fun ofString(string: String) = Channel(string = string) - } - - /** - * An interface that defines how to map each variant of [Channel] to a value of type - * [T]. - */ - interface Visitor { - - fun visitRoutingStrategy(routingStrategy: RoutingStrategyChannel): T - - fun visitRoutingStrategyProvider( - routingStrategyProvider: RoutingStrategyProvider - ): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [Channel] to a value of type [T]. - * - * An instance of [Channel] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Channel: $json") - } - } - - internal class Deserializer : BaseDeserializer(Channel::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Channel { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Channel(routingStrategy = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Channel(routingStrategyProvider = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Channel(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from array). - 0 -> Channel(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Channel::class) { - - override fun serialize( - value: Channel, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.routingStrategy != null -> - generator.writeObject(value.routingStrategy) - value.routingStrategyProvider != null -> - generator.writeObject(value.routingStrategyProvider) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Channel") - } - } - } - - class RoutingStrategyChannel - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channel: JsonField, - private val config: JsonField, - private val if_: JsonField, - private val method: JsonField, - private val providers: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channel") - @ExcludeMissing - channel: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - config: JsonField = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("method") - @ExcludeMissing - method: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField = JsonMissing.of(), - ) : this(channel, config, if_, method, providers, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun config(): Optional = config.getOptional("config") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun method(): Optional = method.getOptional("method") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun providers(): Optional = providers.getOptional("providers") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [method]. - * - * Unlike [method], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("method") - @ExcludeMissing - fun _method(): JsonField = method - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("providers") - @ExcludeMissing - fun _providers(): JsonField = providers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [RoutingStrategyChannel]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RoutingStrategyChannel]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var config: JsonField = JsonMissing.of() - private var if_: JsonField = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var providers: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routingStrategyChannel: RoutingStrategyChannel) = apply { - channel = routingStrategyChannel.channel - config = routingStrategyChannel.config - if_ = routingStrategyChannel.if_ - method = routingStrategyChannel.method - providers = routingStrategyChannel.providers - additionalProperties = - routingStrategyChannel.additionalProperties.toMutableMap() - } - - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun config(config: Config?) = config(JsonField.ofNullable(config)) - - /** Alias for calling [Builder.config] with `config.orElse(null)`. */ - fun config(config: Optional) = config(config.getOrNull()) - - /** - * Sets [Builder.config] to an arbitrary JSON value. - * - * You should usually call [Builder.config] with a well-typed [Config] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun config(config: JsonField) = apply { this.config = config } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun method(method: RoutingMethod?) = method(JsonField.ofNullable(method)) - - /** Alias for calling [Builder.method] with `method.orElse(null)`. */ - fun method(method: Optional) = method(method.getOrNull()) - - /** - * Sets [Builder.method] to an arbitrary JSON value. - * - * You should usually call [Builder.method] with a well-typed [RoutingMethod] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun method(method: JsonField) = apply { this.method = method } - - fun providers(providers: Providers?) = - providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional) = providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed [Providers] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun providers(providers: JsonField) = apply { - this.providers = providers - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RoutingStrategyChannel]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RoutingStrategyChannel = - RoutingStrategyChannel( - checkRequired("channel", channel), - config, - if_, - method, - providers, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RoutingStrategyChannel = apply { - if (validated) { - return@apply - } - - channel() - config().ifPresent { it.validate() } - if_() - method().ifPresent { it.validate() } - providers().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (method.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.validity() ?: 0) - - class Config - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Config]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - additionalProperties = config.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Config]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Config = Config(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Config = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Config{additionalProperties=$additionalProperties}" - } - - class Providers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Providers]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Providers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(providers: Providers) = apply { - additionalProperties = providers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Providers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Providers = Providers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Providers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Providers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Providers{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoutingStrategyChannel && - channel == other.channel && - config == other.config && - if_ == other.if_ && - method == other.method && - providers == other.providers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channel, config, if_, method, providers, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RoutingStrategyChannel{channel=$channel, config=$config, if_=$if_, method=$method, providers=$providers, additionalProperties=$additionalProperties}" + return other is Method && value == other.value } - class RoutingStrategyProvider - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val metadata: JsonField, - private val name: JsonField, - private val config: JsonField, - private val if_: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("config") - @ExcludeMissing - config: JsonField = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - ) : this(metadata, name, config, if_, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun config(): Optional = config.getOptional("config") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("config") @ExcludeMissing fun _config(): JsonField = config - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [RoutingStrategyProvider]. - * - * The following fields are required: - * ```java - * .metadata() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RoutingStrategyProvider]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var name: JsonField? = null - private var config: JsonField = JsonMissing.of() - private var if_: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routingStrategyProvider: RoutingStrategyProvider) = apply { - metadata = routingStrategyProvider.metadata - name = routingStrategyProvider.name - config = routingStrategyProvider.config - if_ = routingStrategyProvider.if_ - additionalProperties = - routingStrategyProvider.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun config(config: Config?) = config(JsonField.ofNullable(config)) - - /** Alias for calling [Builder.config] with `config.orElse(null)`. */ - fun config(config: Optional) = config(config.getOrNull()) - - /** - * Sets [Builder.config] to an arbitrary JSON value. - * - * You should usually call [Builder.config] with a well-typed [Config] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun config(config: JsonField) = apply { this.config = config } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RoutingStrategyProvider]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): RoutingStrategyProvider = - RoutingStrategyProvider( - checkRequired("metadata", metadata), - checkRequired("name", name), - config, - if_, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): RoutingStrategyProvider = apply { - if (validated) { - return@apply - } - - metadata().validate() - name() - config().ifPresent { it.validate() } - if_() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) - - class Metadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val utm: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("utm") @ExcludeMissing utm: JsonField = JsonMissing.of() - ) : this(utm, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun utm(): Optional = utm.getOptional("utm") - - /** - * Returns the raw JSON value of [utm]. - * - * Unlike [utm], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("utm") @ExcludeMissing fun _utm(): JsonField = utm - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var utm: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - utm = metadata.utm - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - fun utm(utm: Utm?) = utm(JsonField.ofNullable(utm)) - - /** Alias for calling [Builder.utm] with `utm.orElse(null)`. */ - fun utm(utm: Optional) = utm(utm.getOrNull()) - - /** - * Sets [Builder.utm] to an arbitrary JSON value. - * - * You should usually call [Builder.utm] with a well-typed [Utm] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun utm(utm: JsonField) = apply { this.utm = utm } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(utm, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - utm().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (utm.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - utm == other.utm && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(utm, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{utm=$utm, additionalProperties=$additionalProperties}" - } - - class Config - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Config]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - additionalProperties = config.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Config]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Config = Config(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Config = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Config{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoutingStrategyProvider && - metadata == other.metadata && - name == other.name && - config == other.config && - if_ == other.if_ && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(metadata, name, config, if_, additionalProperties) - } - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "RoutingStrategyProvider{metadata=$metadata, name=$name, config=$config, if_=$if_, additionalProperties=$additionalProperties}" - } + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt index b1857ad5..03d4d2e2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -9,11 +9,10 @@ import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing import com.courier.api.core.JsonValue import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -28,7 +27,6 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ @JsonDeserialize(using = Content.Deserializer::class) @@ -214,263 +212,6 @@ private constructor( } } - class ElementalContent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val elements: JsonField>, - private val version: JsonField, - private val brand: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), - ) : this(elements, version, brand, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * For example, "2022-01-01" - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalContent]. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalContent]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var version: JsonField? = null - private var brand: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalContent: ElementalContent) = apply { - elements = elementalContent.elements.map { it.toMutableList() } - version = elementalContent.version - brand = elementalContent.brand - additionalProperties = elementalContent.additionalProperties.toMutableMap() - } - - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - /** For example, "2022-01-01" */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - fun brand(brand: JsonValue) = apply { this.brand = brand } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalContent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalContent = - ElementalContent( - checkRequired("elements", elements).map { it.toImmutable() }, - checkRequired("version", version), - brand, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalContent = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - version() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalContent && - elements == other.elements && - version == other.version && - brand == other.brand && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, version, brand, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" - } - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ class ElementalContentSugar @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt index d9a75557..50851d78 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt @@ -13,6 +13,7 @@ import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow import com.courier.api.errors.CourierInvalidDataException import com.courier.api.models.bulk.UserRecipient +import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -897,8 +898,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: Content.ElementalContent) = - content(Content.ofElemental(elemental)) + fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) /** * Alias for calling [content] with diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt deleted file mode 100644 index 3ac4d508..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/RoutingMethod.kt +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.Enum -import com.courier.api.core.JsonField -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class RoutingMethod @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't match - * any known member, and you want to know that value. For example, if the SDK is on an older - * version than the API, then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ALL = of("all") - - @JvmField val SINGLE = of("single") - - @JvmStatic fun of(value: String) = RoutingMethod(JsonField.of(value)) - } - - /** An enum containing [RoutingMethod]'s known values. */ - enum class Known { - ALL, - SINGLE, - } - - /** - * An enum containing [RoutingMethod]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [RoutingMethod] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the SDK - * is on an older version than the API, then the API may respond with new members that the SDK - * is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ALL, - SINGLE, - /** - * An enum member indicating that [RoutingMethod] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if - * the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want to - * throw for the unknown case. - */ - fun value(): Value = - when (this) { - ALL -> Value.ALL - SINGLE -> Value.SINGLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't want - * to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - ALL -> Known.ALL - SINGLE -> Known.SINGLE - else -> throw CourierInvalidDataException("Unknown RoutingMethod: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging and - * generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): RoutingMethod = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RoutingMethod && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt deleted file mode 100644 index 8504b223..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt +++ /dev/null @@ -1,293 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class Utm -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val campaign: JsonField, - private val content: JsonField, - private val medium: JsonField, - private val source: JsonField, - private val term: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("campaign") @ExcludeMissing campaign: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - @JsonProperty("medium") @ExcludeMissing medium: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), - ) : this(campaign, content, medium, source, term, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun campaign(): Optional = campaign.getOptional("campaign") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun medium(): Optional = medium.getOptional("medium") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun term(): Optional = term.getOptional("term") - - /** - * Returns the raw JSON value of [campaign]. - * - * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [medium]. - * - * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - /** - * Returns the raw JSON value of [term]. - * - * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Utm]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Utm]. */ - class Builder internal constructor() { - - private var campaign: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var medium: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var term: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(utm: Utm) = apply { - campaign = utm.campaign - content = utm.content - medium = utm.medium - source = utm.source - term = utm.term - additionalProperties = utm.additionalProperties.toMutableMap() - } - - fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) - - /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ - fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) - - /** - * Sets [Builder.campaign] to an arbitrary JSON value. - * - * You should usually call [Builder.campaign] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun campaign(campaign: JsonField) = apply { this.campaign = campaign } - - fun content(content: String?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) - - /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ - fun medium(medium: Optional) = medium(medium.getOrNull()) - - /** - * Sets [Builder.medium] to an arbitrary JSON value. - * - * You should usually call [Builder.medium] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun medium(medium: JsonField) = apply { this.medium = medium } - - fun source(source: String?) = source(JsonField.ofNullable(source)) - - /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun term(term: String?) = term(JsonField.ofNullable(term)) - - /** Alias for calling [Builder.term] with `term.orElse(null)`. */ - fun term(term: Optional) = term(term.getOrNull()) - - /** - * Sets [Builder.term] to an arbitrary JSON value. - * - * You should usually call [Builder.term] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun term(term: JsonField) = apply { this.term = term } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Utm]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Utm = - Utm(campaign, content, medium, source, term, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Utm = apply { - if (validated) { - return@apply - } - - campaign() - content() - medium() - source() - term() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (campaign.asKnown().isPresent) 1 else 0) + - (if (content.asKnown().isPresent) 1 else 0) + - (if (medium.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (term.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Utm && - campaign == other.campaign && - content == other.content && - medium == other.medium && - source == other.source && - term == other.term && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(campaign, content, medium, source, term, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt new file mode 100644 index 00000000..e5b4b448 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class BaseTemplateTenantAssociation +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val publishedAt: JsonField, + private val updatedAt: JsonField, + private val version: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("published_at") + @ExcludeMissing + publishedAt: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + ) : this(id, createdAt, publishedAt, updatedAt, version, mutableMapOf()) + + /** + * The template's id + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The timestamp at which the template was created + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): String = createdAt.getRequired("created_at") + + /** + * The timestamp at which the template was published + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun publishedAt(): String = publishedAt.getRequired("published_at") + + /** + * The timestamp at which the template was last updated + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): String = updatedAt.getRequired("updated_at") + + /** + * The version of the template + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [publishedAt]. + * + * Unlike [publishedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("published_at") + @ExcludeMissing + fun _publishedAt(): JsonField = publishedAt + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [BaseTemplateTenantAssociation]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .publishedAt() + * .updatedAt() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BaseTemplateTenantAssociation]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var publishedAt: JsonField? = null + private var updatedAt: JsonField? = null + private var version: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(baseTemplateTenantAssociation: BaseTemplateTenantAssociation) = apply { + id = baseTemplateTenantAssociation.id + createdAt = baseTemplateTenantAssociation.createdAt + publishedAt = baseTemplateTenantAssociation.publishedAt + updatedAt = baseTemplateTenantAssociation.updatedAt + version = baseTemplateTenantAssociation.version + additionalProperties = baseTemplateTenantAssociation.additionalProperties.toMutableMap() + } + + /** The template's id */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp at which the template was created */ + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The timestamp at which the template was published */ + fun publishedAt(publishedAt: String) = publishedAt(JsonField.of(publishedAt)) + + /** + * Sets [Builder.publishedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.publishedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun publishedAt(publishedAt: JsonField) = apply { this.publishedAt = publishedAt } + + /** The timestamp at which the template was last updated */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + /** The version of the template */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BaseTemplateTenantAssociation]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .publishedAt() + * .updatedAt() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BaseTemplateTenantAssociation = + BaseTemplateTenantAssociation( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("publishedAt", publishedAt), + checkRequired("updatedAt", updatedAt), + checkRequired("version", version), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BaseTemplateTenantAssociation = apply { + if (validated) { + return@apply + } + + id() + createdAt() + publishedAt() + updatedAt() + version() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (publishedAt.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseTemplateTenantAssociation && + id == other.id && + createdAt == other.createdAt && + publishedAt == other.publishedAt && + updatedAt == other.updatedAt && + version == other.version && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, publishedAt, updatedAt, version, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BaseTemplateTenantAssociation{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt index 68c66523..0700d91f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalChannelNode.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.send +package com.courier.api.models.tenants.templates import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt new file mode 100644 index 00000000..536579a9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ElementalContent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val elements: JsonField>, + private val version: JsonField, + private val brand: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), + ) : this(elements, version, brand, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * For example, "2022-01-01" + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalContent]. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalContent]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var version: JsonField? = null + private var brand: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalContent: ElementalContent) = apply { + elements = elementalContent.elements.map { it.toMutableList() } + version = elementalContent.version + brand = elementalContent.brand + additionalProperties = elementalContent.additionalProperties.toMutableMap() + } + + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + /** For example, "2022-01-01" */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun brand(brand: JsonValue) = apply { this.brand = brand } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalContent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalContent = + ElementalContent( + checkRequired("elements", elements).map { it.toImmutable() }, + checkRequired("version", version), + brand, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalContent = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + version() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalContent && + elements == other.elements && + version == other.version && + brand == other.brand && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, version, brand, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt index c0d905c7..ca5b8af9 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalGroupNode.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.send +package com.courier.api.models.tenants.templates import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt index 17b2304e..0f1d982c 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.send +package com.courier.api.models.tenants.templates import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt new file mode 100644 index 00000000..815f14c1 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt @@ -0,0 +1,236 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.Params +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** List Templates in Tenant */ +class TemplateListParams +private constructor( + private val tenantId: String?, + private val cursor: String?, + private val limit: Long?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tenantId(): Optional = Optional.ofNullable(tenantId) + + /** Continue the pagination with the next cursor */ + fun cursor(): Optional = Optional.ofNullable(cursor) + + /** The number of templates to return (defaults to 20, maximum value of 100) */ + fun limit(): Optional = Optional.ofNullable(limit) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): TemplateListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [TemplateListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TemplateListParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var cursor: String? = null + private var limit: Long? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(templateListParams: TemplateListParams) = apply { + tenantId = templateListParams.tenantId + cursor = templateListParams.cursor + limit = templateListParams.limit + additionalHeaders = templateListParams.additionalHeaders.toBuilder() + additionalQueryParams = templateListParams.additionalQueryParams.toBuilder() + } + + fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** Continue the pagination with the next cursor */ + fun cursor(cursor: String?) = apply { this.cursor = cursor } + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** The number of templates to return (defaults to 20, maximum value of 100) */ + fun limit(limit: Long?) = apply { this.limit = limit } + + /** + * Alias for [Builder.limit]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun limit(limit: Long) = limit(limit as Long?) + + /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ + fun limit(limit: Optional) = limit(limit.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TemplateListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TemplateListParams = + TemplateListParams( + tenantId, + cursor, + limit, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + cursor?.let { put("cursor", it) } + limit?.let { put("limit", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TemplateListParams && + tenantId == other.tenantId && + cursor == other.cursor && + limit == other.limit && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tenantId, cursor, limit, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TemplateListParams{tenantId=$tenantId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt new file mode 100644 index 00000000..5447eab6 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt @@ -0,0 +1,1030 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.notifications.MessageRouting +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class TemplateListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val hasMore: JsonField, + private val type: JsonField, + private val url: JsonField, + private val cursor: JsonField, + private val items: JsonField>, + private val nextUrl: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), + ) : this(hasMore, type, url, cursor, items, nextUrl, mutableMapOf()) + + /** + * Set to true when there are more pages that can be retrieved. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasMore(): Boolean = hasMore.getRequired("has_more") + + /** + * Always set to `list`. Represents the type of this object. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun type(): Type = type.getRequired("type") + + /** + * A url that may be used to generate these results. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun url(): String = url.getRequired("url") + + /** + * A pointer to the next page of results. Defined only when `has_more` is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun cursor(): Optional = cursor.getOptional("cursor") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("items") + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * `has_more` is set to true + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nextUrl(): Optional = nextUrl.getOptional("next_url") + + /** + * Returns the raw JSON value of [hasMore]. + * + * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [cursor]. + * + * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [nextUrl]. + * + * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TemplateListResponse]. + * + * The following fields are required: + * ```java + * .hasMore() + * .type() + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TemplateListResponse]. */ + class Builder internal constructor() { + + private var hasMore: JsonField? = null + private var type: JsonField? = null + private var url: JsonField? = null + private var cursor: JsonField = JsonMissing.of() + private var items: JsonField>? = null + private var nextUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(templateListResponse: TemplateListResponse) = apply { + hasMore = templateListResponse.hasMore + type = templateListResponse.type + url = templateListResponse.url + cursor = templateListResponse.cursor + items = templateListResponse.items.map { it.toMutableList() } + nextUrl = templateListResponse.nextUrl + additionalProperties = templateListResponse.additionalProperties.toMutableMap() + } + + /** Set to true when there are more pages that can be retrieved. */ + fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) + + /** + * Sets [Builder.hasMore] to an arbitrary JSON value. + * + * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } + + /** Always set to `list`. Represents the type of this object. */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** A url that may be used to generate these results. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** A pointer to the next page of results. Defined only when `has_more` is set to true */ + fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) + + /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ + fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) + + /** + * Sets [Builder.cursor] to an arbitrary JSON value. + * + * You should usually call [Builder.cursor] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cursor(cursor: JsonField) = apply { this.cursor = cursor } + + fun items(items: List?) = items(JsonField.ofNullable(items)) + + /** Alias for calling [Builder.items] with `items.orElse(null)`. */ + fun items(items: Optional>) = items(items.getOrNull()) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + /** + * A url that may be used to generate fetch the next set of results. Defined only when + * `has_more` is set to true + */ + fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) + + /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ + fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) + + /** + * Sets [Builder.nextUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TemplateListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .hasMore() + * .type() + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TemplateListResponse = + TemplateListResponse( + checkRequired("hasMore", hasMore), + checkRequired("type", type), + checkRequired("url", url), + cursor, + (items ?: JsonMissing.of()).map { it.toImmutable() }, + nextUrl, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TemplateListResponse = apply { + if (validated) { + return@apply + } + + hasMore() + type().validate() + url() + cursor() + items().ifPresent { it.forEach { it.validate() } } + nextUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (hasMore.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (url.asKnown().isPresent) 1 else 0) + + (if (cursor.asKnown().isPresent) 1 else 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (nextUrl.asKnown().isPresent) 1 else 0) + + /** Always set to `list`. Represents the type of this object. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val LIST = of("list") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + LIST + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + LIST, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + LIST -> Value.LIST + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + LIST -> Known.LIST + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val createdAt: JsonField, + private val publishedAt: JsonField, + private val updatedAt: JsonField, + private val version: JsonField, + private val data: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("published_at") + @ExcludeMissing + publishedAt: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(id, createdAt, publishedAt, updatedAt, version, data, mutableMapOf()) + + fun toBaseTemplateTenantAssociation(): BaseTemplateTenantAssociation = + BaseTemplateTenantAssociation.builder() + .id(id) + .createdAt(createdAt) + .publishedAt(publishedAt) + .updatedAt(updatedAt) + .version(version) + .build() + + /** + * The template's id + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun id(): String = id.getRequired("id") + + /** + * The timestamp at which the template was created + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): String = createdAt.getRequired("created_at") + + /** + * The timestamp at which the template was published + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun publishedAt(): String = publishedAt.getRequired("published_at") + + /** + * The timestamp at which the template was last updated + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun updatedAt(): String = updatedAt.getRequired("updated_at") + + /** + * The version of the template + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + /** + * The template's data containing it's routing configs + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + + /** + * Returns the raw JSON value of [publishedAt]. + * + * Unlike [publishedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("published_at") + @ExcludeMissing + fun _publishedAt(): JsonField = publishedAt + + /** + * Returns the raw JSON value of [updatedAt]. + * + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Item]. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .publishedAt() + * .updatedAt() + * .version() + * .data() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var publishedAt: JsonField? = null + private var updatedAt: JsonField? = null + private var version: JsonField? = null + private var data: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + id = item.id + createdAt = item.createdAt + publishedAt = item.publishedAt + updatedAt = item.updatedAt + version = item.version + data = item.data + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The template's id */ + fun id(id: String) = id(JsonField.of(id)) + + /** + * Sets [Builder.id] to an arbitrary JSON value. + * + * You should usually call [Builder.id] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun id(id: JsonField) = apply { this.id = id } + + /** The timestamp at which the template was created */ + fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + + /** The timestamp at which the template was published */ + fun publishedAt(publishedAt: String) = publishedAt(JsonField.of(publishedAt)) + + /** + * Sets [Builder.publishedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.publishedAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun publishedAt(publishedAt: JsonField) = apply { + this.publishedAt = publishedAt + } + + /** The timestamp at which the template was last updated */ + fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) + + /** + * Sets [Builder.updatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + + /** The version of the template */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + /** The template's data containing it's routing configs */ + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .createdAt() + * .publishedAt() + * .updatedAt() + * .version() + * .data() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Item = + Item( + checkRequired("id", id), + checkRequired("createdAt", createdAt), + checkRequired("publishedAt", publishedAt), + checkRequired("updatedAt", updatedAt), + checkRequired("version", version), + checkRequired("data", data), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + id() + createdAt() + publishedAt() + updatedAt() + version() + data().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (publishedAt.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + /** The template's data containing it's routing configs */ + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val routing: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("routing") + @ExcludeMissing + routing: JsonField = JsonMissing.of() + ) : this(routing, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun routing(): MessageRouting = routing.getRequired("routing") + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") + @ExcludeMissing + fun _routing(): JsonField = routing + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Data]. + * + * The following fields are required: + * ```java + * .routing() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var routing: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + routing = data.routing + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun routing(routing: MessageRouting) = routing(JsonField.of(routing)) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [MessageRouting] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun routing(routing: JsonField) = apply { this.routing = routing } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .routing() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Data = + Data(checkRequired("routing", routing), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + routing().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (routing.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + routing == other.routing && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(routing, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{routing=$routing, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + id == other.id && + createdAt == other.createdAt && + publishedAt == other.publishedAt && + updatedAt == other.updatedAt && + version == other.version && + data == other.data && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, createdAt, publishedAt, updatedAt, version, data, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, data=$data, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TemplateListResponse && + hasMore == other.hasMore && + type == other.type && + url == other.url && + cursor == other.cursor && + items == other.items && + nextUrl == other.nextUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(hasMore, type, url, cursor, items, nextUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TemplateListResponse{hasMore=$hasMore, type=$type, url=$url, cursor=$cursor, items=$items, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt new file mode 100644 index 00000000..58f4908c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt @@ -0,0 +1,217 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.Params +import com.courier.api.core.checkRequired +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Get a Template in Tenant */ +class TemplateRetrieveParams +private constructor( + private val tenantId: String, + private val templateId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun tenantId(): String = tenantId + + fun templateId(): Optional = Optional.ofNullable(templateId) + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [TemplateRetrieveParams]. + * + * The following fields are required: + * ```java + * .tenantId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TemplateRetrieveParams]. */ + class Builder internal constructor() { + + private var tenantId: String? = null + private var templateId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(templateRetrieveParams: TemplateRetrieveParams) = apply { + tenantId = templateRetrieveParams.tenantId + templateId = templateRetrieveParams.templateId + additionalHeaders = templateRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = templateRetrieveParams.additionalQueryParams.toBuilder() + } + + fun tenantId(tenantId: String) = apply { this.tenantId = tenantId } + + fun templateId(templateId: String?) = apply { this.templateId = templateId } + + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [TemplateRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tenantId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TemplateRetrieveParams = + TemplateRetrieveParams( + checkRequired("tenantId", tenantId), + templateId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> tenantId + 1 -> templateId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TemplateRetrieveParams && + tenantId == other.tenantId && + templateId == other.templateId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(tenantId, templateId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TemplateRetrieveParams{tenantId=$tenantId, templateId=$templateId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt similarity index 88% rename from courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt index 4cb39559..8bbc02b8 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt @@ -11,7 +11,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Get single token available for a `:token` */ -class TokenRetrieveSingleParams +class TokenRetrieveParams private constructor( private val userId: String, private val token: String?, @@ -34,7 +34,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TokenRetrieveSingleParams]. + * Returns a mutable builder for constructing an instance of [TokenRetrieveParams]. * * The following fields are required: * ```java @@ -44,7 +44,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TokenRetrieveSingleParams]. */ + /** A builder for [TokenRetrieveParams]. */ class Builder internal constructor() { private var userId: String? = null @@ -53,11 +53,11 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(tokenRetrieveSingleParams: TokenRetrieveSingleParams) = apply { - userId = tokenRetrieveSingleParams.userId - token = tokenRetrieveSingleParams.token - additionalHeaders = tokenRetrieveSingleParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenRetrieveSingleParams.additionalQueryParams.toBuilder() + internal fun from(tokenRetrieveParams: TokenRetrieveParams) = apply { + userId = tokenRetrieveParams.userId + token = tokenRetrieveParams.token + additionalHeaders = tokenRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = tokenRetrieveParams.additionalQueryParams.toBuilder() } fun userId(userId: String) = apply { this.userId = userId } @@ -166,7 +166,7 @@ private constructor( } /** - * Returns an immutable instance of [TokenRetrieveSingleParams]. + * Returns an immutable instance of [TokenRetrieveParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -177,8 +177,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TokenRetrieveSingleParams = - TokenRetrieveSingleParams( + fun build(): TokenRetrieveParams = + TokenRetrieveParams( checkRequired("userId", userId), token, additionalHeaders.build(), @@ -202,7 +202,7 @@ private constructor( return true } - return other is TokenRetrieveSingleParams && + return other is TokenRetrieveParams && userId == other.userId && token == other.token && additionalHeaders == other.additionalHeaders && @@ -213,5 +213,5 @@ private constructor( Objects.hash(userId, token, additionalHeaders, additionalQueryParams) override fun toString() = - "TokenRetrieveSingleParams{userId=$userId, token=$token, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "TokenRetrieveParams{userId=$userId, token=$token, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt similarity index 94% rename from courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt index 93319ec8..981fe28e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt @@ -18,7 +18,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -class TokenRetrieveSingleResponse +class TokenRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val providerKey: JsonField, @@ -202,7 +202,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TokenRetrieveSingleResponse]. + * Returns a mutable builder for constructing an instance of [TokenRetrieveResponse]. * * The following fields are required: * ```java @@ -212,7 +212,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TokenRetrieveSingleResponse]. */ + /** A builder for [TokenRetrieveResponse]. */ class Builder internal constructor() { private var providerKey: JsonField? = null @@ -226,16 +226,16 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(tokenRetrieveSingleResponse: TokenRetrieveSingleResponse) = apply { - providerKey = tokenRetrieveSingleResponse.providerKey - token = tokenRetrieveSingleResponse.token - device = tokenRetrieveSingleResponse.device - expiryDate = tokenRetrieveSingleResponse.expiryDate - properties = tokenRetrieveSingleResponse.properties - tracking = tokenRetrieveSingleResponse.tracking - status = tokenRetrieveSingleResponse.status - statusReason = tokenRetrieveSingleResponse.statusReason - additionalProperties = tokenRetrieveSingleResponse.additionalProperties.toMutableMap() + internal fun from(tokenRetrieveResponse: TokenRetrieveResponse) = apply { + providerKey = tokenRetrieveResponse.providerKey + token = tokenRetrieveResponse.token + device = tokenRetrieveResponse.device + expiryDate = tokenRetrieveResponse.expiryDate + properties = tokenRetrieveResponse.properties + tracking = tokenRetrieveResponse.tracking + status = tokenRetrieveResponse.status + statusReason = tokenRetrieveResponse.statusReason + additionalProperties = tokenRetrieveResponse.additionalProperties.toMutableMap() } fun providerKey(providerKey: UserToken.ProviderKey) = providerKey(JsonField.of(providerKey)) @@ -376,7 +376,7 @@ private constructor( } /** - * Returns an immutable instance of [TokenRetrieveSingleResponse]. + * Returns an immutable instance of [TokenRetrieveResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -387,8 +387,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TokenRetrieveSingleResponse = - TokenRetrieveSingleResponse( + fun build(): TokenRetrieveResponse = + TokenRetrieveResponse( checkRequired("providerKey", providerKey), token, device, @@ -403,7 +403,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TokenRetrieveSingleResponse = apply { + fun validate(): TokenRetrieveResponse = apply { if (validated) { return@apply } @@ -583,7 +583,7 @@ private constructor( return true } - return other is TokenRetrieveSingleResponse && + return other is TokenRetrieveResponse && providerKey == other.providerKey && token == other.token && device == other.device && @@ -612,5 +612,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TokenRetrieveSingleResponse{providerKey=$providerKey, token=$token, device=$device, expiryDate=$expiryDate, properties=$properties, tracking=$tracking, status=$status, statusReason=$statusReason, additionalProperties=$additionalProperties}" + "TokenRetrieveResponse{providerKey=$providerKey, token=$token, device=$device, expiryDate=$expiryDate, properties=$properties, tracking=$tracking, status=$status, statusReason=$statusReason, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt index 948d0f1e..8652504a 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt @@ -3,13 +3,7 @@ package com.courier.api.services.async import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.automations.AutomationInvokeAdHocParams -import com.courier.api.models.automations.AutomationInvokeByTemplateParams -import com.courier.api.models.automations.invoke.AutomationInvokeResponse import com.courier.api.services.async.automations.InvokeServiceAsync -import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface AutomationServiceAsync { @@ -28,47 +22,6 @@ interface AutomationServiceAsync { fun invoke(): InvokeServiceAsync - /** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of - * automation steps. For information about what steps are available, checkout the ad hoc - * automation guide [here](https://www.courier.com/docs/automations/steps/). - */ - fun invokeAdHoc( - params: AutomationInvokeAdHocParams - ): CompletableFuture = invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Invoke an automation run from an automation template. */ - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - ): CompletableFuture = - invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams - ): CompletableFuture = invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** * A view of [AutomationServiceAsync] that provides access to raw HTTP responses for each * method. @@ -85,50 +38,5 @@ interface AutomationServiceAsync { ): AutomationServiceAsync.WithRawResponse fun invoke(): InvokeServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as - * [AutomationServiceAsync.invokeAdHoc]. - */ - fun invokeAdHoc( - params: AutomationInvokeAdHocParams - ): CompletableFuture> = - invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise - * the same as [AutomationServiceAsync.invokeByTemplate]. - */ - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - ): CompletableFuture> = - invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams - ): CompletableFuture> = - invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt index 3278e90b..1c512834 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt @@ -3,27 +3,9 @@ package com.courier.api.services.async import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.automations.AutomationInvokeAdHocParams -import com.courier.api.models.automations.AutomationInvokeByTemplateParams -import com.courier.api.models.automations.invoke.AutomationInvokeResponse import com.courier.api.services.async.automations.InvokeServiceAsync import com.courier.api.services.async.automations.InvokeServiceAsyncImpl -import java.util.concurrent.CompletableFuture import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull class AutomationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AutomationServiceAsync { @@ -41,26 +23,9 @@ class AutomationServiceAsyncImpl internal constructor(private val clientOptions: override fun invoke(): InvokeServiceAsync = invoke - override fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /automations/invoke - withRawResponse().invokeAdHoc(params, requestOptions).thenApply { it.parse() } - - override fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /automations/{templateId}/invoke - withRawResponse().invokeByTemplate(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AutomationServiceAsync.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - private val invoke: InvokeServiceAsync.WithRawResponse by lazy { InvokeServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -73,70 +38,5 @@ class AutomationServiceAsyncImpl internal constructor(private val clientOptions: ) override fun invoke(): InvokeServiceAsync.WithRawResponse = invoke - - private val invokeAdHocHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { invokeAdHocHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val invokeByTemplateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("templateId", params.templateId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", params._pathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { invokeByTemplateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt index 469f7ca0..ecf11b2e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt @@ -65,7 +65,7 @@ interface ListServiceAsync { retrieve(listId, ListRetrieveParams.none(), requestOptions) /** Create or replace an existing list with the supplied values. */ - fun update(listId: String, params: ListUpdateParams): CompletableFuture = + fun update(listId: String, params: ListUpdateParams): CompletableFuture = update(listId, params, RequestOptions.none()) /** @see update */ @@ -73,17 +73,17 @@ interface ListServiceAsync { listId: String, params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().listId(listId).build(), requestOptions) + ): CompletableFuture = update(params.toBuilder().listId(listId).build(), requestOptions) /** @see update */ - fun update(params: ListUpdateParams): CompletableFuture = + fun update(params: ListUpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** Returns all of the lists, with the ability to filter based on a pattern. */ fun list(): CompletableFuture = list(ListListParams.none()) @@ -133,21 +133,19 @@ interface ListServiceAsync { delete(listId, ListDeleteParams.none(), requestOptions) /** Restore a previously deleted list. */ - fun restore(listId: String): CompletableFuture = - restore(listId, ListRestoreParams.none()) + fun restore(listId: String, params: ListRestoreParams): CompletableFuture = + restore(listId, params, RequestOptions.none()) /** @see restore */ fun restore( listId: String, - params: ListRestoreParams = ListRestoreParams.none(), + params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = restore(params.toBuilder().listId(listId).build(), requestOptions) /** @see restore */ - fun restore( - listId: String, - params: ListRestoreParams = ListRestoreParams.none(), - ): CompletableFuture = restore(listId, params, RequestOptions.none()) + fun restore(params: ListRestoreParams): CompletableFuture = + restore(params, RequestOptions.none()) /** @see restore */ fun restore( @@ -155,14 +153,6 @@ interface ListServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see restore */ - fun restore(params: ListRestoreParams): CompletableFuture = - restore(params, RequestOptions.none()) - - /** @see restore */ - fun restore(listId: String, requestOptions: RequestOptions): CompletableFuture = - restore(listId, ListRestoreParams.none(), requestOptions) - /** A view of [ListServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -218,28 +208,26 @@ interface ListServiceAsync { * Returns a raw HTTP response for `put /lists/{list_id}`, but is otherwise the same as * [ListServiceAsync.update]. */ - fun update( - listId: String, - params: ListUpdateParams, - ): CompletableFuture> = update(listId, params, RequestOptions.none()) + fun update(listId: String, params: ListUpdateParams): CompletableFuture = + update(listId, params, RequestOptions.none()) /** @see update */ fun update( listId: String, params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture = update(params.toBuilder().listId(listId).build(), requestOptions) /** @see update */ - fun update(params: ListUpdateParams): CompletableFuture> = + fun update(params: ListUpdateParams): CompletableFuture = update(params, RequestOptions.none()) /** @see update */ fun update( params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture /** * Returns a raw HTTP response for `get /lists`, but is otherwise the same as @@ -307,38 +295,25 @@ interface ListServiceAsync { * Returns a raw HTTP response for `put /lists/{list_id}/restore`, but is otherwise the same * as [ListServiceAsync.restore]. */ - fun restore(listId: String): CompletableFuture = - restore(listId, ListRestoreParams.none()) + fun restore(listId: String, params: ListRestoreParams): CompletableFuture = + restore(listId, params, RequestOptions.none()) /** @see restore */ fun restore( listId: String, - params: ListRestoreParams = ListRestoreParams.none(), + params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = restore(params.toBuilder().listId(listId).build(), requestOptions) /** @see restore */ - fun restore( - listId: String, - params: ListRestoreParams = ListRestoreParams.none(), - ): CompletableFuture = restore(listId, params, RequestOptions.none()) + fun restore(params: ListRestoreParams): CompletableFuture = + restore(params, RequestOptions.none()) /** @see restore */ fun restore( params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - - /** @see restore */ - fun restore(params: ListRestoreParams): CompletableFuture = - restore(params, RequestOptions.none()) - - /** @see restore */ - fun restore( - listId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - restore(listId, ListRestoreParams.none(), requestOptions) } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt index 1afe7a8f..5dc5052d 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt @@ -58,9 +58,9 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun update( params: ListUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // put /lists/{list_id} - withRawResponse().update(params, requestOptions).thenApply { it.parse() } + withRawResponse().update(params, requestOptions).thenAccept {} override fun list( params: ListListParams, @@ -134,12 +134,12 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = emptyHandler() override fun update( params: ListUpdateParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("listId", params.listId().getOrNull()) @@ -156,13 +156,7 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } .thenApply { response -> errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + response.use { updateHandler.handle(it) } } } } @@ -238,7 +232,7 @@ class ListServiceAsyncImpl internal constructor(private val clientOptions: Clien .method(HttpMethod.PUT) .baseUrl(clientOptions.baseUrl()) .addPathSegments("lists", params._pathParam(0), "restore") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt index b8cb8b7f..85e62f76 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt @@ -6,9 +6,9 @@ import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageContentParams +import com.courier.api.models.messages.MessageContentResponse import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageGetContentParams -import com.courier.api.models.messages.MessageGetContentResponse import com.courier.api.models.messages.MessageHistoryParams import com.courier.api.models.messages.MessageHistoryResponse import com.courier.api.models.messages.MessageListParams @@ -127,40 +127,39 @@ interface MessageServiceAsync { cancel(messageId, MessageCancelParams.none(), requestOptions) /** Get message content */ - fun getContent(messageId: String): CompletableFuture = - getContent(messageId, MessageGetContentParams.none()) + fun content(messageId: String): CompletableFuture = + content(messageId, MessageContentParams.none()) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), + params: MessageContentParams = MessageContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + ): CompletableFuture = + content(params.toBuilder().messageId(messageId).build(), requestOptions) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), - ): CompletableFuture = - getContent(messageId, params, RequestOptions.none()) + params: MessageContentParams = MessageContentParams.none(), + ): CompletableFuture = content(messageId, params, RequestOptions.none()) - /** @see getContent */ - fun getContent( - params: MessageGetContentParams, + /** @see content */ + fun content( + params: MessageContentParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture - /** @see getContent */ - fun getContent(params: MessageGetContentParams): CompletableFuture = - getContent(params, RequestOptions.none()) + /** @see content */ + fun content(params: MessageContentParams): CompletableFuture = + content(params, RequestOptions.none()) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, requestOptions: RequestOptions, - ): CompletableFuture = - getContent(messageId, MessageGetContentParams.none(), requestOptions) + ): CompletableFuture = + content(messageId, MessageContentParams.none(), requestOptions) /** Fetch the array of events of a message you've previously sent. */ fun history(messageId: String): CompletableFuture = @@ -322,46 +321,44 @@ interface MessageServiceAsync { /** * Returns a raw HTTP response for `get /messages/{message_id}/output`, but is otherwise the - * same as [MessageServiceAsync.getContent]. + * same as [MessageServiceAsync.content]. */ - fun getContent( - messageId: String - ): CompletableFuture> = - getContent(messageId, MessageGetContentParams.none()) + fun content(messageId: String): CompletableFuture> = + content(messageId, MessageContentParams.none()) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), + params: MessageContentParams = MessageContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + ): CompletableFuture> = + content(params.toBuilder().messageId(messageId).build(), requestOptions) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), - ): CompletableFuture> = - getContent(messageId, params, RequestOptions.none()) + params: MessageContentParams = MessageContentParams.none(), + ): CompletableFuture> = + content(messageId, params, RequestOptions.none()) - /** @see getContent */ - fun getContent( - params: MessageGetContentParams, + /** @see content */ + fun content( + params: MessageContentParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> - /** @see getContent */ - fun getContent( - params: MessageGetContentParams - ): CompletableFuture> = - getContent(params, RequestOptions.none()) + /** @see content */ + fun content( + params: MessageContentParams + ): CompletableFuture> = + content(params, RequestOptions.none()) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, requestOptions: RequestOptions, - ): CompletableFuture> = - getContent(messageId, MessageGetContentParams.none(), requestOptions) + ): CompletableFuture> = + content(messageId, MessageContentParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /messages/{message_id}/history`, but is otherwise diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt index ad3d38ed..6eb0b364 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt @@ -17,9 +17,9 @@ import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepareAsync import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageContentParams +import com.courier.api.models.messages.MessageContentResponse import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageGetContentParams -import com.courier.api.models.messages.MessageGetContentResponse import com.courier.api.models.messages.MessageHistoryParams import com.courier.api.models.messages.MessageHistoryResponse import com.courier.api.models.messages.MessageListParams @@ -63,12 +63,12 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl // post /messages/{message_id}/cancel withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } - override fun getContent( - params: MessageGetContentParams, + override fun content( + params: MessageContentParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /messages/{message_id}/output - withRawResponse().getContent(params, requestOptions).thenApply { it.parse() } + withRawResponse().content(params, requestOptions).thenApply { it.parse() } override fun history( params: MessageHistoryParams, @@ -187,13 +187,13 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val getContentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val contentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun getContent( - params: MessageGetContentParams, + override fun content( + params: MessageContentParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("messageId", params.messageId().getOrNull()) @@ -210,7 +210,7 @@ class MessageServiceAsyncImpl internal constructor(private val clientOptions: Cl .thenApply { response -> errorHandler.handle(response).parseable { response - .use { getContentHandler.handle(it) } + .use { contentHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt index 5af8249b..ce07f17e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt @@ -15,6 +15,7 @@ import com.courier.api.models.tenants.TenantListUsersResponse import com.courier.api.models.tenants.TenantRetrieveParams import com.courier.api.models.tenants.TenantUpdateParams import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsync +import com.courier.api.services.async.tenants.TemplateServiceAsync import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -34,6 +35,8 @@ interface TenantServiceAsync { fun defaultPreferences(): DefaultPreferenceServiceAsync + fun templates(): TemplateServiceAsync + /** Get a Tenant */ fun retrieve(tenantId: String): CompletableFuture = retrieve(tenantId, TenantRetrieveParams.none()) @@ -190,6 +193,8 @@ interface TenantServiceAsync { fun defaultPreferences(): DefaultPreferenceServiceAsync.WithRawResponse + fun templates(): TemplateServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /tenants/{tenant_id}`, but is otherwise the same as * [TenantServiceAsync.retrieve]. diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt index 750709d0..44e59a6b 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt @@ -27,6 +27,8 @@ import com.courier.api.models.tenants.TenantRetrieveParams import com.courier.api.models.tenants.TenantUpdateParams import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsync import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsyncImpl +import com.courier.api.services.async.tenants.TemplateServiceAsync +import com.courier.api.services.async.tenants.TemplateServiceAsyncImpl import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -42,6 +44,8 @@ class TenantServiceAsyncImpl internal constructor(private val clientOptions: Cli DefaultPreferenceServiceAsyncImpl(clientOptions) } + private val templates: TemplateServiceAsync by lazy { TemplateServiceAsyncImpl(clientOptions) } + override fun withRawResponse(): TenantServiceAsync.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): TenantServiceAsync = @@ -49,6 +53,8 @@ class TenantServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun defaultPreferences(): DefaultPreferenceServiceAsync = defaultPreferences + override fun templates(): TemplateServiceAsync = templates + override fun retrieve( params: TenantRetrieveParams, requestOptions: RequestOptions, @@ -94,6 +100,10 @@ class TenantServiceAsyncImpl internal constructor(private val clientOptions: Cli DefaultPreferenceServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val templates: TemplateServiceAsync.WithRawResponse by lazy { + TemplateServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): TenantServiceAsync.WithRawResponse = @@ -104,6 +114,8 @@ class TenantServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun defaultPreferences(): DefaultPreferenceServiceAsync.WithRawResponse = defaultPreferences + override fun templates(): TemplateServiceAsync.WithRawResponse = templates + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun retrieve( diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt index 7885bbed..0c6046a7 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt @@ -3,6 +3,12 @@ package com.courier.api.services.async.automations import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams +import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams +import java.util.concurrent.CompletableFuture import java.util.function.Consumer interface InvokeServiceAsync { @@ -19,6 +25,46 @@ interface InvokeServiceAsync { */ fun withOptions(modifier: Consumer): InvokeServiceAsync + /** + * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of + * automation steps. For information about what steps are available, checkout the ad hoc + * automation guide [here](https://www.courier.com/docs/automations/steps/). + */ + fun invokeAdHoc(params: InvokeInvokeAdHocParams): CompletableFuture = + invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** Invoke an automation run from an automation template. */ + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + ): CompletableFuture = + invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams + ): CompletableFuture = invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * A view of [InvokeServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -32,5 +78,50 @@ interface InvokeServiceAsync { fun withOptions( modifier: Consumer ): InvokeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as + * [InvokeServiceAsync.invokeAdHoc]. + */ + fun invokeAdHoc( + params: InvokeInvokeAdHocParams + ): CompletableFuture> = + invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise + * the same as [InvokeServiceAsync.invokeByTemplate]. + */ + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + ): CompletableFuture> = + invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams + ): CompletableFuture> = + invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt index ee9fe041..5f95c7e1 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt @@ -3,7 +3,25 @@ package com.courier.api.services.async.automations import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams +import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams +import java.util.concurrent.CompletableFuture import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull class InvokeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : InvokeServiceAsync { @@ -17,14 +35,96 @@ class InvokeServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): InvokeServiceAsync = InvokeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /automations/invoke + withRawResponse().invokeAdHoc(params, requestOptions).thenApply { it.parse() } + + override fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /automations/{templateId}/invoke + withRawResponse().invokeByTemplate(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InvokeServiceAsync.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): InvokeServiceAsync.WithRawResponse = InvokeServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val invokeAdHocHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { invokeAdHocHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val invokeByTemplateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("templateId", params.templateId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", params._pathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { invokeByTemplateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt new file mode 100644 index 00000000..57f29c9f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation +import com.courier.api.models.tenants.templates.TemplateListParams +import com.courier.api.models.tenants.templates.TemplateListResponse +import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface TemplateServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TemplateServiceAsync + + /** Get a Template in Tenant */ + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + ): CompletableFuture = + retrieve(templateId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TemplateRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** List Templates in Tenant */ + fun list(tenantId: String): CompletableFuture = + list(tenantId, TemplateListParams.none()) + + /** @see list */ + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + list(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see list */ + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + ): CompletableFuture = list(tenantId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TemplateListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list(params: TemplateListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + tenantId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + list(tenantId, TemplateListParams.none(), requestOptions) + + /** + * A view of [TemplateServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): TemplateServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates/{template_id}`, but + * is otherwise the same as [TemplateServiceAsync.retrieve]. + */ + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + ): CompletableFuture> = + retrieve(templateId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: TemplateRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise + * the same as [TemplateServiceAsync.list]. + */ + fun list(tenantId: String): CompletableFuture> = + list(tenantId, TemplateListParams.none()) + + /** @see list */ + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + list(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see list */ + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + ): CompletableFuture> = + list(tenantId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TemplateListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: TemplateListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + tenantId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + list(tenantId, TemplateListParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt new file mode 100644 index 00000000..7cf0f7a1 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepareAsync +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation +import com.courier.api.models.tenants.templates.TemplateListParams +import com.courier.api.models.tenants.templates.TemplateListResponse +import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TemplateServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + TemplateServiceAsync { + + private val withRawResponse: TemplateServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TemplateServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TemplateServiceAsync = + TemplateServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /tenants/{tenant_id}/templates/{template_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: TemplateListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /tenants/{tenant_id}/templates + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TemplateServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TemplateServiceAsync.WithRawResponse = + TemplateServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("templateId", params.templateId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "tenants", + params._pathParam(0), + "templates", + params._pathParam(1), + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TemplateListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0), "templates") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt index d0dac405..0e63f364 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt @@ -10,8 +10,8 @@ import com.courier.api.models.users.tokens.TokenAddMultipleParams import com.courier.api.models.users.tokens.TokenAddSingleParams import com.courier.api.models.users.tokens.TokenDeleteParams import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenRetrieveParams +import com.courier.api.models.users.tokens.TokenRetrieveResponse import com.courier.api.models.users.tokens.TokenUpdateParams import com.courier.api.models.users.tokens.UserToken import java.util.concurrent.CompletableFuture @@ -31,6 +31,30 @@ interface TokenServiceAsync { */ fun withOptions(modifier: Consumer): TokenServiceAsync + /** Get single token available for a `:token` */ + fun retrieve( + token: String, + params: TokenRetrieveParams, + ): CompletableFuture = retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TokenRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** Apply a JSON Patch (RFC 6902) to the specified token. */ fun update(token: String, params: TokenUpdateParams): CompletableFuture = update(token, params, RequestOptions.none()) @@ -159,33 +183,6 @@ interface TokenServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Get single token available for a `:token` */ - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - ): CompletableFuture = - retrieveSingle(token, params, RequestOptions.none()) - - /** @see retrieveSingle */ - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveSingle(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieveSingle */ - fun retrieveSingle( - params: TokenRetrieveSingleParams - ): CompletableFuture = - retrieveSingle(params, RequestOptions.none()) - - /** @see retrieveSingle */ - fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - /** A view of [TokenServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -198,6 +195,36 @@ interface TokenServiceAsync { modifier: Consumer ): TokenServiceAsync.WithRawResponse + /** + * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenServiceAsync.retrieve]. + */ + fun retrieve( + token: String, + params: TokenRetrieveParams, + ): CompletableFuture> = + retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `patch /users/{user_id}/tokens/{token}`, but is otherwise * the same as [TokenServiceAsync.update]. @@ -351,35 +378,5 @@ interface TokenServiceAsync { params: TokenAddSingleParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenServiceAsync.retrieveSingle]. - */ - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - ): CompletableFuture> = - retrieveSingle(token, params, RequestOptions.none()) - - /** @see retrieveSingle */ - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveSingle(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieveSingle */ - fun retrieveSingle( - params: TokenRetrieveSingleParams - ): CompletableFuture> = - retrieveSingle(params, RequestOptions.none()) - - /** @see retrieveSingle */ - fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt index 8cb2ca26..a0d80bf1 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt @@ -21,8 +21,8 @@ import com.courier.api.models.users.tokens.TokenAddMultipleParams import com.courier.api.models.users.tokens.TokenAddSingleParams import com.courier.api.models.users.tokens.TokenDeleteParams import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenRetrieveParams +import com.courier.api.models.users.tokens.TokenRetrieveResponse import com.courier.api.models.users.tokens.TokenUpdateParams import com.courier.api.models.users.tokens.UserToken import java.util.concurrent.CompletableFuture @@ -41,6 +41,13 @@ class TokenServiceAsyncImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): TokenServiceAsync = TokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /users/{user_id}/tokens/{token} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + override fun update( params: TokenUpdateParams, requestOptions: RequestOptions, @@ -76,13 +83,6 @@ class TokenServiceAsyncImpl internal constructor(private val clientOptions: Clie // put /users/{user_id}/tokens/{token} withRawResponse().addSingle(params, requestOptions).thenAccept {} - override fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /users/{user_id}/tokens/{token} - withRawResponse().retrieveSingle(params, requestOptions).thenApply { it.parse() } - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TokenServiceAsync.WithRawResponse { @@ -96,6 +96,39 @@ class TokenServiceAsyncImpl internal constructor(private val clientOptions: Clie clientOptions.toBuilder().apply(modifier::accept).build() ) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val updateHandler: Handler = emptyHandler() override fun update( @@ -236,38 +269,5 @@ class TokenServiceAsyncImpl internal constructor(private val clientOptions: Clie } } } - - private val retrieveSingleHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveSingleHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt index fa34bac4..a8f13875 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt @@ -3,13 +3,7 @@ package com.courier.api.services.blocking import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.automations.AutomationInvokeAdHocParams -import com.courier.api.models.automations.AutomationInvokeByTemplateParams -import com.courier.api.models.automations.invoke.AutomationInvokeResponse import com.courier.api.services.blocking.automations.InvokeService -import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface AutomationService { @@ -28,44 +22,6 @@ interface AutomationService { fun invoke(): InvokeService - /** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of - * automation steps. For information about what steps are available, checkout the ad hoc - * automation guide [here](https://www.courier.com/docs/automations/steps/). - */ - fun invokeAdHoc(params: AutomationInvokeAdHocParams): AutomationInvokeResponse = - invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AutomationInvokeResponse - - /** Invoke an automation run from an automation template. */ - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - ): AutomationInvokeResponse = invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AutomationInvokeResponse = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - fun invokeByTemplate(params: AutomationInvokeByTemplateParams): AutomationInvokeResponse = - invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AutomationInvokeResponse - /** A view of [AutomationService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -79,55 +35,5 @@ interface AutomationService { ): AutomationService.WithRawResponse fun invoke(): InvokeService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as - * [AutomationService.invokeAdHoc]. - */ - @MustBeClosed - fun invokeAdHoc( - params: AutomationInvokeAdHocParams - ): HttpResponseFor = invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - @MustBeClosed - fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise - * the same as [AutomationService.invokeByTemplate]. - */ - @MustBeClosed - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - ): HttpResponseFor = - invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - @MustBeClosed - fun invokeByTemplate( - templateId: String, - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - @MustBeClosed - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams - ): HttpResponseFor = - invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - @MustBeClosed - fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt index 4b501bde..e70e5232 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt @@ -3,26 +3,9 @@ package com.courier.api.services.blocking import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.automations.AutomationInvokeAdHocParams -import com.courier.api.models.automations.AutomationInvokeByTemplateParams -import com.courier.api.models.automations.invoke.AutomationInvokeResponse import com.courier.api.services.blocking.automations.InvokeService import com.courier.api.services.blocking.automations.InvokeServiceImpl import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull class AutomationServiceImpl internal constructor(private val clientOptions: ClientOptions) : AutomationService { @@ -40,26 +23,9 @@ class AutomationServiceImpl internal constructor(private val clientOptions: Clie override fun invoke(): InvokeService = invoke - override fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions, - ): AutomationInvokeResponse = - // post /automations/invoke - withRawResponse().invokeAdHoc(params, requestOptions).parse() - - override fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions, - ): AutomationInvokeResponse = - // post /automations/{templateId}/invoke - withRawResponse().invokeByTemplate(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : AutomationService.WithRawResponse { - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - private val invoke: InvokeService.WithRawResponse by lazy { InvokeServiceImpl.WithRawResponseImpl(clientOptions) } @@ -72,64 +38,5 @@ class AutomationServiceImpl internal constructor(private val clientOptions: Clie ) override fun invoke(): InvokeService.WithRawResponse = invoke - - private val invokeAdHocHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeAdHoc( - params: AutomationInvokeAdHocParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { invokeAdHocHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val invokeByTemplateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeByTemplate( - params: AutomationInvokeByTemplateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("templateId", params.templateId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", params._pathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { invokeByTemplateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt index 225cf527..bec58f03 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt @@ -61,7 +61,7 @@ interface ListService { retrieve(listId, ListRetrieveParams.none(), requestOptions) /** Create or replace an existing list with the supplied values. */ - fun update(listId: String, params: ListUpdateParams): List = + fun update(listId: String, params: ListUpdateParams) = update(listId, params, RequestOptions.none()) /** @see update */ @@ -69,16 +69,13 @@ interface ListService { listId: String, params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): List = update(params.toBuilder().listId(listId).build(), requestOptions) + ) = update(params.toBuilder().listId(listId).build(), requestOptions) /** @see update */ - fun update(params: ListUpdateParams): List = update(params, RequestOptions.none()) + fun update(params: ListUpdateParams) = update(params, RequestOptions.none()) /** @see update */ - fun update( - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): List + fun update(params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) /** Returns all of the lists, with the ability to filter based on a pattern. */ fun list(): ListListResponse = list(ListListParams.none()) @@ -122,28 +119,21 @@ interface ListService { delete(listId, ListDeleteParams.none(), requestOptions) /** Restore a previously deleted list. */ - fun restore(listId: String) = restore(listId, ListRestoreParams.none()) + fun restore(listId: String, params: ListRestoreParams) = + restore(listId, params, RequestOptions.none()) /** @see restore */ fun restore( listId: String, - params: ListRestoreParams = ListRestoreParams.none(), + params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), ) = restore(params.toBuilder().listId(listId).build(), requestOptions) - /** @see restore */ - fun restore(listId: String, params: ListRestoreParams = ListRestoreParams.none()) = - restore(listId, params, RequestOptions.none()) - - /** @see restore */ - fun restore(params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none()) - /** @see restore */ fun restore(params: ListRestoreParams) = restore(params, RequestOptions.none()) /** @see restore */ - fun restore(listId: String, requestOptions: RequestOptions) = - restore(listId, ListRestoreParams.none(), requestOptions) + fun restore(params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none()) /** A view of [ListService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -203,7 +193,7 @@ interface ListService { * [ListService.update]. */ @MustBeClosed - fun update(listId: String, params: ListUpdateParams): HttpResponseFor = + fun update(listId: String, params: ListUpdateParams): HttpResponse = update(listId, params, RequestOptions.none()) /** @see update */ @@ -212,19 +202,18 @@ interface ListService { listId: String, params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = update(params.toBuilder().listId(listId).build(), requestOptions) + ): HttpResponse = update(params.toBuilder().listId(listId).build(), requestOptions) /** @see update */ @MustBeClosed - fun update(params: ListUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) + fun update(params: ListUpdateParams): HttpResponse = update(params, RequestOptions.none()) /** @see update */ @MustBeClosed fun update( params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponse /** * Returns a raw HTTP response for `get /lists`, but is otherwise the same as @@ -293,22 +282,21 @@ interface ListService { * as [ListService.restore]. */ @MustBeClosed - fun restore(listId: String): HttpResponse = restore(listId, ListRestoreParams.none()) + fun restore(listId: String, params: ListRestoreParams): HttpResponse = + restore(listId, params, RequestOptions.none()) /** @see restore */ @MustBeClosed fun restore( listId: String, - params: ListRestoreParams = ListRestoreParams.none(), + params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse = restore(params.toBuilder().listId(listId).build(), requestOptions) /** @see restore */ @MustBeClosed - fun restore( - listId: String, - params: ListRestoreParams = ListRestoreParams.none(), - ): HttpResponse = restore(listId, params, RequestOptions.none()) + fun restore(params: ListRestoreParams): HttpResponse = + restore(params, RequestOptions.none()) /** @see restore */ @MustBeClosed @@ -316,15 +304,5 @@ interface ListService { params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - - /** @see restore */ - @MustBeClosed - fun restore(params: ListRestoreParams): HttpResponse = - restore(params, RequestOptions.none()) - - /** @see restore */ - @MustBeClosed - fun restore(listId: String, requestOptions: RequestOptions): HttpResponse = - restore(listId, ListRestoreParams.none(), requestOptions) } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt index 626fa491..68e42a9e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt @@ -50,9 +50,10 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti // get /lists/{list_id} withRawResponse().retrieve(params, requestOptions).parse() - override fun update(params: ListUpdateParams, requestOptions: RequestOptions): List = + override fun update(params: ListUpdateParams, requestOptions: RequestOptions) { // put /lists/{list_id} - withRawResponse().update(params, requestOptions).parse() + withRawResponse().update(params, requestOptions) + } override fun list(params: ListListParams, requestOptions: RequestOptions): ListListResponse = // get /lists @@ -116,12 +117,12 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) + private val updateHandler: Handler = emptyHandler() override fun update( params: ListUpdateParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponse { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("listId", params.listId().getOrNull()) @@ -136,13 +137,7 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } + response.use { updateHandler.handle(it) } } } @@ -211,7 +206,7 @@ class ListServiceImpl internal constructor(private val clientOptions: ClientOpti .method(HttpMethod.PUT) .baseUrl(clientOptions.baseUrl()) .addPathSegments("lists", params._pathParam(0), "restore") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt index a150e625..81ff9644 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt @@ -6,9 +6,9 @@ import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageContentParams +import com.courier.api.models.messages.MessageContentResponse import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageGetContentParams -import com.courier.api.models.messages.MessageGetContentResponse import com.courier.api.models.messages.MessageHistoryParams import com.courier.api.models.messages.MessageHistoryResponse import com.courier.api.models.messages.MessageListParams @@ -116,36 +116,36 @@ interface MessageService { cancel(messageId, MessageCancelParams.none(), requestOptions) /** Get message content */ - fun getContent(messageId: String): MessageGetContentResponse = - getContent(messageId, MessageGetContentParams.none()) + fun content(messageId: String): MessageContentResponse = + content(messageId, MessageContentParams.none()) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), + params: MessageContentParams = MessageContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): MessageGetContentResponse = - getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + ): MessageContentResponse = + content(params.toBuilder().messageId(messageId).build(), requestOptions) - /** @see getContent */ - fun getContent( + /** @see content */ + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), - ): MessageGetContentResponse = getContent(messageId, params, RequestOptions.none()) + params: MessageContentParams = MessageContentParams.none(), + ): MessageContentResponse = content(messageId, params, RequestOptions.none()) - /** @see getContent */ - fun getContent( - params: MessageGetContentParams, + /** @see content */ + fun content( + params: MessageContentParams, requestOptions: RequestOptions = RequestOptions.none(), - ): MessageGetContentResponse + ): MessageContentResponse - /** @see getContent */ - fun getContent(params: MessageGetContentParams): MessageGetContentResponse = - getContent(params, RequestOptions.none()) + /** @see content */ + fun content(params: MessageContentParams): MessageContentResponse = + content(params, RequestOptions.none()) - /** @see getContent */ - fun getContent(messageId: String, requestOptions: RequestOptions): MessageGetContentResponse = - getContent(messageId, MessageGetContentParams.none(), requestOptions) + /** @see content */ + fun content(messageId: String, requestOptions: RequestOptions): MessageContentResponse = + content(messageId, MessageContentParams.none(), requestOptions) /** Fetch the array of events of a message you've previously sent. */ fun history(messageId: String): MessageHistoryResponse = @@ -305,49 +305,48 @@ interface MessageService { /** * Returns a raw HTTP response for `get /messages/{message_id}/output`, but is otherwise the - * same as [MessageService.getContent]. + * same as [MessageService.content]. */ @MustBeClosed - fun getContent(messageId: String): HttpResponseFor = - getContent(messageId, MessageGetContentParams.none()) + fun content(messageId: String): HttpResponseFor = + content(messageId, MessageContentParams.none()) - /** @see getContent */ + /** @see content */ @MustBeClosed - fun getContent( + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), + params: MessageContentParams = MessageContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - getContent(params.toBuilder().messageId(messageId).build(), requestOptions) + ): HttpResponseFor = + content(params.toBuilder().messageId(messageId).build(), requestOptions) - /** @see getContent */ + /** @see content */ @MustBeClosed - fun getContent( + fun content( messageId: String, - params: MessageGetContentParams = MessageGetContentParams.none(), - ): HttpResponseFor = - getContent(messageId, params, RequestOptions.none()) + params: MessageContentParams = MessageContentParams.none(), + ): HttpResponseFor = + content(messageId, params, RequestOptions.none()) - /** @see getContent */ + /** @see content */ @MustBeClosed - fun getContent( - params: MessageGetContentParams, + fun content( + params: MessageContentParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor - /** @see getContent */ + /** @see content */ @MustBeClosed - fun getContent( - params: MessageGetContentParams - ): HttpResponseFor = getContent(params, RequestOptions.none()) + fun content(params: MessageContentParams): HttpResponseFor = + content(params, RequestOptions.none()) - /** @see getContent */ + /** @see content */ @MustBeClosed - fun getContent( + fun content( messageId: String, requestOptions: RequestOptions, - ): HttpResponseFor = - getContent(messageId, MessageGetContentParams.none(), requestOptions) + ): HttpResponseFor = + content(messageId, MessageContentParams.none(), requestOptions) /** * Returns a raw HTTP response for `get /messages/{message_id}/history`, but is otherwise diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt index ea6eb65d..5428d5e2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt @@ -17,9 +17,9 @@ import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepare import com.courier.api.models.messages.MessageCancelParams +import com.courier.api.models.messages.MessageContentParams +import com.courier.api.models.messages.MessageContentResponse import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageGetContentParams -import com.courier.api.models.messages.MessageGetContentResponse import com.courier.api.models.messages.MessageHistoryParams import com.courier.api.models.messages.MessageHistoryResponse import com.courier.api.models.messages.MessageListParams @@ -62,12 +62,12 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO // post /messages/{message_id}/cancel withRawResponse().cancel(params, requestOptions).parse() - override fun getContent( - params: MessageGetContentParams, + override fun content( + params: MessageContentParams, requestOptions: RequestOptions, - ): MessageGetContentResponse = + ): MessageContentResponse = // get /messages/{message_id}/output - withRawResponse().getContent(params, requestOptions).parse() + withRawResponse().content(params, requestOptions).parse() override fun history( params: MessageHistoryParams, @@ -177,13 +177,13 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO } } - private val getContentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val contentHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun getContent( - params: MessageGetContentParams, + override fun content( + params: MessageContentParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("messageId", params.messageId().getOrNull()) @@ -198,7 +198,7 @@ class MessageServiceImpl internal constructor(private val clientOptions: ClientO val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { getContentHandler.handle(it) } + .use { contentHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt index a4259836..e5d1d513 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt @@ -15,6 +15,7 @@ import com.courier.api.models.tenants.TenantListUsersResponse import com.courier.api.models.tenants.TenantRetrieveParams import com.courier.api.models.tenants.TenantUpdateParams import com.courier.api.services.blocking.tenants.DefaultPreferenceService +import com.courier.api.services.blocking.tenants.TemplateService import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -34,6 +35,8 @@ interface TenantService { fun defaultPreferences(): DefaultPreferenceService + fun templates(): TemplateService + /** Get a Tenant */ fun retrieve(tenantId: String): Tenant = retrieve(tenantId, TenantRetrieveParams.none()) @@ -168,6 +171,8 @@ interface TenantService { fun defaultPreferences(): DefaultPreferenceService.WithRawResponse + fun templates(): TemplateService.WithRawResponse + /** * Returns a raw HTTP response for `get /tenants/{tenant_id}`, but is otherwise the same as * [TenantService.retrieve]. diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt index 5c770be6..4ebe012a 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt @@ -27,6 +27,8 @@ import com.courier.api.models.tenants.TenantRetrieveParams import com.courier.api.models.tenants.TenantUpdateParams import com.courier.api.services.blocking.tenants.DefaultPreferenceService import com.courier.api.services.blocking.tenants.DefaultPreferenceServiceImpl +import com.courier.api.services.blocking.tenants.TemplateService +import com.courier.api.services.blocking.tenants.TemplateServiceImpl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -41,6 +43,8 @@ class TenantServiceImpl internal constructor(private val clientOptions: ClientOp DefaultPreferenceServiceImpl(clientOptions) } + private val templates: TemplateService by lazy { TemplateServiceImpl(clientOptions) } + override fun withRawResponse(): TenantService.WithRawResponse = withRawResponse override fun withOptions(modifier: Consumer): TenantService = @@ -48,6 +52,8 @@ class TenantServiceImpl internal constructor(private val clientOptions: ClientOp override fun defaultPreferences(): DefaultPreferenceService = defaultPreferences + override fun templates(): TemplateService = templates + override fun retrieve(params: TenantRetrieveParams, requestOptions: RequestOptions): Tenant = // get /tenants/{tenant_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -85,6 +91,10 @@ class TenantServiceImpl internal constructor(private val clientOptions: ClientOp DefaultPreferenceServiceImpl.WithRawResponseImpl(clientOptions) } + private val templates: TemplateService.WithRawResponse by lazy { + TemplateServiceImpl.WithRawResponseImpl(clientOptions) + } + override fun withOptions( modifier: Consumer ): TenantService.WithRawResponse = @@ -95,6 +105,8 @@ class TenantServiceImpl internal constructor(private val clientOptions: ClientOp override fun defaultPreferences(): DefaultPreferenceService.WithRawResponse = defaultPreferences + override fun templates(): TemplateService.WithRawResponse = templates + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) override fun retrieve( diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt index cbd025ff..14b7bf3c 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt @@ -3,6 +3,12 @@ package com.courier.api.services.blocking.automations import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams +import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams +import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer interface InvokeService { @@ -19,6 +25,44 @@ interface InvokeService { */ fun withOptions(modifier: Consumer): InvokeService + /** + * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of + * automation steps. For information about what steps are available, checkout the ad hoc + * automation guide [here](https://www.courier.com/docs/automations/steps/). + */ + fun invokeAdHoc(params: InvokeInvokeAdHocParams): AutomationInvokeResponse = + invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AutomationInvokeResponse + + /** Invoke an automation run from an automation template. */ + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + ): AutomationInvokeResponse = invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AutomationInvokeResponse = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + fun invokeByTemplate(params: InvokeInvokeByTemplateParams): AutomationInvokeResponse = + invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): AutomationInvokeResponse + /** A view of [InvokeService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -28,5 +72,55 @@ interface InvokeService { * The original service is not modified. */ fun withOptions(modifier: Consumer): InvokeService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as + * [InvokeService.invokeAdHoc]. + */ + @MustBeClosed + fun invokeAdHoc( + params: InvokeInvokeAdHocParams + ): HttpResponseFor = invokeAdHoc(params, RequestOptions.none()) + + /** @see invokeAdHoc */ + @MustBeClosed + fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise + * the same as [InvokeService.invokeByTemplate]. + */ + @MustBeClosed + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + ): HttpResponseFor = + invokeByTemplate(templateId, params, RequestOptions.none()) + + /** @see invokeByTemplate */ + @MustBeClosed + fun invokeByTemplate( + templateId: String, + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see invokeByTemplate */ + @MustBeClosed + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams + ): HttpResponseFor = + invokeByTemplate(params, RequestOptions.none()) + + /** @see invokeByTemplate */ + @MustBeClosed + fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt index e2ebcaa0..1501be4c 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt @@ -3,7 +3,24 @@ package com.courier.api.services.blocking.automations import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.json +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.automations.invoke.AutomationInvokeResponse +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams +import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull class InvokeServiceImpl internal constructor(private val clientOptions: ClientOptions) : InvokeService { @@ -17,14 +34,90 @@ class InvokeServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): InvokeService = InvokeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions, + ): AutomationInvokeResponse = + // post /automations/invoke + withRawResponse().invokeAdHoc(params, requestOptions).parse() + + override fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions, + ): AutomationInvokeResponse = + // post /automations/{templateId}/invoke + withRawResponse().invokeByTemplate(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InvokeService.WithRawResponse { + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + override fun withOptions( modifier: Consumer ): InvokeService.WithRawResponse = InvokeServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) + + private val invokeAdHocHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeAdHoc( + params: InvokeInvokeAdHocParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { invokeAdHocHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val invokeByTemplateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun invokeByTemplate( + params: InvokeInvokeByTemplateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("templateId", params.templateId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("automations", params._pathParam(0), "invoke") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { invokeByTemplateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt new file mode 100644 index 00000000..95f8bc9b --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation +import com.courier.api.models.tenants.templates.TemplateListParams +import com.courier.api.models.tenants.templates.TemplateListResponse +import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface TemplateService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TemplateService + + /** Get a Template in Tenant */ + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + ): BaseTemplateTenantAssociation = retrieve(templateId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BaseTemplateTenantAssociation = + retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TemplateRetrieveParams): BaseTemplateTenantAssociation = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BaseTemplateTenantAssociation + + /** List Templates in Tenant */ + fun list(tenantId: String): TemplateListResponse = list(tenantId, TemplateListParams.none()) + + /** @see list */ + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): TemplateListResponse = list(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see list */ + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + ): TemplateListResponse = list(tenantId, params, RequestOptions.none()) + + /** @see list */ + fun list( + params: TemplateListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TemplateListResponse + + /** @see list */ + fun list(params: TemplateListParams): TemplateListResponse = list(params, RequestOptions.none()) + + /** @see list */ + fun list(tenantId: String, requestOptions: RequestOptions): TemplateListResponse = + list(tenantId, TemplateListParams.none(), requestOptions) + + /** A view of [TemplateService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): TemplateService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates/{template_id}`, but + * is otherwise the same as [TemplateService.retrieve]. + */ + @MustBeClosed + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + ): HttpResponseFor = + retrieve(templateId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TemplateRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise + * the same as [TemplateService.list]. + */ + @MustBeClosed + fun list(tenantId: String): HttpResponseFor = + list(tenantId, TemplateListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + list(params.toBuilder().tenantId(tenantId).build(), requestOptions) + + /** @see list */ + @MustBeClosed + fun list( + tenantId: String, + params: TemplateListParams = TemplateListParams.none(), + ): HttpResponseFor = list(tenantId, params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: TemplateListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: TemplateListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + tenantId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + list(tenantId, TemplateListParams.none(), requestOptions) + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt new file mode 100644 index 00000000..71d74426 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants + +import com.courier.api.core.ClientOptions +import com.courier.api.core.RequestOptions +import com.courier.api.core.checkRequired +import com.courier.api.core.handlers.errorBodyHandler +import com.courier.api.core.handlers.errorHandler +import com.courier.api.core.handlers.jsonHandler +import com.courier.api.core.http.HttpMethod +import com.courier.api.core.http.HttpRequest +import com.courier.api.core.http.HttpResponse +import com.courier.api.core.http.HttpResponse.Handler +import com.courier.api.core.http.HttpResponseFor +import com.courier.api.core.http.parseable +import com.courier.api.core.prepare +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation +import com.courier.api.models.tenants.templates.TemplateListParams +import com.courier.api.models.tenants.templates.TemplateListResponse +import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class TemplateServiceImpl internal constructor(private val clientOptions: ClientOptions) : + TemplateService { + + private val withRawResponse: TemplateService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): TemplateService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): TemplateService = + TemplateServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions, + ): BaseTemplateTenantAssociation = + // get /tenants/{tenant_id}/templates/{template_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun list( + params: TemplateListParams, + requestOptions: RequestOptions, + ): TemplateListResponse = + // get /tenants/{tenant_id}/templates + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + TemplateService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): TemplateService.WithRawResponse = + TemplateServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: TemplateRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("templateId", params.templateId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "tenants", + params._pathParam(0), + "templates", + params._pathParam(1), + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: TemplateListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("tenantId", params.tenantId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("tenants", params._pathParam(0), "templates") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt index 6c834e0e..ab684385 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt @@ -10,8 +10,8 @@ import com.courier.api.models.users.tokens.TokenAddMultipleParams import com.courier.api.models.users.tokens.TokenAddSingleParams import com.courier.api.models.users.tokens.TokenDeleteParams import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenRetrieveParams +import com.courier.api.models.users.tokens.TokenRetrieveResponse import com.courier.api.models.users.tokens.TokenUpdateParams import com.courier.api.models.users.tokens.UserToken import com.google.errorprone.annotations.MustBeClosed @@ -31,6 +31,27 @@ interface TokenService { */ fun withOptions(modifier: Consumer): TokenService + /** Get single token available for a `:token` */ + fun retrieve(token: String, params: TokenRetrieveParams): TokenRetrieveResponse = + retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + token: String, + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenRetrieveResponse = retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + fun retrieve(params: TokenRetrieveParams): TokenRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TokenRetrieveResponse + /** Apply a JSON Patch (RFC 6902) to the specified token. */ fun update(token: String, params: TokenUpdateParams) = update(token, params, RequestOptions.none()) @@ -141,30 +162,6 @@ interface TokenService { requestOptions: RequestOptions = RequestOptions.none(), ) - /** Get single token available for a `:token` */ - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - ): TokenRetrieveSingleResponse = retrieveSingle(token, params, RequestOptions.none()) - - /** @see retrieveSingle */ - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TokenRetrieveSingleResponse = - retrieveSingle(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieveSingle */ - fun retrieveSingle(params: TokenRetrieveSingleParams): TokenRetrieveSingleResponse = - retrieveSingle(params, RequestOptions.none()) - - /** @see retrieveSingle */ - fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TokenRetrieveSingleResponse - /** A view of [TokenService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -175,6 +172,37 @@ interface TokenService { */ fun withOptions(modifier: Consumer): TokenService.WithRawResponse + /** + * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise + * the same as [TokenService.retrieve]. + */ + @MustBeClosed + fun retrieve( + token: String, + params: TokenRetrieveParams, + ): HttpResponseFor = retrieve(token, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + token: String, + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().token(token).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: TokenRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `patch /users/{user_id}/tokens/{token}`, but is otherwise * the same as [TokenService.update]. @@ -337,39 +365,5 @@ interface TokenService { params: TokenAddSingleParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenService.retrieveSingle]. - */ - @MustBeClosed - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - ): HttpResponseFor = - retrieveSingle(token, params, RequestOptions.none()) - - /** @see retrieveSingle */ - @MustBeClosed - fun retrieveSingle( - token: String, - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveSingle(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieveSingle */ - @MustBeClosed - fun retrieveSingle( - params: TokenRetrieveSingleParams - ): HttpResponseFor = - retrieveSingle(params, RequestOptions.none()) - - /** @see retrieveSingle */ - @MustBeClosed - fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt index 7c168b9f..d000a1fb 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt @@ -21,8 +21,8 @@ import com.courier.api.models.users.tokens.TokenAddMultipleParams import com.courier.api.models.users.tokens.TokenAddSingleParams import com.courier.api.models.users.tokens.TokenDeleteParams import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleResponse +import com.courier.api.models.users.tokens.TokenRetrieveParams +import com.courier.api.models.users.tokens.TokenRetrieveResponse import com.courier.api.models.users.tokens.TokenUpdateParams import com.courier.api.models.users.tokens.UserToken import java.util.function.Consumer @@ -40,6 +40,13 @@ class TokenServiceImpl internal constructor(private val clientOptions: ClientOpt override fun withOptions(modifier: Consumer): TokenService = TokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): TokenRetrieveResponse = + // get /users/{user_id}/tokens/{token} + withRawResponse().retrieve(params, requestOptions).parse() + override fun update(params: TokenUpdateParams, requestOptions: RequestOptions) { // patch /users/{user_id}/tokens/{token} withRawResponse().update(params, requestOptions) @@ -64,13 +71,6 @@ class TokenServiceImpl internal constructor(private val clientOptions: ClientOpt withRawResponse().addSingle(params, requestOptions) } - override fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions, - ): TokenRetrieveSingleResponse = - // get /users/{user_id}/tokens/{token} - withRawResponse().retrieveSingle(params, requestOptions).parse() - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TokenService.WithRawResponse { @@ -84,6 +84,36 @@ class TokenServiceImpl internal constructor(private val clientOptions: ClientOpt clientOptions.toBuilder().apply(modifier::accept).build() ) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: TokenRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("token", params.token().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val updateHandler: Handler = emptyHandler() override fun update( @@ -209,35 +239,5 @@ class TokenServiceImpl internal constructor(private val clientOptions: ClientOpt response.use { addSingleHandler.handle(it) } } } - - private val retrieveSingleHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveSingle( - params: TokenRetrieveSingleParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveSingleHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt index cd7b9143..a972133b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt @@ -9,23 +9,16 @@ internal class AuthIssueTokenParamsTest { @Test fun create() { - AuthIssueTokenParams.builder() - .expiresIn("expires_in") - .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) - .build() + AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() } @Test fun body() { - val params = - AuthIssueTokenParams.builder() - .expiresIn("expires_in") - .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) - .build() + val params = AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() val body = params._body() assertThat(body.expiresIn()).isEqualTo("expires_in") - assertThat(body.scope()).isEqualTo(AuthIssueTokenParams.Scope.READ_PREFERENCES) + assertThat(body.scope()).isEqualTo("scope") } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt similarity index 73% rename from courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt index 2c15d8cb..d3ed655f 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeAdHocParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt @@ -1,17 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.automations +package com.courier.api.models.automations.invoke import com.courier.api.core.JsonValue -import com.courier.api.models.automations.invoke.AutomationInvokeParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class AutomationInvokeAdHocParamsTest { +internal class InvokeInvokeAdHocParamsTest { @Test fun create() { - AutomationInvokeAdHocParams.builder() + InvokeInvokeAdHocParams.builder() .brand("brand") .data( AutomationInvokeParams.Data.builder() @@ -22,15 +21,13 @@ internal class AutomationInvokeAdHocParamsTest { .recipient("recipient") .template("template") .automation( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep.builder() .if_("if") .ref("ref") .action( - AutomationInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .Action .ADD_TO_DIGEST ) @@ -46,7 +43,7 @@ internal class AutomationInvokeAdHocParamsTest { @Test fun body() { val params = - AutomationInvokeAdHocParams.builder() + InvokeInvokeAdHocParams.builder() .brand("brand") .data( AutomationInvokeParams.Data.builder() @@ -57,14 +54,14 @@ internal class AutomationInvokeAdHocParamsTest { .recipient("recipient") .template("template") .automation( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .builder() .if_("if") .ref("ref") .action( - AutomationInvokeAdHocParams.Automation.Step + InvokeInvokeAdHocParams.Automation.Step .AutomationAddToDigestStep .Action .ADD_TO_DIGEST @@ -91,15 +88,13 @@ internal class AutomationInvokeAdHocParamsTest { assertThat(body.template()).contains("template") assertThat(body.automation()) .isEqualTo( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep.builder() .if_("if") .ref("ref") .action( - AutomationInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .Action .ADD_TO_DIGEST ) @@ -114,14 +109,14 @@ internal class AutomationInvokeAdHocParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - AutomationInvokeAdHocParams.builder() + InvokeInvokeAdHocParams.builder() .automation( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .builder() .action( - AutomationInvokeAdHocParams.Automation.Step + InvokeInvokeAdHocParams.Automation.Step .AutomationAddToDigestStep .Action .ADD_TO_DIGEST @@ -137,13 +132,11 @@ internal class AutomationInvokeAdHocParamsTest { assertThat(body.automation()) .isEqualTo( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep.builder() .action( - AutomationInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .Action .ADD_TO_DIGEST ) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt similarity index 88% rename from courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt index 46e54514..c661938b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/AutomationInvokeByTemplateParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt @@ -1,17 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.automations +package com.courier.api.models.automations.invoke import com.courier.api.core.JsonValue -import com.courier.api.models.automations.invoke.AutomationInvokeParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class AutomationInvokeByTemplateParamsTest { +internal class InvokeInvokeByTemplateParamsTest { @Test fun create() { - AutomationInvokeByTemplateParams.builder() + InvokeInvokeByTemplateParams.builder() .templateId("templateId") .automationInvokeParams( AutomationInvokeParams.builder() @@ -32,7 +31,7 @@ internal class AutomationInvokeByTemplateParamsTest { @Test fun pathParams() { val params = - AutomationInvokeByTemplateParams.builder() + InvokeInvokeByTemplateParams.builder() .templateId("templateId") .automationInvokeParams(AutomationInvokeParams.builder().build()) .build() @@ -45,7 +44,7 @@ internal class AutomationInvokeByTemplateParamsTest { @Test fun body() { val params = - AutomationInvokeByTemplateParams.builder() + InvokeInvokeByTemplateParams.builder() .templateId("templateId") .automationInvokeParams( AutomationInvokeParams.builder() @@ -83,7 +82,7 @@ internal class AutomationInvokeByTemplateParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - AutomationInvokeByTemplateParams.builder() + InvokeInvokeByTemplateParams.builder() .templateId("templateId") .automationInvokeParams(AutomationInvokeParams.builder().build()) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt index d6e441d2..c3d43d77 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt @@ -5,8 +5,6 @@ package com.courier.api.models.bulk import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.Utm import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -79,7 +77,7 @@ internal class BulkCreateJobParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -121,55 +119,8 @@ internal class BulkCreateJobParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -269,7 +220,7 @@ internal class BulkCreateJobParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -311,59 +262,8 @@ internal class BulkCreateJobParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -458,7 +358,7 @@ internal class BulkCreateJobParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -500,55 +400,8 @@ internal class BulkCreateJobParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt index 3016664d..aa7a864a 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt @@ -6,8 +6,6 @@ import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.Utm import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -96,7 +94,7 @@ internal class BulkRetrieveJobResponseTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -139,63 +137,8 @@ internal class BulkRetrieveJobResponseTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to - "term", - ) - ), - "override" to - mapOf( - "foo" to "bar" - ), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -310,7 +253,7 @@ internal class BulkRetrieveJobResponseTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -352,60 +295,8 @@ internal class BulkRetrieveJobResponseTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to - "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -522,7 +413,7 @@ internal class BulkRetrieveJobResponseTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -565,63 +456,8 @@ internal class BulkRetrieveJobResponseTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to - "term", - ) - ), - "override" to - mapOf( - "foo" to "bar" - ), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt index 7934c3d9..8ca3dd87 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt @@ -6,8 +6,6 @@ import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.Utm import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -80,7 +78,7 @@ internal class InboundBulkMessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -122,49 +120,8 @@ internal class InboundBulkMessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -256,7 +213,7 @@ internal class InboundBulkMessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -298,49 +255,8 @@ internal class InboundBulkMessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -434,7 +350,7 @@ internal class InboundBulkMessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -476,49 +392,8 @@ internal class InboundBulkMessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt index 5319596d..2f61684a 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt @@ -14,12 +14,21 @@ internal class ListListResponseTest { fun create() { val listListResponse = ListListResponse.builder() - .addItem(List.builder().id("id").name("name").created(0L).updated(0L).build()) + .addItem( + List.builder() + .id("id") + .name("name") + .created("created") + .updated("updated") + .build() + ) .paging(Paging.builder().more(true).cursor("cursor").build()) .build() assertThat(listListResponse.items()) - .containsExactly(List.builder().id("id").name("name").created(0L).updated(0L).build()) + .containsExactly( + List.builder().id("id").name("name").created("created").updated("updated").build() + ) assertThat(listListResponse.paging()) .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) } @@ -29,7 +38,14 @@ internal class ListListResponseTest { val jsonMapper = jsonMapper() val listListResponse = ListListResponse.builder() - .addItem(List.builder().id("id").name("name").created(0L).updated(0L).build()) + .addItem( + List.builder() + .id("id") + .name("name") + .created("created") + .updated("updated") + .build() + ) .paging(Paging.builder().more(true).cursor("cursor").build()) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt index 86f8655c..934eb5db 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt @@ -2,6 +2,7 @@ package com.courier.api.models.lists +import com.courier.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -9,15 +10,35 @@ internal class ListRestoreParamsTest { @Test fun create() { - ListRestoreParams.builder().listId("list_id").build() + ListRestoreParams.builder() + .listId("list_id") + .body(JsonValue.from(mapOf())) + .build() } @Test fun pathParams() { - val params = ListRestoreParams.builder().listId("list_id").build() + val params = + ListRestoreParams.builder() + .listId("list_id") + .body(JsonValue.from(mapOf())) + .build() assertThat(params._pathParam(0)).isEqualTo("list_id") // out-of-bound path param assertThat(params._pathParam(1)).isEqualTo("") } + + @Test + fun body() { + val params = + ListRestoreParams.builder() + .listId("list_id") + .body(JsonValue.from(mapOf())) + .build() + + val body = params._body() + + assertThat(body).isEqualTo(JsonValue.from(mapOf())) + } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt index 324770f7..b7b348ac 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt @@ -11,18 +11,20 @@ internal class ListTest { @Test fun create() { - val list = List.builder().id("id").name("name").created(0L).updated(0L).build() + val list = + List.builder().id("id").name("name").created("created").updated("updated").build() assertThat(list.id()).isEqualTo("id") assertThat(list.name()).isEqualTo("name") - assertThat(list.created()).contains(0L) - assertThat(list.updated()).contains(0L) + assertThat(list.created()).contains("created") + assertThat(list.updated()).contains("updated") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val list = List.builder().id("id").name("name").created(0L).updated(0L).build() + val list = + List.builder().id("id").name("name").created("created").updated("updated").build() val roundtrippedList = jsonMapper.readValue(jsonMapper.writeValueAsString(list), jacksonTypeRef()) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt similarity index 66% rename from courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt index fb739bfd..359fe01d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt @@ -5,16 +5,16 @@ package com.courier.api.models.messages import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MessageGetContentParamsTest { +internal class MessageContentParamsTest { @Test fun create() { - MessageGetContentParams.builder().messageId("message_id").build() + MessageContentParams.builder().messageId("message_id").build() } @Test fun pathParams() { - val params = MessageGetContentParams.builder().messageId("message_id").build() + val params = MessageContentParams.builder().messageId("message_id").build() assertThat(params._pathParam(0)).isEqualTo("message_id") // out-of-bound path param diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt similarity index 67% rename from courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt index 40b073cf..cb5a08b5 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageGetContentResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt @@ -7,20 +7,20 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class MessageGetContentResponseTest { +internal class MessageContentResponseTest { @Test fun create() { - val messageGetContentResponse = - MessageGetContentResponse.builder() + val messageContentResponse = + MessageContentResponse.builder() .addResult( - MessageGetContentResponse.Result.builder() + MessageContentResponse.Result.builder() .channel("channel") .channelId("channel_id") .content( - MessageGetContentResponse.Result.Content.builder() + MessageContentResponse.Result.Content.builder() .addBlock( - MessageGetContentResponse.Result.Content.Block.builder() + MessageContentResponse.Result.Content.Block.builder() .text("text") .type("type") .build() @@ -36,15 +36,15 @@ internal class MessageGetContentResponseTest { ) .build() - assertThat(messageGetContentResponse.results()) + assertThat(messageContentResponse.results()) .containsExactly( - MessageGetContentResponse.Result.builder() + MessageContentResponse.Result.builder() .channel("channel") .channelId("channel_id") .content( - MessageGetContentResponse.Result.Content.builder() + MessageContentResponse.Result.Content.builder() .addBlock( - MessageGetContentResponse.Result.Content.Block.builder() + MessageContentResponse.Result.Content.Block.builder() .text("text") .type("type") .build() @@ -63,16 +63,16 @@ internal class MessageGetContentResponseTest { @Test fun roundtrip() { val jsonMapper = jsonMapper() - val messageGetContentResponse = - MessageGetContentResponse.builder() + val messageContentResponse = + MessageContentResponse.builder() .addResult( - MessageGetContentResponse.Result.builder() + MessageContentResponse.Result.builder() .channel("channel") .channelId("channel_id") .content( - MessageGetContentResponse.Result.Content.builder() + MessageContentResponse.Result.Content.builder() .addBlock( - MessageGetContentResponse.Result.Content.Block.builder() + MessageContentResponse.Result.Content.Block.builder() .text("text") .type("type") .build() @@ -88,12 +88,12 @@ internal class MessageGetContentResponseTest { ) .build() - val roundtrippedMessageGetContentResponse = + val roundtrippedMessageContentResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(messageGetContentResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(messageContentResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedMessageGetContentResponse).isEqualTo(messageGetContentResponse) + assertThat(roundtrippedMessageContentResponse).isEqualTo(messageContentResponse) } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt index 44a98a49..de505845 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt @@ -24,7 +24,7 @@ internal class MessageDetailsTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .build() assertThat(messageDetails.id()).isEqualTo("id") @@ -38,7 +38,7 @@ internal class MessageDetailsTest { assertThat(messageDetails.sent()).isEqualTo(0L) assertThat(messageDetails.status()).isEqualTo(MessageDetails.Status.CANCELED) assertThat(messageDetails.error()).contains("error") - assertThat(messageDetails.reason()).contains(MessageDetails.Reason.FILTERED) + assertThat(messageDetails.reason()).contains(MessageDetails.Reason.BOUNCED) } @Test @@ -57,7 +57,7 @@ internal class MessageDetailsTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .build() val roundtrippedMessageDetails = diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt index bba292c7..b6a3e256 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt @@ -28,7 +28,7 @@ internal class MessageListResponseTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .build() ) .build() @@ -49,7 +49,7 @@ internal class MessageListResponseTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .build() ) } @@ -73,7 +73,7 @@ internal class MessageListResponseTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt index 5c604358..0ed0c62d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt @@ -26,7 +26,7 @@ internal class MessageRetrieveResponseTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .addProvider( MessageRetrieveResponse.Provider.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) @@ -45,7 +45,7 @@ internal class MessageRetrieveResponseTest { assertThat(messageRetrieveResponse.sent()).isEqualTo(0L) assertThat(messageRetrieveResponse.status()).isEqualTo(MessageDetails.Status.CANCELED) assertThat(messageRetrieveResponse.error()).contains("error") - assertThat(messageRetrieveResponse.reason()).contains(MessageDetails.Reason.FILTERED) + assertThat(messageRetrieveResponse.reason()).contains(MessageDetails.Reason.BOUNCED) assertThat(messageRetrieveResponse.providers().getOrNull()) .containsExactly( MessageRetrieveResponse.Provider.builder() @@ -70,7 +70,7 @@ internal class MessageRetrieveResponseTest { .sent(0L) .status(MessageDetails.Status.CANCELED) .error("error") - .reason(MessageDetails.Reason.FILTERED) + .reason(MessageDetails.Reason.BOUNCED) .addProvider( MessageRetrieveResponse.Provider.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt index 481297c7..bc1a4bff 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt @@ -59,7 +59,7 @@ internal class BaseMessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -101,46 +101,8 @@ internal class BaseMessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -213,7 +175,7 @@ internal class BaseMessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -258,45 +220,8 @@ internal class BaseMessageTest { assertThat(baseMessage.routing()) .contains( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) assertThat(baseMessage.timeout()) @@ -369,7 +294,7 @@ internal class BaseMessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -411,46 +336,8 @@ internal class BaseMessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt index 37c66cfa..04338e09 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt @@ -5,6 +5,8 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.templates.ElementalContent +import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,7 +19,7 @@ internal class ContentTest { @Test fun ofElemental() { val elemental = - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( ElementalNode.UnionMember0.builder() .addChannel("string") @@ -42,7 +44,7 @@ internal class ContentTest { val jsonMapper = jsonMapper() val content = Content.ofElemental( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( ElementalNode.UnionMember0.builder() .addChannel("string") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt index cfd8399f..e455bcc1 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt @@ -5,6 +5,8 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.templates.ElementalContent +import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -63,7 +65,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -105,46 +107,8 @@ internal class MessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -184,7 +148,7 @@ internal class MessageTest { .build() ) .content( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( ElementalNode.UnionMember0.builder() .addChannel("string") @@ -260,7 +224,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -302,46 +266,8 @@ internal class MessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -385,7 +311,7 @@ internal class MessageTest { .build() ) .content( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( ElementalNode.UnionMember0.builder() .addChannel("string") @@ -457,7 +383,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -499,46 +425,8 @@ internal class MessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -640,7 +528,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -682,46 +570,8 @@ internal class MessageTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index 09280c1e..372fd470 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -45,7 +45,7 @@ internal class SendMessageParamsTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) @@ -61,7 +61,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -103,46 +103,8 @@ internal class SendMessageParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -163,41 +125,28 @@ internal class SendMessageParamsTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator - .MEMBER_OF - ) - .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path - .ACCOUNT_ID + BaseMessageSendTo.To.UnionMember1.Filter.Operator.MEMBER_OF ) + .path(BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -243,7 +192,7 @@ internal class SendMessageParamsTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) @@ -259,7 +208,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -301,49 +250,8 @@ internal class SendMessageParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -364,41 +272,31 @@ internal class SendMessageParamsTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + BaseMessageSendTo.To.UnionMember1.Filter.Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path - .ACCOUNT_ID + BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -443,7 +341,7 @@ internal class SendMessageParamsTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) @@ -459,7 +357,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -501,49 +399,8 @@ internal class SendMessageParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -564,41 +421,31 @@ internal class SendMessageParamsTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + BaseMessageSendTo.To.UnionMember1.Filter.Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path - .ACCOUNT_ID + BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -613,9 +460,9 @@ internal class SendMessageParamsTest { .message( Message.ContentMessage.builder() .content( - Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) - .version("version") + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -629,9 +476,9 @@ internal class SendMessageParamsTest { Message.ofContent( Message.ContentMessage.builder() .content( - Content.ElementalContent.builder() - .addElement(ElementalNode.UnionMember0.builder().build()) - .version("version") + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt index 77c1eb0f..990f0b0b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt @@ -11,15 +11,17 @@ internal class SendMessageResponseTest { @Test fun create() { - val sendMessageResponse = SendMessageResponse.builder().requestId("requestId").build() + val sendMessageResponse = + SendMessageResponse.builder().requestId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() - assertThat(sendMessageResponse.requestId()).isEqualTo("requestId") + assertThat(sendMessageResponse.requestId()).isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val sendMessageResponse = SendMessageResponse.builder().requestId("requestId").build() + val sendMessageResponse = + SendMessageResponse.builder().requestId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() val roundtrippedSendMessageResponse = jsonMapper.readValue( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt deleted file mode 100644 index 889e13b8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UtmTest { - - @Test - fun create() { - val utm = - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - - assertThat(utm.campaign()).contains("campaign") - assertThat(utm.content()).contains("content") - assertThat(utm.medium()).contains("medium") - assertThat(utm.source()).contains("source") - assertThat(utm.term()).contains("term") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val utm = - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - - val roundtrippedUtm = - jsonMapper.readValue(jsonMapper.writeValueAsString(utm), jacksonTypeRef()) - - assertThat(roundtrippedUtm).isEqualTo(utm) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt new file mode 100644 index 00000000..dda241ef --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseTemplateTenantAssociationTest { + + @Test + fun create() { + val baseTemplateTenantAssociation = + BaseTemplateTenantAssociation.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .build() + + assertThat(baseTemplateTenantAssociation.id()).isEqualTo("id") + assertThat(baseTemplateTenantAssociation.createdAt()).isEqualTo("created_at") + assertThat(baseTemplateTenantAssociation.publishedAt()).isEqualTo("published_at") + assertThat(baseTemplateTenantAssociation.updatedAt()).isEqualTo("updated_at") + assertThat(baseTemplateTenantAssociation.version()).isEqualTo("version") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseTemplateTenantAssociation = + BaseTemplateTenantAssociation.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .build() + + val roundtrippedBaseTemplateTenantAssociation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseTemplateTenantAssociation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseTemplateTenantAssociation) + .isEqualTo(baseTemplateTenantAssociation) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt similarity index 98% rename from courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt index 4587d04e..40d76a91 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalChannelNodeTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.send +package com.courier.api.models.tenants.templates import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt new file mode 100644 index 00000000..1a816605 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalContentTest { + + @Test + fun create() { + val elementalContent = + ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + + assertThat(elementalContent.elements()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalContent.version()).isEqualTo("version") + assertThat(elementalContent._brand()).isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalContent = + ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + + val roundtrippedElementalContent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalContent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalContent).isEqualTo(elementalContent) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt similarity index 98% rename from courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt index bf51afd4..57ed362b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalGroupNodeTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.send +package com.courier.api.models.tenants.templates import com.courier.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt similarity index 99% rename from courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt index df5c7d9d..a6fe92cb 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.send +package com.courier.api.models.tenants.templates import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt new file mode 100644 index 00000000..fa16fc52 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TemplateListParamsTest { + + @Test + fun create() { + TemplateListParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() + } + + @Test + fun pathParams() { + val params = TemplateListParams.builder().tenantId("tenant_id").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + TemplateListParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "0").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = TemplateListParams.builder().tenantId("tenant_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt new file mode 100644 index 00000000..427e61d3 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.jsonMapper +import com.courier.api.models.notifications.MessageRouting +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TemplateListResponseTest { + + @Test + fun create() { + val templateListResponse = + TemplateListResponse.builder() + .hasMore(true) + .type(TemplateListResponse.Type.LIST) + .url("url") + .cursor("cursor") + .addItem( + TemplateListResponse.Item.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .data( + TemplateListResponse.Item.Data.builder() + .routing( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + .build() + ) + .build() + ) + .nextUrl("next_url") + .build() + + assertThat(templateListResponse.hasMore()).isEqualTo(true) + assertThat(templateListResponse.type()).isEqualTo(TemplateListResponse.Type.LIST) + assertThat(templateListResponse.url()).isEqualTo("url") + assertThat(templateListResponse.cursor()).contains("cursor") + assertThat(templateListResponse.items().getOrNull()) + .containsExactly( + TemplateListResponse.Item.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .data( + TemplateListResponse.Item.Data.builder() + .routing( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + .build() + ) + .build() + ) + assertThat(templateListResponse.nextUrl()).contains("next_url") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val templateListResponse = + TemplateListResponse.builder() + .hasMore(true) + .type(TemplateListResponse.Type.LIST) + .url("url") + .cursor("cursor") + .addItem( + TemplateListResponse.Item.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .data( + TemplateListResponse.Item.Data.builder() + .routing( + MessageRouting.builder() + .addChannel("string") + .method(MessageRouting.Method.ALL) + .build() + ) + .build() + ) + .build() + ) + .nextUrl("next_url") + .build() + + val roundtrippedTemplateListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(templateListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTemplateListResponse).isEqualTo(templateListResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt new file mode 100644 index 00000000..527cfe5b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TemplateRetrieveParamsTest { + + @Test + fun create() { + TemplateRetrieveParams.builder().tenantId("tenant_id").templateId("template_id").build() + } + + @Test + fun pathParams() { + val params = + TemplateRetrieveParams.builder().tenantId("tenant_id").templateId("template_id").build() + + assertThat(params._pathParam(0)).isEqualTo("tenant_id") + assertThat(params._pathParam(1)).isEqualTo("template_id") + // out-of-bound path param + assertThat(params._pathParam(2)).isEqualTo("") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt similarity index 67% rename from courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt index 11211c56..ff21e7c3 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt @@ -5,16 +5,16 @@ package com.courier.api.models.users.tokens import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class TokenRetrieveSingleParamsTest { +internal class TokenRetrieveParamsTest { @Test fun create() { - TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() + TokenRetrieveParams.builder().userId("user_id").token("token").build() } @Test fun pathParams() { - val params = TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() + val params = TokenRetrieveParams.builder().userId("user_id").token("token").build() assertThat(params._pathParam(0)).isEqualTo("user_id") assertThat(params._pathParam(1)).isEqualTo("token") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt similarity index 71% rename from courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt index 511a3c56..0f275e09 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveSingleResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt @@ -8,12 +8,12 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class TokenRetrieveSingleResponseTest { +internal class TokenRetrieveResponseTest { @Test fun create() { - val tokenRetrieveSingleResponse = - TokenRetrieveSingleResponse.builder() + val tokenRetrieveResponse = + TokenRetrieveResponse.builder() .providerKey(UserToken.ProviderKey.FIREBASE_FCM) .token("token") .device( @@ -36,14 +36,14 @@ internal class TokenRetrieveSingleResponseTest { .osVersion("os_version") .build() ) - .status(TokenRetrieveSingleResponse.Status.ACTIVE) + .status(TokenRetrieveResponse.Status.ACTIVE) .statusReason("status_reason") .build() - assertThat(tokenRetrieveSingleResponse.providerKey()) + assertThat(tokenRetrieveResponse.providerKey()) .isEqualTo(UserToken.ProviderKey.FIREBASE_FCM) - assertThat(tokenRetrieveSingleResponse.token()).contains("token") - assertThat(tokenRetrieveSingleResponse.device()) + assertThat(tokenRetrieveResponse.token()).contains("token") + assertThat(tokenRetrieveResponse.device()) .contains( UserToken.Device.builder() .adId("ad_id") @@ -54,11 +54,11 @@ internal class TokenRetrieveSingleResponseTest { .platform("platform") .build() ) - assertThat(tokenRetrieveSingleResponse.expiryDate()) + assertThat(tokenRetrieveResponse.expiryDate()) .contains(UserToken.ExpiryDate.ofString("string")) - assertThat(tokenRetrieveSingleResponse._properties()) + assertThat(tokenRetrieveResponse._properties()) .isEqualTo(JsonValue.from(mapOf())) - assertThat(tokenRetrieveSingleResponse.tracking()) + assertThat(tokenRetrieveResponse.tracking()) .contains( UserToken.Tracking.builder() .ip("ip") @@ -67,16 +67,15 @@ internal class TokenRetrieveSingleResponseTest { .osVersion("os_version") .build() ) - assertThat(tokenRetrieveSingleResponse.status()) - .contains(TokenRetrieveSingleResponse.Status.ACTIVE) - assertThat(tokenRetrieveSingleResponse.statusReason()).contains("status_reason") + assertThat(tokenRetrieveResponse.status()).contains(TokenRetrieveResponse.Status.ACTIVE) + assertThat(tokenRetrieveResponse.statusReason()).contains("status_reason") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val tokenRetrieveSingleResponse = - TokenRetrieveSingleResponse.builder() + val tokenRetrieveResponse = + TokenRetrieveResponse.builder() .providerKey(UserToken.ProviderKey.FIREBASE_FCM) .token("token") .device( @@ -99,16 +98,16 @@ internal class TokenRetrieveSingleResponseTest { .osVersion("os_version") .build() ) - .status(TokenRetrieveSingleResponse.Status.ACTIVE) + .status(TokenRetrieveResponse.Status.ACTIVE) .statusReason("status_reason") .build() - val roundtrippedTokenRetrieveSingleResponse = + val roundtrippedTokenRetrieveResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(tokenRetrieveSingleResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(tokenRetrieveResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedTokenRetrieveSingleResponse).isEqualTo(tokenRetrieveSingleResponse) + assertThat(roundtrippedTokenRetrieveResponse).isEqualTo(tokenRetrieveResponse) } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index 1926589d..674007a8 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -19,12 +19,9 @@ import com.courier.api.errors.UnprocessableEntityException import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -115,7 +112,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -133,7 +130,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -175,59 +172,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -248,43 +194,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -347,7 +283,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -365,7 +301,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -407,59 +343,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -480,43 +365,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -579,7 +454,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -597,7 +472,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -639,59 +514,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -712,43 +536,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -811,7 +625,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -829,7 +643,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -871,59 +685,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -944,43 +707,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -1043,7 +796,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -1061,7 +814,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1103,59 +856,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -1176,43 +878,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -1275,7 +967,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -1293,7 +985,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1335,59 +1027,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -1408,43 +1049,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -1507,7 +1138,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -1525,7 +1156,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1567,59 +1198,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -1640,43 +1220,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -1739,7 +1309,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -1757,7 +1327,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1799,59 +1369,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -1872,43 +1391,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -1971,7 +1480,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -1989,7 +1498,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2031,59 +1540,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -2104,43 +1562,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -2203,7 +1651,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -2221,7 +1669,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2263,59 +1711,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -2336,43 +1733,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -2435,7 +1822,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -2453,7 +1840,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2495,59 +1882,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -2568,43 +1904,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -2667,7 +1993,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -2685,7 +2011,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2727,59 +2053,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -2800,43 +2075,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -2899,7 +2164,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -2917,7 +2182,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2959,59 +2224,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -3032,43 +2246,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -3131,7 +2335,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -3149,7 +2353,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3191,59 +2395,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -3264,43 +2417,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -3363,7 +2506,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -3381,7 +2524,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3423,59 +2566,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -3496,43 +2588,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -3595,7 +2677,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -3613,7 +2695,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3655,59 +2737,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -3728,43 +2759,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() @@ -3825,7 +2846,7 @@ internal class ErrorHandlingTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( @@ -3843,7 +2864,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3885,59 +2906,8 @@ internal class ErrorHandlingTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -3958,43 +2928,33 @@ internal class ErrorHandlingTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter + BaseMessageSendTo.To.UnionMember1.Filter .Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index cbd00c20..68d82b1f 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -8,12 +8,9 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -86,7 +83,7 @@ internal class ServiceParamsTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) @@ -102,7 +99,7 @@ internal class ServiceParamsTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -144,49 +141,8 @@ internal class ServiceParamsTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -207,41 +163,31 @@ internal class ServiceParamsTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator + BaseMessageSendTo.To.UnionMember1.Filter.Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path - .ACCOUNT_ID + BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt index 63da8a0b..6bc5a348 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt @@ -24,10 +24,7 @@ internal class AuthServiceAsyncTest { val responseFuture = authServiceAsync.issueToken( - AuthIssueTokenParams.builder() - .expiresIn("expires_in") - .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) - .build() + AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() ) val response = responseFuture.get() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt index 0dad4e99..63de477a 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt @@ -14,8 +14,6 @@ import com.courier.api.models.bulk.UserRecipient import com.courier.api.models.lists.subscriptions.RecipientPreferences import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -258,7 +256,7 @@ internal class BulkServiceAsyncTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -300,60 +298,8 @@ internal class BulkServiceAsyncTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to - "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt index a0bdfdab..0db1025b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt @@ -6,6 +6,7 @@ import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListRestoreParams import com.courier.api.models.lists.ListUpdateParams import com.courier.api.models.lists.subscriptions.RecipientPreferences import org.junit.jupiter.api.Disabled @@ -41,7 +42,7 @@ internal class ListServiceAsyncTest { .build() val listServiceAsync = client.lists() - val listFuture = + val future = listServiceAsync.update( ListUpdateParams.builder() .listId("list_id") @@ -95,8 +96,7 @@ internal class ListServiceAsyncTest { .build() ) - val list = listFuture.get() - list.validate() + val response = future.get() } @Disabled("Prism tests are disabled") @@ -143,7 +143,13 @@ internal class ListServiceAsyncTest { .build() val listServiceAsync = client.lists() - val future = listServiceAsync.restore("list_id") + val future = + listServiceAsync.restore( + ListRestoreParams.builder() + .listId("list_id") + .body(JsonValue.from(mapOf())) + .build() + ) val response = future.get() } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt index 52f3d5e0..3b81e849 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt @@ -81,7 +81,7 @@ internal class MessageServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun getContent() { + fun content() { val client = CourierOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -89,7 +89,7 @@ internal class MessageServiceAsyncTest { .build() val messageServiceAsync = client.messages() - val responseFuture = messageServiceAsync.getContent("message_id") + val responseFuture = messageServiceAsync.content("message_id") val response = responseFuture.get() response.validate() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 17ca5300..902afcc0 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -8,12 +8,9 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -68,7 +65,7 @@ internal class SendServiceAsyncTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) @@ -84,7 +81,7 @@ internal class SendServiceAsyncTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -126,55 +123,8 @@ internal class SendServiceAsyncTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -195,42 +145,32 @@ internal class SendServiceAsyncTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Operator + BaseMessageSendTo.To.UnionMember1.Filter.Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt similarity index 79% rename from courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt index 3d31a7ce..3162bf76 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AutomationServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.services.async +package com.courier.api.services.async.automations import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue -import com.courier.api.models.automations.AutomationInvokeAdHocParams -import com.courier.api.models.automations.AutomationInvokeByTemplateParams import com.courier.api.models.automations.invoke.AutomationInvokeParams +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams +import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -internal class AutomationServiceAsyncTest { +internal class InvokeServiceAsyncTest { @Disabled("Prism tests are disabled") @Test @@ -23,11 +23,11 @@ internal class AutomationServiceAsyncTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val automationServiceAsync = client.automations() + val invokeServiceAsync = client.automations().invoke() val automationInvokeResponseFuture = - automationServiceAsync.invokeAdHoc( - AutomationInvokeAdHocParams.builder() + invokeServiceAsync.invokeAdHoc( + InvokeInvokeAdHocParams.builder() .brand("brand") .data( AutomationInvokeParams.Data.builder() @@ -38,15 +38,14 @@ internal class AutomationServiceAsyncTest { .recipient("recipient") .template("template") .automation( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .builder() .if_("if") .ref("ref") .action( - AutomationInvokeAdHocParams.Automation.Step + InvokeInvokeAdHocParams.Automation.Step .AutomationAddToDigestStep .Action .ADD_TO_DIGEST @@ -72,11 +71,11 @@ internal class AutomationServiceAsyncTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val automationServiceAsync = client.automations() + val invokeServiceAsync = client.automations().invoke() val automationInvokeResponseFuture = - automationServiceAsync.invokeByTemplate( - AutomationInvokeByTemplateParams.builder() + invokeServiceAsync.invokeByTemplate( + InvokeInvokeByTemplateParams.builder() .templateId("templateId") .automationInvokeParams( AutomationInvokeParams.builder() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt new file mode 100644 index 00000000..f650a197 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.async.tenants + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClientAsync +import com.courier.api.models.tenants.templates.TemplateListParams +import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TemplateServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val templateServiceAsync = client.tenants().templates() + + val baseTemplateTenantAssociationFuture = + templateServiceAsync.retrieve( + TemplateRetrieveParams.builder() + .tenantId("tenant_id") + .templateId("template_id") + .build() + ) + + val baseTemplateTenantAssociation = baseTemplateTenantAssociationFuture.get() + baseTemplateTenantAssociation.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val templateServiceAsync = client.tenants().templates() + + val templatesFuture = + templateServiceAsync.list( + TemplateListParams.builder() + .tenantId("tenant_id") + .cursor("cursor") + .limit(0L) + .build() + ) + + val templates = templatesFuture.get() + templates.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt index a200b7cb..166514a4 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt @@ -7,7 +7,7 @@ import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue import com.courier.api.models.users.tokens.TokenAddSingleParams import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenRetrieveParams import com.courier.api.models.users.tokens.TokenUpdateParams import com.courier.api.models.users.tokens.UserToken import org.junit.jupiter.api.Disabled @@ -17,6 +17,25 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TokenServiceAsyncTest { + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenServiceAsync = client.users().tokens() + + val tokenFuture = + tokenServiceAsync.retrieve( + TokenRetrieveParams.builder().userId("user_id").token("token").build() + ) + + val token = tokenFuture.get() + token.validate() + } + @Disabled("Prism tests are disabled") @Test fun update() { @@ -140,23 +159,4 @@ internal class TokenServiceAsyncTest { val response = future.get() } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveSingle() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val responseFuture = - tokenServiceAsync.retrieveSingle( - TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() - ) - - val response = responseFuture.get() - response.validate() - } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt index 7b8cf586..b9598b04 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt @@ -24,10 +24,7 @@ internal class AuthServiceTest { val response = authService.issueToken( - AuthIssueTokenParams.builder() - .expiresIn("expires_in") - .scope(AuthIssueTokenParams.Scope.READ_PREFERENCES) - .build() + AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() ) response.validate() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt index 4d065b1d..199f1705 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt @@ -14,8 +14,6 @@ import com.courier.api.models.bulk.UserRecipient import com.courier.api.models.lists.subscriptions.RecipientPreferences import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -255,7 +253,7 @@ internal class BulkServiceTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -297,60 +295,8 @@ internal class BulkServiceTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel - .RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to - "term", - ) - ), - "override" to - mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt index 3a3ac703..7a52b218 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt @@ -6,6 +6,7 @@ import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.models.lists.ListListParams +import com.courier.api.models.lists.ListRestoreParams import com.courier.api.models.lists.ListUpdateParams import com.courier.api.models.lists.subscriptions.RecipientPreferences import org.junit.jupiter.api.Disabled @@ -40,61 +41,52 @@ internal class ListServiceTest { .build() val listService = client.lists() - val list = - listService.update( - ListUpdateParams.builder() - .listId("list_id") - .name("name") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - - list.validate() + listService.update( + ListUpdateParams.builder() + .listId("list_id") + .name("name") + .preferences( + RecipientPreferences.builder() + .categories( + RecipientPreferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .notifications( + RecipientPreferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + ) + ), + ) + .build() + ) + .build() + ) + .build() + ) } @Disabled("Prism tests are disabled") @@ -136,6 +128,11 @@ internal class ListServiceTest { .build() val listService = client.lists() - listService.restore("list_id") + listService.restore( + ListRestoreParams.builder() + .listId("list_id") + .body(JsonValue.from(mapOf())) + .build() + ) } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt index bfa54e0b..4c6aeb06 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt @@ -78,7 +78,7 @@ internal class MessageServiceTest { @Disabled("Prism tests are disabled") @Test - fun getContent() { + fun content() { val client = CourierOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -86,7 +86,7 @@ internal class MessageServiceTest { .build() val messageService = client.messages() - val response = messageService.getContent("message_id") + val response = messageService.content("message_id") response.validate() } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index 86d83405..9bc19a3e 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -8,12 +8,9 @@ import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.BaseMessageSendTo import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -68,7 +65,7 @@ internal class SendServiceTest { .context(MessageContext.builder().tenantId("tenant_id").build()) .data( BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) + .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) @@ -84,7 +81,7 @@ internal class SendServiceTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -126,55 +123,8 @@ internal class SendServiceTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Config - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("bar"), - ) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel - .Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to - "content", - "medium" to - "medium", - "source" to - "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("email") + .method(BaseMessage.Routing.Method.SINGLE) .build() ) .timeout( @@ -195,42 +145,32 @@ internal class SendServiceTest { .build() ) .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") + BaseMessageSendTo.To.UnionMember1.builder() .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() + BaseMessageSendTo.To.UnionMember1.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() + BaseMessageSendTo.To.UnionMember1.Filter.builder() .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter - .Operator + BaseMessageSendTo.To.UnionMember1.Filter.Operator .MEMBER_OF ) .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path + BaseMessageSendTo.To.UnionMember1.Filter.Path .ACCOUNT_ID ) .value("value") .build() ) + .listId("list_id") .build() ) .content( - Content.ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) + Content.ElementalContentSugar.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt similarity index 78% rename from courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt index a0098e6a..4a3aaa0c 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AutomationServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt @@ -1,19 +1,19 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.services.blocking +package com.courier.api.services.blocking.automations import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue -import com.courier.api.models.automations.AutomationInvokeAdHocParams -import com.courier.api.models.automations.AutomationInvokeByTemplateParams import com.courier.api.models.automations.invoke.AutomationInvokeParams +import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams +import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) -internal class AutomationServiceTest { +internal class InvokeServiceTest { @Disabled("Prism tests are disabled") @Test @@ -23,11 +23,11 @@ internal class AutomationServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val automationService = client.automations() + val invokeService = client.automations().invoke() val automationInvokeResponse = - automationService.invokeAdHoc( - AutomationInvokeAdHocParams.builder() + invokeService.invokeAdHoc( + InvokeInvokeAdHocParams.builder() .brand("brand") .data( AutomationInvokeParams.Data.builder() @@ -38,15 +38,14 @@ internal class AutomationServiceTest { .recipient("recipient") .template("template") .automation( - AutomationInvokeAdHocParams.Automation.builder() + InvokeInvokeAdHocParams.Automation.builder() .addStep( - AutomationInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep + InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep .builder() .if_("if") .ref("ref") .action( - AutomationInvokeAdHocParams.Automation.Step + InvokeInvokeAdHocParams.Automation.Step .AutomationAddToDigestStep .Action .ADD_TO_DIGEST @@ -71,11 +70,11 @@ internal class AutomationServiceTest { .baseUrl(TestServerExtension.BASE_URL) .apiKey("My API Key") .build() - val automationService = client.automations() + val invokeService = client.automations().invoke() val automationInvokeResponse = - automationService.invokeByTemplate( - AutomationInvokeByTemplateParams.builder() + invokeService.invokeByTemplate( + InvokeInvokeByTemplateParams.builder() .templateId("templateId") .automationInvokeParams( AutomationInvokeParams.builder() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt new file mode 100644 index 00000000..2476c72d --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.services.blocking.tenants + +import com.courier.api.TestServerExtension +import com.courier.api.client.okhttp.CourierOkHttpClient +import com.courier.api.models.tenants.templates.TemplateListParams +import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class TemplateServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val templateService = client.tenants().templates() + + val baseTemplateTenantAssociation = + templateService.retrieve( + TemplateRetrieveParams.builder() + .tenantId("tenant_id") + .templateId("template_id") + .build() + ) + + baseTemplateTenantAssociation.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun list() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val templateService = client.tenants().templates() + + val templates = + templateService.list( + TemplateListParams.builder() + .tenantId("tenant_id") + .cursor("cursor") + .limit(0L) + .build() + ) + + templates.validate() + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt index b6781c61..255c522c 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt @@ -7,7 +7,7 @@ import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.models.users.tokens.TokenAddSingleParams import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenRetrieveSingleParams +import com.courier.api.models.users.tokens.TokenRetrieveParams import com.courier.api.models.users.tokens.TokenUpdateParams import com.courier.api.models.users.tokens.UserToken import org.junit.jupiter.api.Disabled @@ -17,6 +17,24 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class TokenServiceTest { + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + CourierOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val tokenService = client.users().tokens() + + val token = + tokenService.retrieve( + TokenRetrieveParams.builder().userId("user_id").token("token").build() + ) + + token.validate() + } + @Disabled("Prism tests are disabled") @Test fun update() { @@ -122,22 +140,4 @@ internal class TokenServiceTest { .build() ) } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveSingle() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - val response = - tokenService.retrieveSingle( - TokenRetrieveSingleParams.builder().userId("user_id").token("token").build() - ) - - response.validate() - } } diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt index 40930df0..674353b3 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -5,12 +5,12 @@ package com.courier.api.proguard import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper +import com.courier.api.models.automations.invoke.MergeAlgorithm import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content -import com.courier.api.models.send.ElementalNode import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.RoutingMethod -import com.courier.api.models.send.Utm +import com.courier.api.models.tenants.templates.ElementalContent +import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -121,7 +121,7 @@ internal class ProGuardCompatibilityTest { .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + BaseMessage.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -163,46 +163,8 @@ internal class ProGuardCompatibilityTest { ) .routing( BaseMessage.Routing.builder() - .addChannel( - BaseMessage.Routing.Channel.RoutingStrategyChannel.builder() - .channel("channel") - .config( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Config - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .if_("if") - .method(RoutingMethod.ALL) - .providers( - BaseMessage.Routing.Channel.RoutingStrategyChannel.Providers - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .build() - ) - .method(RoutingMethod.ALL) + .addChannel("string") + .method(BaseMessage.Routing.Method.ALL) .build() ) .timeout( @@ -238,7 +200,7 @@ internal class ProGuardCompatibilityTest { val jsonMapper = jsonMapper() val content = Content.ofElemental( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( ElementalNode.UnionMember0.builder() .addChannel("string") @@ -260,16 +222,16 @@ internal class ProGuardCompatibilityTest { } @Test - fun routingMethodRoundtrip() { + fun mergeAlgorithmRoundtrip() { val jsonMapper = jsonMapper() - val routingMethod = RoutingMethod.ALL + val mergeAlgorithm = MergeAlgorithm.REPLACE - val roundtrippedRoutingMethod = + val roundtrippedMergeAlgorithm = jsonMapper.readValue( - jsonMapper.writeValueAsString(routingMethod), - jacksonTypeRef(), + jsonMapper.writeValueAsString(mergeAlgorithm), + jacksonTypeRef(), ) - assertThat(roundtrippedRoutingMethod).isEqualTo(routingMethod) + assertThat(roundtrippedMergeAlgorithm).isEqualTo(mergeAlgorithm) } } From 6b9f5296179dccc64931dd2afe8802cf06b69873 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 23:23:27 +0000 Subject: [PATCH 18/33] feat(api): manual updates --- .stats.yml | 2 +- .../api/models/bulk/InboundBulkMessage.kt | 4 +- .../com/courier/api/models/send/Content.kt | 3822 ++++++++++++++- .../com/courier/api/models/send/Message.kt | 4 +- .../tenants/templates/ElementalChannelNode.kt | 572 --- .../tenants/templates/ElementalContent.kt | 274 -- .../tenants/templates/ElementalGroupNode.kt | 385 -- .../models/tenants/templates/ElementalNode.kt | 4182 ----------------- .../tenants/templates/TemplateListResponse.kt | 91 +- ...ciation.kt => TemplateRetrieveResponse.kt} | 33 +- .../async/tenants/TemplateServiceAsync.kt | 18 +- .../async/tenants/TemplateServiceAsyncImpl.kt | 10 +- .../blocking/tenants/TemplateService.kt | 25 +- .../blocking/tenants/TemplateServiceImpl.kt | 10 +- .../courier/api/models/send/ContentTest.kt | 14 +- .../courier/api/models/send/MessageTest.kt | 14 +- .../BaseTemplateTenantAssociationTest.kt | 51 - .../templates/ElementalChannelNodeTest.kt | 98 - .../tenants/templates/ElementalContentTest.kt | 72 - .../templates/ElementalGroupNodeTest.kt | 78 - .../tenants/templates/ElementalNodeTest.kt | 450 -- .../templates/TemplateListResponseTest.kt | 18 +- .../templates/TemplateRetrieveResponseTest.kt | 50 + .../async/tenants/TemplateServiceAsyncTest.kt | 6 +- .../blocking/tenants/TemplateServiceTest.kt | 4 +- .../api/proguard/ProGuardCompatibilityTest.kt | 8 +- 26 files changed, 3992 insertions(+), 6303 deletions(-) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/{BaseTemplateTenantAssociation.kt => TemplateRetrieveResponse.kt} (90%) delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 1091de1b..e5f08384 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 77 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-f2aedc1eadc5dfc25984cacada32b0b603b441282b70c7f246545eeb10e1100f.yml openapi_spec_hash: 9f40fc40e0269789116564dd953e71ef -config_hash: e3d76c7c10d5045dce1d5c823e778b93 +config_hash: 5563a6ac95907ac79cb554a55a14e24d diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt index 67d16aa5..966be3c5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt @@ -16,7 +16,6 @@ import com.courier.api.errors.CourierInvalidDataException import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content import com.courier.api.models.send.MessageContext -import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -2110,7 +2109,8 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) + fun content(elemental: Content.ElementalContent) = + content(Content.ofElemental(elemental)) /** * Alias for calling [content] with diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt index 03d4d2e2..e3d6bdfa 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -4,15 +4,17 @@ package com.courier.api.models.send import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing import com.courier.api.core.JsonValue import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -27,6 +29,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ @JsonDeserialize(using = Content.Deserializer::class) @@ -212,6 +215,3823 @@ private constructor( } } + class ElementalContent + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val elements: JsonField>, + private val version: JsonField, + private val brand: JsonValue, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), + ) : this(elements, version, brand, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * For example, "2022-01-01" + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalContent]. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalContent]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var version: JsonField? = null + private var brand: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalContent: ElementalContent) = apply { + elements = elementalContent.elements.map { it.toMutableList() } + version = elementalContent.version + brand = elementalContent.brand + additionalProperties = elementalContent.additionalProperties.toMutableMap() + } + + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [Element] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: Element) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `Element.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: Element.UnionMember0) = + addElement(Element.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `Element.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: Element.UnionMember1) = + addElement(Element.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `Element.ofType(type)`. */ + fun addElement(type: Element.Type) = addElement(Element.ofType(type)) + + /** Alias for calling [addElement] with `Element.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: Element.UnionMember3) = + addElement(Element.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `Element.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: Element.UnionMember4) = + addElement(Element.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `Element.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: Element.UnionMember5) = + addElement(Element.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `Element.ofType(type)`. */ + fun addElement(type: Element.Type) = addElement(Element.ofType(type)) + + /** Alias for calling [addElement] with `Element.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: Element.UnionMember7) = + addElement(Element.ofUnionMember7(unionMember7)) + + /** For example, "2022-01-01" */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun brand(brand: JsonValue) = apply { this.brand = brand } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalContent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalContent = + ElementalContent( + checkRequired("elements", elements).map { it.toImmutable() }, + checkRequired("version", version), + brand, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalContent = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + version() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Element.Deserializer::class) + @JsonSerialize(using = Element.Serializer::class) + class Element + private constructor( + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val type: Type? = null, + private val unionMember3: UnionMember3? = null, + private val unionMember4: UnionMember4? = null, + private val unionMember5: UnionMember5? = null, + private val type: Type? = null, + private val unionMember7: UnionMember7? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun type(): Optional = Optional.ofNullable(type) + + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun unionMember4(): Optional = Optional.ofNullable(unionMember4) + + fun unionMember5(): Optional = Optional.ofNullable(unionMember5) + + fun type(): Optional = Optional.ofNullable(type) + + fun unionMember7(): Optional = Optional.ofNullable(unionMember7) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isType(): Boolean = type != null + + fun isUnionMember3(): Boolean = unionMember3 != null + + fun isUnionMember4(): Boolean = unionMember4 != null + + fun isUnionMember5(): Boolean = unionMember5 != null + + fun isType(): Boolean = type != null + + fun isUnionMember7(): Boolean = unionMember7 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun asType(): Type = type.getOrThrow("type") + + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") + + fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + + fun asType(): Type = type.getOrThrow("type") + + fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + type != null -> visitor.visitType(type) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) + unionMember4 != null -> visitor.visitUnionMember4(unionMember4) + unionMember5 != null -> visitor.visitUnionMember5(unionMember5) + type != null -> visitor.visitType(type) + unionMember7 != null -> visitor.visitUnionMember7(unionMember7) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Element = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitType(type: Type) { + type.validate() + } + + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } + + override fun visitUnionMember4(unionMember4: UnionMember4) { + unionMember4.validate() + } + + override fun visitUnionMember5(unionMember5: UnionMember5) { + unionMember5.validate() + } + + override fun visitType(type: Type) { + type.validate() + } + + override fun visitUnionMember7(unionMember7: UnionMember7) { + unionMember7.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = + unionMember1.validity() + + override fun visitType(type: Type) = type.validity() + + override fun visitUnionMember3(unionMember3: UnionMember3) = + unionMember3.validity() + + override fun visitUnionMember4(unionMember4: UnionMember4) = + unionMember4.validity() + + override fun visitUnionMember5(unionMember5: UnionMember5) = + unionMember5.validity() + + override fun visitType(type: Type) = type.validity() + + override fun visitUnionMember7(unionMember7: UnionMember7) = + unionMember7.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Element && + unionMember0 == other.unionMember0 && + unionMember1 == other.unionMember1 && + type == other.type && + unionMember3 == other.unionMember3 && + unionMember4 == other.unionMember4 && + unionMember5 == other.unionMember5 && + type == other.type && + unionMember7 == other.unionMember7 + } + + override fun hashCode(): Int = + Objects.hash( + unionMember0, + unionMember1, + type, + unionMember3, + unionMember4, + unionMember5, + type, + unionMember7, + ) + + override fun toString(): String = + when { + unionMember0 != null -> "Element{unionMember0=$unionMember0}" + unionMember1 != null -> "Element{unionMember1=$unionMember1}" + type != null -> "Element{type=$type}" + unionMember3 != null -> "Element{unionMember3=$unionMember3}" + unionMember4 != null -> "Element{unionMember4=$unionMember4}" + unionMember5 != null -> "Element{unionMember5=$unionMember5}" + type != null -> "Element{type=$type}" + unionMember7 != null -> "Element{unionMember7=$unionMember7}" + _json != null -> "Element{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Element") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + Element(unionMember0 = unionMember0) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = + Element(unionMember1 = unionMember1) + + @JvmStatic fun ofType(type: Type) = Element(type = type) + + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = + Element(unionMember3 = unionMember3) + + @JvmStatic + fun ofUnionMember4(unionMember4: UnionMember4) = + Element(unionMember4 = unionMember4) + + @JvmStatic + fun ofUnionMember5(unionMember5: UnionMember5) = + Element(unionMember5 = unionMember5) + + @JvmStatic fun ofType(type: Type) = Element(type = type) + + @JvmStatic + fun ofUnionMember7(unionMember7: UnionMember7) = + Element(unionMember7 = unionMember7) + } + + /** + * An interface that defines how to map each variant of [Element] to a value of type + * [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + fun visitType(type: Type): T + + fun visitUnionMember3(unionMember3: UnionMember3): T + + fun visitUnionMember4(unionMember4: UnionMember4): T + + fun visitUnionMember5(unionMember5: UnionMember5): T + + fun visitType(type: Type): T + + fun visitUnionMember7(unionMember7: UnionMember7): T + + /** + * Maps an unknown variant of [Element] to a value of type [T]. + * + * An instance of [Element] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown Element: $json") + } + } + + internal class Deserializer : BaseDeserializer(Element::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Element { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(type = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember4 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember5 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(type = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Element(unionMember7 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> Element(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Element::class) { + + override fun serialize( + value: Element, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.type != null -> generator.writeObject(value.type) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) + value.unionMember4 != null -> generator.writeObject(value.unionMember4) + value.unionMember5 != null -> generator.writeObject(value.unionMember5) + value.type != null -> generator.writeObject(value.type) + value.unionMember7 != null -> generator.writeObject(value.unionMember7) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Element") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + channels = unionMember0.channels.map { it.toMutableList() } + if_ = unionMember0.if_ + loop = unionMember0.loop + ref = unionMember0.ref + type = unionMember0.type + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + channels = unionMember1.channels.map { it.toMutableList() } + if_ = unionMember1.if_ + loop = unionMember1.loop + ref = unionMember1.ref + type = unionMember1.type + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val META = of("meta") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + META + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + META, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + META -> Value.META + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + META -> Known.META + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class Type + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun type(): InnerType = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Type]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Type]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties = type.additionalProperties.toMutableMap() + } + + fun type(type: InnerType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [InnerType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Type]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Type = + Type(checkRequired("type", type), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class InnerType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val CHANNEL = of("channel") + + @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) + } + + /** An enum containing [InnerType]'s known values. */ + enum class Known { + CHANNEL + } + + /** + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InnerType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHANNEL, + /** + * An enum member indicating that [InnerType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHANNEL -> Value.CHANNEL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + CHANNEL -> Known.CHANNEL + else -> throw CourierInvalidDataException("Unknown InnerType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): InnerType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + channels = unionMember3.channels.map { it.toMutableList() } + if_ = unionMember3.if_ + loop = unionMember3.loop + ref = unionMember3.ref + type = unionMember3.type + additionalProperties = unionMember3.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = + UnionMember3( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IMAGE, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IMAGE -> Value.IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + IMAGE -> Known.IMAGE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember4 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember4]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember4: UnionMember4) = apply { + channels = unionMember4.channels.map { it.toMutableList() } + if_ = unionMember4.if_ + loop = unionMember4.loop + ref = unionMember4.ref + type = unionMember4.type + additionalProperties = unionMember4.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember4]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember4 = + UnionMember4( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember4 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val ACTION = of("action") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACTION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTION, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTION -> Value.ACTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ACTION -> Known.ACTION + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember4 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember5 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember5]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember5: UnionMember5) = apply { + channels = unionMember5.channels.map { it.toMutableList() } + if_ = unionMember5.if_ + loop = unionMember5.loop + ref = unionMember5.ref + type = unionMember5.type + additionalProperties = unionMember5.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember5]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember5 = + UnionMember5( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember5 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val DIVIDER = of("divider") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIVIDER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDER, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDER -> Value.DIVIDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + DIVIDER -> Known.DIVIDER + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember5 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class Type + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun type(): InnerType = type.getRequired("type") + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Type]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Type]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(type: Type) = apply { + this.type = type.type + additionalProperties = type.additionalProperties.toMutableMap() + } + + fun type(type: InnerType) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [InnerType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Type]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Type = + Type(checkRequired("type", type), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + type().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) + + class InnerType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val GROUP = of("group") + + @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) + } + + /** An enum containing [InnerType]'s known values. */ + enum class Known { + GROUP + } + + /** + * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [InnerType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUP, + /** + * An enum member indicating that [InnerType] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUP -> Value.GROUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + GROUP -> Known.GROUP + else -> throw CourierInvalidDataException("Unknown InnerType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): InnerType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InnerType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Type{type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember7 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") + @ExcludeMissing + loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember7]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember7: UnionMember7) = apply { + channels = unionMember7.channels.map { it.toMutableList() } + if_ = unionMember7.if_ + loop = unionMember7.loop + ref = unionMember7.ref + type = unionMember7.type + additionalProperties = unionMember7.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember7]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember7 = + UnionMember7( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember7 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val QUOTE = of("quote") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + QUOTE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + QUOTE, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUOTE -> Value.QUOTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + QUOTE -> Known.QUOTE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember7 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalContent && + elements == other.elements && + version == other.version && + brand == other.brand && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, version, brand, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" + } + /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ class ElementalContentSugar @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt index 50851d78..d9a75557 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt @@ -13,7 +13,6 @@ import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow import com.courier.api.errors.CourierInvalidDataException import com.courier.api.models.bulk.UserRecipient -import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -898,7 +897,8 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) + fun content(elemental: Content.ElementalContent) = + content(Content.ofElemental(elemental)) /** * Alias for calling [content] with diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt deleted file mode 100644 index 0700d91f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt +++ /dev/null @@ -1,572 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ElementalChannelNode -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val channel: JsonField, - private val channels: JsonField>, - private val elements: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val raw: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(channel, channels, elements, if_, loop, raw, ref, mutableMapOf()) - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` is - * `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun elements(): Optional> = elements.getOptional("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun raw(): Optional = raw.getOptional("raw") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [raw]. - * - * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalChannelNode]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalChannelNode]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var channels: JsonField>? = null - private var elements: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var raw: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalChannelNode: ElementalChannelNode) = apply { - channel = elementalChannelNode.channel - channels = elementalChannelNode.channels.map { it.toMutableList() } - elements = elementalChannelNode.elements.map { it.toMutableList() } - if_ = elementalChannelNode.if_ - loop = elementalChannelNode.loop - raw = elementalChannelNode.raw - ref = elementalChannelNode.ref - additionalProperties = elementalChannelNode.additionalProperties.toMutableMap() - } - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - */ - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` - * is `required`. - */ - fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) - - /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ - fun elements(elements: Optional>) = elements(elements.getOrNull()) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - */ - fun raw(raw: Raw?) = raw(JsonField.ofNullable(raw)) - - /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ - fun raw(raw: Optional) = raw(raw.getOrNull()) - - /** - * Sets [Builder.raw] to an arbitrary JSON value. - * - * You should usually call [Builder.raw] with a well-typed [Raw] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. - */ - fun raw(raw: JsonField) = apply { this.raw = raw } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalChannelNode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalChannelNode = - ElementalChannelNode( - checkRequired("channel", channel), - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - (elements ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - raw, - ref, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalChannelNode = apply { - if (validated) { - return@apply - } - - channel() - channels() - elements().ifPresent { it.forEach { it.validate() } } - if_() - loop() - raw().ifPresent { it.validate() } - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (raw.asKnown().getOrNull()?.validity() ?: 0) + - (if (ref.asKnown().isPresent) 1 else 0) - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. - */ - class Raw - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Raw]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Raw]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(raw: Raw) = apply { - additionalProperties = raw.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Raw]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Raw = Raw(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Raw = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Raw && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Raw{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalChannelNode && - channel == other.channel && - channels == other.channels && - elements == other.elements && - if_ == other.if_ && - loop == other.loop && - raw == other.raw && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channel, channels, elements, if_, loop, raw, ref, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalChannelNode{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt deleted file mode 100644 index 536579a9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt +++ /dev/null @@ -1,274 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ElementalContent -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val elements: JsonField>, - private val version: JsonField, - private val brand: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), - ) : this(elements, version, brand, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * For example, "2022-01-01" - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalContent]. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalContent]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var version: JsonField? = null - private var brand: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalContent: ElementalContent) = apply { - elements = elementalContent.elements.map { it.toMutableList() } - version = elementalContent.version - brand = elementalContent.brand - additionalProperties = elementalContent.additionalProperties.toMutableMap() - } - - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - /** For example, "2022-01-01" */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - fun brand(brand: JsonValue) = apply { this.brand = brand } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalContent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalContent = - ElementalContent( - checkRequired("elements", elements).map { it.toImmutable() }, - checkRequired("version", version), - brand, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalContent = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - version() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalContent && - elements == other.elements && - version == other.version && - brand == other.brand && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, version, brand, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt deleted file mode 100644 index ca5b8af9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt +++ /dev/null @@ -1,385 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ElementalGroupNode -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val elements: JsonField>, - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(elements, channels, if_, loop, ref, mutableMapOf()) - - /** - * Sub elements to render. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalGroupNode]. - * - * The following fields are required: - * ```java - * .elements() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalGroupNode]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalGroupNode: ElementalGroupNode) = apply { - elements = elementalGroupNode.elements.map { it.toMutableList() } - channels = elementalGroupNode.channels.map { it.toMutableList() } - if_ = elementalGroupNode.if_ - loop = elementalGroupNode.loop - ref = elementalGroupNode.ref - additionalProperties = elementalGroupNode.additionalProperties.toMutableMap() - } - - /** Sub elements to render. */ - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalGroupNode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalGroupNode = - ElementalGroupNode( - checkRequired("elements", elements).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalGroupNode = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - channels() - if_() - loop() - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalGroupNode && - elements == other.elements && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, channels, if_, loop, ref, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalGroupNode{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt deleted file mode 100644 index 0f1d982c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt +++ /dev/null @@ -1,4182 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is sent - * through email, and a more concise message in a push notification. Channel elements are only valid - * as top-level elements; you cannot nest channel elements. If there is a channel element specified - * at the top-level of the document, all sibling elements must be channel elements. Note: As an - * alternative, most elements support a `channel` property. Which allows you to selectively display - * an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for - * more details. - */ -@JsonDeserialize(using = ElementalNode.Deserializer::class) -@JsonSerialize(using = ElementalNode.Serializer::class) -class ElementalNode -private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val unionMember6: UnionMember6? = null, - private val unionMember7: UnionMember7? = null, - private val _json: JsonValue? = null, -) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun unionMember6(): Optional = Optional.ofNullable(unionMember6) - - fun unionMember7(): Optional = Optional.ofNullable(unionMember7) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun isUnionMember5(): Boolean = unionMember5 != null - - fun isUnionMember6(): Boolean = unionMember6 != null - - fun isUnionMember7(): Boolean = unionMember7 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") - - fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - unionMember6 != null -> visitor.visitUnionMember6(unionMember6) - unionMember7 != null -> visitor.visitUnionMember7(unionMember7) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ElementalNode = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } - - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() - } - - override fun visitUnionMember3(unionMember3: UnionMember3) { - unionMember3.validate() - } - - override fun visitUnionMember4(unionMember4: UnionMember4) { - unionMember4.validate() - } - - override fun visitUnionMember5(unionMember5: UnionMember5) { - unionMember5.validate() - } - - override fun visitUnionMember6(unionMember6: UnionMember6) { - unionMember6.validate() - } - - override fun visitUnionMember7(unionMember7: UnionMember7) { - unionMember7.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - - override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() - - override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() - - override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() - - override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() - - override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() - - override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() - - override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalNode && - unionMember0 == other.unionMember0 && - unionMember1 == other.unionMember1 && - unionMember2 == other.unionMember2 && - unionMember3 == other.unionMember3 && - unionMember4 == other.unionMember4 && - unionMember5 == other.unionMember5 && - unionMember6 == other.unionMember6 && - unionMember7 == other.unionMember7 - } - - override fun hashCode(): Int = - Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - unionMember6, - unionMember7, - ) - - override fun toString(): String = - when { - unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" - unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" - unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" - unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" - unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" - unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" - unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" - unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" - _json != null -> "ElementalNode{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ElementalNode") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) - - /** - * The channel element allows a notification to be customized based on which channel it is - * sent through. For example, you may want to display a detailed message when the - * notification is sent through email, and a more concise message in a push notification. - * Channel elements are only valid as top-level elements; you cannot nest channel elements. - * If there is a channel element specified at the top-level of the document, all sibling - * elements must be channel elements. Note: As an alternative, most elements support a - * `channel` property. Which allows you to selectively display an individual element on a - * per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) - - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) - - /** - * Allows you to group elements together. This can be useful when used in combination with - * "if" or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - @JvmStatic - fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) - - @JvmStatic - fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) - } - - /** - * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. - */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - /** - * The channel element allows a notification to be customized based on which channel it is - * sent through. For example, you may want to display a detailed message when the - * notification is sent through email, and a more concise message in a push notification. - * Channel elements are only valid as top-level elements; you cannot nest channel elements. - * If there is a channel element specified at the top-level of the document, all sibling - * elements must be channel elements. Note: As an alternative, most elements support a - * `channel` property. Which allows you to selectively display an individual element on a - * per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun visitUnionMember5(unionMember5: UnionMember5): T - - /** - * Allows you to group elements together. This can be useful when used in combination with - * "if" or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun visitUnionMember6(unionMember6: UnionMember6): T - - fun visitUnionMember7(unionMember7: UnionMember7): T - - /** - * Maps an unknown variant of [ElementalNode] to a value of type [T]. - * - * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown ElementalNode: $json") - } - } - - internal class Deserializer : BaseDeserializer(ElementalNode::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember2 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember4 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember5 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember6 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember7 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> ElementalNode(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ElementalNode::class) { - - override fun serialize( - value: ElementalNode, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value.unionMember6 != null -> generator.writeObject(value.unionMember6) - value.unionMember7 != null -> generator.writeObject(value.unionMember7) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ElementalNode") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - channels = unionMember0.channels.map { it.toMutableList() } - if_ = unionMember0.if_ - loop = unionMember0.loop - ref = unionMember0.ref - type = unionMember0.type - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember0 = - UnionMember0( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TEXT = of("text") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TEXT - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TEXT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - channels = unionMember1.channels.map { it.toMutableList() } - if_ = unionMember1.if_ - loop = unionMember1.loop - ref = unionMember1.ref - type = unionMember1.type - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val META = of("meta") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - META - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - META, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - META -> Value.META - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - META -> Known.META - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - class UnionMember2 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channel: JsonField, - private val channels: JsonField>, - private val elements: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val raw: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("raw") - @ExcludeMissing - raw: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channel, channels, elements, if_, loop, raw, ref, type, mutableMapOf()) - - fun toElementalChannelNode(): ElementalChannelNode = - ElementalChannelNode.builder() - .channel(channel) - .channels(channels) - .elements(elements) - .if_(if_) - .loop(loop) - .raw(raw) - .ref(ref) - .build() - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` - * is `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun elements(): Optional> = elements.getOptional("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun raw(): Optional = raw.getOptional("raw") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [raw]. - * - * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember2]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember2]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var channels: JsonField>? = null - private var elements: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var raw: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - channel = unionMember2.channel - channels = unionMember2.channels.map { it.toMutableList() } - elements = unionMember2.elements.map { it.toMutableList() } - if_ = unionMember2.if_ - loop = unionMember2.loop - raw = unionMember2.raw - ref = unionMember2.ref - type = unionMember2.type - additionalProperties = unionMember2.additionalProperties.toMutableMap() - } - - /** - * The channel the contents of this element should be applied to. Can be `email`, - * `push`, `direct_message`, `sms` or a provider such as slack - */ - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, - * `elements` is `required`. - */ - fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) - - /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ - fun elements(elements: Optional>) = elements(elements.getOrNull()) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - */ - fun raw(raw: ElementalChannelNode.Raw?) = raw(JsonField.ofNullable(raw)) - - /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ - fun raw(raw: Optional) = raw(raw.getOrNull()) - - /** - * Sets [Builder.raw] to an arbitrary JSON value. - * - * You should usually call [Builder.raw] with a well-typed [ElementalChannelNode.Raw] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun raw(raw: JsonField) = apply { this.raw = raw } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember2]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember2 = - UnionMember2( - checkRequired("channel", channel), - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - (elements ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - raw, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember2 = apply { - if (validated) { - return@apply - } - - channel() - channels() - elements().ifPresent { it.forEach { it.validate() } } - if_() - loop() - raw().ifPresent { it.validate() } - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (raw.asKnown().getOrNull()?.validity() ?: 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHANNEL = of("channel") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CHANNEL - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHANNEL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHANNEL -> Value.CHANNEL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CHANNEL -> Known.CHANNEL - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - channel == other.channel && - channels == other.channels && - elements == other.elements && - if_ == other.if_ && - loop == other.loop && - raw == other.raw && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - channel, - channels, - elements, - if_, - loop, - raw, - ref, - type, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember2{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember3 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember3]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - channels = unionMember3.channels.map { it.toMutableList() } - if_ = unionMember3.if_ - loop = unionMember3.loop - ref = unionMember3.ref - type = unionMember3.type - additionalProperties = unionMember3.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember3]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember3 = - UnionMember3( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember3 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val IMAGE = of("image") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMAGE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IMAGE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IMAGE -> Value.IMAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IMAGE -> Known.IMAGE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember4 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember4]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - channels = unionMember4.channels.map { it.toMutableList() } - if_ = unionMember4.if_ - loop = unionMember4.loop - ref = unionMember4.ref - type = unionMember4.type - additionalProperties = unionMember4.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember4]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember4 = - UnionMember4( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember4 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTION = of("action") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ACTION - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTION -> Value.ACTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTION -> Known.ACTION - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember5 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember5]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - channels = unionMember5.channels.map { it.toMutableList() } - if_ = unionMember5.if_ - loop = unionMember5.loop - ref = unionMember5.ref - type = unionMember5.type - additionalProperties = unionMember5.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember5]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember5 = - UnionMember5( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember5 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DIVIDER = of("divider") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - DIVIDER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDER -> Value.DIVIDER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DIVIDER -> Known.DIVIDER - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember5 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - class UnionMember6 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val elements: JsonField>, - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(elements, channels, if_, loop, ref, type, mutableMapOf()) - - fun toElementalGroupNode(): ElementalGroupNode = - ElementalGroupNode.builder() - .elements(elements) - .channels(channels) - .if_(if_) - .loop(loop) - .ref(ref) - .build() - - /** - * Sub elements to render. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember6]. - * - * The following fields are required: - * ```java - * .elements() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember6]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember6: UnionMember6) = apply { - elements = unionMember6.elements.map { it.toMutableList() } - channels = unionMember6.channels.map { it.toMutableList() } - if_ = unionMember6.if_ - loop = unionMember6.loop - ref = unionMember6.ref - type = unionMember6.type - additionalProperties = unionMember6.additionalProperties.toMutableMap() - } - - /** Sub elements to render. */ - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember6]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember6 = - UnionMember6( - checkRequired("elements", elements).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember6 = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUP = of("group") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GROUP - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUP, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUP -> Value.GROUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUP -> Known.GROUP - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember6 && - elements == other.elements && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember6{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember7 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember7]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember7: UnionMember7) = apply { - channels = unionMember7.channels.map { it.toMutableList() } - if_ = unionMember7.if_ - loop = unionMember7.loop - ref = unionMember7.ref - type = unionMember7.type - additionalProperties = unionMember7.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember7]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember7 = - UnionMember7( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember7 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUOTE = of("quote") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - QUOTE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - QUOTE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - QUOTE -> Value.QUOTE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - QUOTE -> Known.QUOTE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember7 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt index 5447eab6..9824531c 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt @@ -479,10 +479,10 @@ private constructor( private constructor( private val id: JsonField, private val createdAt: JsonField, + private val data: JsonField, private val publishedAt: JsonField, private val updatedAt: JsonField, private val version: JsonField, - private val data: JsonField, private val additionalProperties: MutableMap, ) { @@ -492,6 +492,7 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("published_at") @ExcludeMissing publishedAt: JsonField = JsonMissing.of(), @@ -499,17 +500,7 @@ private constructor( @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - ) : this(id, createdAt, publishedAt, updatedAt, version, data, mutableMapOf()) - - fun toBaseTemplateTenantAssociation(): BaseTemplateTenantAssociation = - BaseTemplateTenantAssociation.builder() - .id(id) - .createdAt(createdAt) - .publishedAt(publishedAt) - .updatedAt(updatedAt) - .version(version) - .build() + ) : this(id, createdAt, data, publishedAt, updatedAt, version, mutableMapOf()) /** * The template's id @@ -528,36 +519,36 @@ private constructor( fun createdAt(): String = createdAt.getRequired("created_at") /** - * The timestamp at which the template was published + * The template's data containing it's routing configs * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun publishedAt(): String = publishedAt.getRequired("published_at") + fun data(): Data = data.getRequired("data") /** - * The timestamp at which the template was last updated + * The timestamp at which the template was published * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun updatedAt(): String = updatedAt.getRequired("updated_at") + fun publishedAt(): String = publishedAt.getRequired("published_at") /** - * The version of the template + * The timestamp at which the template was last updated * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun version(): String = version.getRequired("version") + fun updatedAt(): String = updatedAt.getRequired("updated_at") /** - * The template's data containing it's routing configs + * The version of the template * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun data(): Data = data.getRequired("data") + fun version(): String = version.getRequired("version") /** * Returns the raw JSON value of [id]. @@ -573,6 +564,13 @@ private constructor( */ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + /** * Returns the raw JSON value of [publishedAt]. * @@ -596,13 +594,6 @@ private constructor( */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -624,10 +615,10 @@ private constructor( * ```java * .id() * .createdAt() + * .data() * .publishedAt() * .updatedAt() * .version() - * .data() * ``` */ @JvmStatic fun builder() = Builder() @@ -638,20 +629,20 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null + private var data: JsonField? = null private var publishedAt: JsonField? = null private var updatedAt: JsonField? = null private var version: JsonField? = null - private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(item: Item) = apply { id = item.id createdAt = item.createdAt + data = item.data publishedAt = item.publishedAt updatedAt = item.updatedAt version = item.version - data = item.data additionalProperties = item.additionalProperties.toMutableMap() } @@ -679,6 +670,18 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** The template's data containing it's routing configs */ + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + /** The timestamp at which the template was published */ fun publishedAt(publishedAt: String) = publishedAt(JsonField.of(publishedAt)) @@ -717,18 +720,6 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } - /** The template's data containing it's routing configs */ - fun data(data: Data) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -757,10 +748,10 @@ private constructor( * ```java * .id() * .createdAt() + * .data() * .publishedAt() * .updatedAt() * .version() - * .data() * ``` * * @throws IllegalStateException if any required field is unset. @@ -769,10 +760,10 @@ private constructor( Item( checkRequired("id", id), checkRequired("createdAt", createdAt), + checkRequired("data", data), checkRequired("publishedAt", publishedAt), checkRequired("updatedAt", updatedAt), checkRequired("version", version), - checkRequired("data", data), additionalProperties.toMutableMap(), ) } @@ -786,10 +777,10 @@ private constructor( id() createdAt() + data().validate() publishedAt() updatedAt() version() - data().validate() validated = true } @@ -811,10 +802,10 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + (if (publishedAt.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + (if (version.asKnown().isPresent) 1 else 0) /** The template's data containing it's routing configs */ class Data @@ -987,21 +978,21 @@ private constructor( return other is Item && id == other.id && createdAt == other.createdAt && + data == other.data && publishedAt == other.publishedAt && updatedAt == other.updatedAt && version == other.version && - data == other.data && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, publishedAt, updatedAt, version, data, additionalProperties) + Objects.hash(id, createdAt, data, publishedAt, updatedAt, version, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Item{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, data=$data, additionalProperties=$additionalProperties}" + "Item{id=$id, createdAt=$createdAt, data=$data, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponse.kt similarity index 90% rename from courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponse.kt index e5b4b448..83f870a5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponse.kt @@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects -class BaseTemplateTenantAssociation +class TemplateRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -129,8 +129,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of - * [BaseTemplateTenantAssociation]. + * Returns a mutable builder for constructing an instance of [TemplateRetrieveResponse]. * * The following fields are required: * ```java @@ -144,7 +143,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [BaseTemplateTenantAssociation]. */ + /** A builder for [TemplateRetrieveResponse]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -155,13 +154,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(baseTemplateTenantAssociation: BaseTemplateTenantAssociation) = apply { - id = baseTemplateTenantAssociation.id - createdAt = baseTemplateTenantAssociation.createdAt - publishedAt = baseTemplateTenantAssociation.publishedAt - updatedAt = baseTemplateTenantAssociation.updatedAt - version = baseTemplateTenantAssociation.version - additionalProperties = baseTemplateTenantAssociation.additionalProperties.toMutableMap() + internal fun from(templateRetrieveResponse: TemplateRetrieveResponse) = apply { + id = templateRetrieveResponse.id + createdAt = templateRetrieveResponse.createdAt + publishedAt = templateRetrieveResponse.publishedAt + updatedAt = templateRetrieveResponse.updatedAt + version = templateRetrieveResponse.version + additionalProperties = templateRetrieveResponse.additionalProperties.toMutableMap() } /** The template's id */ @@ -242,7 +241,7 @@ private constructor( } /** - * Returns an immutable instance of [BaseTemplateTenantAssociation]. + * Returns an immutable instance of [TemplateRetrieveResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -257,8 +256,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): BaseTemplateTenantAssociation = - BaseTemplateTenantAssociation( + fun build(): TemplateRetrieveResponse = + TemplateRetrieveResponse( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("publishedAt", publishedAt), @@ -270,7 +269,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BaseTemplateTenantAssociation = apply { + fun validate(): TemplateRetrieveResponse = apply { if (validated) { return@apply } @@ -309,7 +308,7 @@ private constructor( return true } - return other is BaseTemplateTenantAssociation && + return other is TemplateRetrieveResponse && id == other.id && createdAt == other.createdAt && publishedAt == other.publishedAt && @@ -325,5 +324,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BaseTemplateTenantAssociation{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" + "TemplateRetrieveResponse{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt index 57f29c9f..520ed971 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt @@ -5,10 +5,10 @@ package com.courier.api.services.async.tenants import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -30,7 +30,7 @@ interface TemplateServiceAsync { fun retrieve( templateId: String, params: TemplateRetrieveParams, - ): CompletableFuture = + ): CompletableFuture = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ @@ -38,18 +38,18 @@ interface TemplateServiceAsync { templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ - fun retrieve(params: TemplateRetrieveParams): CompletableFuture = + fun retrieve(params: TemplateRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** List Templates in Tenant */ fun list(tenantId: String): CompletableFuture = @@ -107,7 +107,7 @@ interface TemplateServiceAsync { fun retrieve( templateId: String, params: TemplateRetrieveParams, - ): CompletableFuture> = + ): CompletableFuture> = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ @@ -115,20 +115,20 @@ interface TemplateServiceAsync { templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt index 7cf0f7a1..23155206 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt @@ -15,10 +15,10 @@ import com.courier.api.core.http.HttpResponse.Handler import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.parseable import com.courier.api.core.prepareAsync -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -38,7 +38,7 @@ class TemplateServiceAsyncImpl internal constructor(private val clientOptions: C override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /tenants/{tenant_id}/templates/{template_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } @@ -62,13 +62,13 @@ class TemplateServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("templateId", params.templateId().getOrNull()) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt index 95f8bc9b..d1b08f8c 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt @@ -5,10 +5,10 @@ package com.courier.api.services.blocking.tenants import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -27,28 +27,26 @@ interface TemplateService { fun withOptions(modifier: Consumer): TemplateService /** Get a Template in Tenant */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - ): BaseTemplateTenantAssociation = retrieve(templateId, params, RequestOptions.none()) + fun retrieve(templateId: String, params: TemplateRetrieveParams): TemplateRetrieveResponse = + retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): BaseTemplateTenantAssociation = + ): TemplateRetrieveResponse = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ - fun retrieve(params: TemplateRetrieveParams): BaseTemplateTenantAssociation = + fun retrieve(params: TemplateRetrieveParams): TemplateRetrieveResponse = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): BaseTemplateTenantAssociation + ): TemplateRetrieveResponse /** List Templates in Tenant */ fun list(tenantId: String): TemplateListResponse = list(tenantId, TemplateListParams.none()) @@ -97,7 +95,7 @@ interface TemplateService { fun retrieve( templateId: String, params: TemplateRetrieveParams, - ): HttpResponseFor = + ): HttpResponseFor = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ @@ -106,21 +104,20 @@ interface TemplateService { templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ @MustBeClosed - fun retrieve( - params: TemplateRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) + fun retrieve(params: TemplateRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt index 71d74426..787d7be2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt @@ -15,10 +15,10 @@ import com.courier.api.core.http.HttpResponse.Handler import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.parseable import com.courier.api.core.prepare -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams +import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -37,7 +37,7 @@ class TemplateServiceImpl internal constructor(private val clientOptions: Client override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): BaseTemplateTenantAssociation = + ): TemplateRetrieveResponse = // get /tenants/{tenant_id}/templates/{template_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -61,13 +61,13 @@ class TemplateServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("templateId", params.templateId().getOrNull()) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt index 04338e09..698992ba 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt @@ -5,8 +5,6 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.templates.ElementalContent -import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -19,14 +17,14 @@ internal class ContentTest { @Test fun ofElemental() { val elemental = - ElementalContent.builder() + Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -44,14 +42,14 @@ internal class ContentTest { val jsonMapper = jsonMapper() val content = Content.ofElemental( - ElementalContent.builder() + Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt index e455bcc1..04188b3c 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt @@ -5,8 +5,6 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.templates.ElementalContent -import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -148,14 +146,14 @@ internal class MessageTest { .build() ) .content( - ElementalContent.builder() + Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -311,14 +309,14 @@ internal class MessageTest { .build() ) .content( - ElementalContent.builder() + Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt deleted file mode 100644 index dda241ef..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BaseTemplateTenantAssociationTest { - - @Test - fun create() { - val baseTemplateTenantAssociation = - BaseTemplateTenantAssociation.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .build() - - assertThat(baseTemplateTenantAssociation.id()).isEqualTo("id") - assertThat(baseTemplateTenantAssociation.createdAt()).isEqualTo("created_at") - assertThat(baseTemplateTenantAssociation.publishedAt()).isEqualTo("published_at") - assertThat(baseTemplateTenantAssociation.updatedAt()).isEqualTo("updated_at") - assertThat(baseTemplateTenantAssociation.version()).isEqualTo("version") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val baseTemplateTenantAssociation = - BaseTemplateTenantAssociation.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .build() - - val roundtrippedBaseTemplateTenantAssociation = - jsonMapper.readValue( - jsonMapper.writeValueAsString(baseTemplateTenantAssociation), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBaseTemplateTenantAssociation) - .isEqualTo(baseTemplateTenantAssociation) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt deleted file mode 100644 index 40d76a91..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalChannelNodeTest { - - @Test - fun create() { - val elementalChannelNode = - ElementalChannelNode.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .build() - - assertThat(elementalChannelNode.channel()).isEqualTo("channel") - assertThat(elementalChannelNode.channels().getOrNull()).containsExactly("string") - assertThat(elementalChannelNode.elements().getOrNull()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalChannelNode.if_()).contains("if") - assertThat(elementalChannelNode.loop()).contains("loop") - assertThat(elementalChannelNode.raw()) - .contains( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(elementalChannelNode.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalChannelNode = - ElementalChannelNode.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .build() - - val roundtrippedElementalChannelNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalChannelNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalChannelNode).isEqualTo(elementalChannelNode) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt deleted file mode 100644 index 1a816605..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalContentTest { - - @Test - fun create() { - val elementalContent = - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - - assertThat(elementalContent.elements()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalContent.version()).isEqualTo("version") - assertThat(elementalContent._brand()).isEqualTo(JsonValue.from(mapOf())) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalContent = - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - - val roundtrippedElementalContent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalContent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalContent).isEqualTo(elementalContent) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt deleted file mode 100644 index 57ed362b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalGroupNodeTest { - - @Test - fun create() { - val elementalGroupNode = - ElementalGroupNode.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .build() - - assertThat(elementalGroupNode.elements()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalGroupNode.channels().getOrNull()).containsExactly("string") - assertThat(elementalGroupNode.if_()).contains("if") - assertThat(elementalGroupNode.loop()).contains("loop") - assertThat(elementalGroupNode.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalGroupNode = - ElementalGroupNode.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .build() - - val roundtrippedElementalGroupNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalGroupNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalGroupNode).isEqualTo(elementalGroupNode) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt deleted file mode 100644 index a6fe92cb..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt +++ /dev/null @@ -1,450 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class ElementalNodeTest { - - @Test - fun ofUnionMember0() { - val unionMember0 = - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - - val elementalNode = ElementalNode.ofUnionMember0(unionMember0) - - assertThat(elementalNode.unionMember0()).contains(unionMember0) - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember0Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember1() { - val unionMember1 = - ElementalNode.UnionMember1.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember1.Type.META) - .build() - - val elementalNode = ElementalNode.ofUnionMember1(unionMember1) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).contains(unionMember1) - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember1Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember1( - ElementalNode.UnionMember1.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember1.Type.META) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember2() { - val unionMember2 = - ElementalNode.UnionMember2.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .type(ElementalNode.UnionMember2.Type.CHANNEL) - .build() - - val elementalNode = ElementalNode.ofUnionMember2(unionMember2) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).contains(unionMember2) - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember2Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember2( - ElementalNode.UnionMember2.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .type(ElementalNode.UnionMember2.Type.CHANNEL) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember3() { - val unionMember3 = - ElementalNode.UnionMember3.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember3.Type.IMAGE) - .build() - - val elementalNode = ElementalNode.ofUnionMember3(unionMember3) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).contains(unionMember3) - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember3Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember3( - ElementalNode.UnionMember3.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember3.Type.IMAGE) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember4() { - val unionMember4 = - ElementalNode.UnionMember4.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember4.Type.ACTION) - .build() - - val elementalNode = ElementalNode.ofUnionMember4(unionMember4) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).contains(unionMember4) - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember4Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember4( - ElementalNode.UnionMember4.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember4.Type.ACTION) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember5() { - val unionMember5 = - ElementalNode.UnionMember5.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember5.Type.DIVIDER) - .build() - - val elementalNode = ElementalNode.ofUnionMember5(unionMember5) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).contains(unionMember5) - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember5Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember5( - ElementalNode.UnionMember5.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember5.Type.DIVIDER) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember6() { - val unionMember6 = - ElementalNode.UnionMember6.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember6.Type.GROUP) - .build() - - val elementalNode = ElementalNode.ofUnionMember6(unionMember6) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).contains(unionMember6) - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember6Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember6( - ElementalNode.UnionMember6.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember6.Type.GROUP) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember7() { - val unionMember7 = - ElementalNode.UnionMember7.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember7.Type.QUOTE) - .build() - - val elementalNode = ElementalNode.ofUnionMember7(unionMember7) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).contains(unionMember7) - } - - @Test - fun ofUnionMember7Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember7( - ElementalNode.UnionMember7.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember7.Type.QUOTE) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val elementalNode = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { elementalNode.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt index 427e61d3..41303da7 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt @@ -23,9 +23,6 @@ internal class TemplateListResponseTest { TemplateListResponse.Item.builder() .id("id") .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") .data( TemplateListResponse.Item.Data.builder() .routing( @@ -36,6 +33,9 @@ internal class TemplateListResponseTest { ) .build() ) + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") .build() ) .nextUrl("next_url") @@ -50,9 +50,6 @@ internal class TemplateListResponseTest { TemplateListResponse.Item.builder() .id("id") .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") .data( TemplateListResponse.Item.Data.builder() .routing( @@ -63,6 +60,9 @@ internal class TemplateListResponseTest { ) .build() ) + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") .build() ) assertThat(templateListResponse.nextUrl()).contains("next_url") @@ -81,9 +81,6 @@ internal class TemplateListResponseTest { TemplateListResponse.Item.builder() .id("id") .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") .data( TemplateListResponse.Item.Data.builder() .routing( @@ -94,6 +91,9 @@ internal class TemplateListResponseTest { ) .build() ) + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") .build() ) .nextUrl("next_url") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt new file mode 100644 index 00000000..de5d7b67 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TemplateRetrieveResponseTest { + + @Test + fun create() { + val templateRetrieveResponse = + TemplateRetrieveResponse.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .build() + + assertThat(templateRetrieveResponse.id()).isEqualTo("id") + assertThat(templateRetrieveResponse.createdAt()).isEqualTo("created_at") + assertThat(templateRetrieveResponse.publishedAt()).isEqualTo("published_at") + assertThat(templateRetrieveResponse.updatedAt()).isEqualTo("updated_at") + assertThat(templateRetrieveResponse.version()).isEqualTo("version") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val templateRetrieveResponse = + TemplateRetrieveResponse.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .build() + + val roundtrippedTemplateRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(templateRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTemplateRetrieveResponse).isEqualTo(templateRetrieveResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt index f650a197..27d4470b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt @@ -23,7 +23,7 @@ internal class TemplateServiceAsyncTest { .build() val templateServiceAsync = client.tenants().templates() - val baseTemplateTenantAssociationFuture = + val templateFuture = templateServiceAsync.retrieve( TemplateRetrieveParams.builder() .tenantId("tenant_id") @@ -31,8 +31,8 @@ internal class TemplateServiceAsyncTest { .build() ) - val baseTemplateTenantAssociation = baseTemplateTenantAssociationFuture.get() - baseTemplateTenantAssociation.validate() + val template = templateFuture.get() + template.validate() } @Disabled("Prism tests are disabled") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt index 2476c72d..a7c32e45 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt @@ -23,7 +23,7 @@ internal class TemplateServiceTest { .build() val templateService = client.tenants().templates() - val baseTemplateTenantAssociation = + val template = templateService.retrieve( TemplateRetrieveParams.builder() .tenantId("tenant_id") @@ -31,7 +31,7 @@ internal class TemplateServiceTest { .build() ) - baseTemplateTenantAssociation.validate() + template.validate() } @Disabled("Prism tests are disabled") diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt index 674353b3..26c8af84 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -9,8 +9,6 @@ import com.courier.api.models.automations.invoke.MergeAlgorithm import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content import com.courier.api.models.send.MessageContext -import com.courier.api.models.tenants.templates.ElementalContent -import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -200,14 +198,14 @@ internal class ProGuardCompatibilityTest { val jsonMapper = jsonMapper() val content = Content.ofElemental( - ElementalContent.builder() + Content.ElementalContent.builder() .addElement( - ElementalNode.UnionMember0.builder() + Content.ElementalContent.Element.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) + .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) .build() ) .version("version") From 26e335a72dc4aebf9c3b71f440f317ce4409371c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 2 Oct 2025 23:39:49 +0000 Subject: [PATCH 19/33] feat(api): manual updates --- .stats.yml | 2 +- .../courier/api/models/ChannelPreference.kt | 177 + .../kotlin/com/courier/api/models/Rule.kt | 203 + .../courier/api/models/brands/BrandColors.kt | 228 + .../api/models/brands/BrandSettings.kt | 385 +- .../courier/api/models/brands/BrandSnippet.kt | 359 ++ .../api/models/brands/BrandSnippets.kt | 378 +- .../com/courier/api/models/brands/Email.kt | 161 + .../api/models/bulk/InboundBulkMessage.kt | 4 +- .../NotificationPreferenceDetails.kt | 292 ++ .../courier/api/models/send/BaseMessage.kt | 305 -- .../com/courier/api/models/send/Content.kt | 3822 +-------------- .../com/courier/api/models/send/Message.kt | 4 +- .../kotlin/com/courier/api/models/send/Utm.kt | 293 ++ ...se.kt => BaseTemplateTenantAssociation.kt} | 33 +- .../tenants/templates/ElementalChannelNode.kt | 572 +++ .../tenants/templates/ElementalContent.kt | 274 ++ .../tenants/templates/ElementalGroupNode.kt | 385 ++ .../models/tenants/templates/ElementalNode.kt | 4182 +++++++++++++++++ .../tenants/templates/TemplateListResponse.kt | 91 +- .../async/tenants/TemplateServiceAsync.kt | 18 +- .../async/tenants/TemplateServiceAsyncImpl.kt | 10 +- .../blocking/tenants/TemplateService.kt | 25 +- .../blocking/tenants/TemplateServiceImpl.kt | 10 +- .../api/models/ChannelPreferenceTest.kt | 35 + .../kotlin/com/courier/api/models/RuleTest.kt | 30 + .../api/models/brands/BrandColorsTest.kt | 44 + .../models/brands/BrandCreateParamsTest.kt | 24 +- .../models/brands/BrandListResponseTest.kt | 24 +- .../api/models/brands/BrandSettingsTest.kt | 12 +- .../api/models/brands/BrandSnippetTest.kt | 44 + .../api/models/brands/BrandSnippetsTest.kt | 12 +- .../courier/api/models/brands/BrandTest.kt | 24 +- .../models/brands/BrandUpdateParamsTest.kt | 24 +- .../courier/api/models/brands/EmailTest.kt | 39 + .../models/bulk/BulkCreateJobParamsTest.kt | 7 +- .../bulk/BulkRetrieveJobResponseTest.kt | 7 +- .../api/models/bulk/InboundBulkMessageTest.kt | 7 +- .../NotificationPreferenceDetailsTest.kt | 62 + .../api/models/send/BaseMessageTest.kt | 6 +- .../courier/api/models/send/ContentTest.kt | 14 +- .../courier/api/models/send/MessageTest.kt | 22 +- .../api/models/send/SendMessageParamsTest.kt | 6 +- .../com/courier/api/models/send/UtmTest.kt | 47 + .../BaseTemplateTenantAssociationTest.kt | 51 + .../templates/ElementalChannelNodeTest.kt | 98 + .../tenants/templates/ElementalContentTest.kt | 72 + .../templates/ElementalGroupNodeTest.kt | 78 + .../tenants/templates/ElementalNodeTest.kt | 450 ++ .../templates/TemplateListResponseTest.kt | 18 +- .../templates/TemplateRetrieveResponseTest.kt | 50 - .../courier/api/services/ErrorHandlingTest.kt | 35 +- .../courier/api/services/ServiceParamsTest.kt | 3 +- .../services/async/BrandServiceAsyncTest.kt | 19 +- .../services/async/BulkServiceAsyncTest.kt | 3 +- .../services/async/SendServiceAsyncTest.kt | 3 +- .../async/tenants/TemplateServiceAsyncTest.kt | 6 +- .../api/services/blocking/BrandServiceTest.kt | 19 +- .../api/services/blocking/BulkServiceTest.kt | 3 +- .../api/services/blocking/SendServiceTest.kt | 3 +- .../blocking/tenants/TemplateServiceTest.kt | 4 +- .../api/proguard/ProGuardCompatibilityTest.kt | 11 +- 62 files changed, 8476 insertions(+), 5153 deletions(-) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/{TemplateRetrieveResponse.kt => BaseTemplateTenantAssociation.kt} (90%) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt diff --git a/.stats.yml b/.stats.yml index e5f08384..2eb4ff1b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 77 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-f2aedc1eadc5dfc25984cacada32b0b603b441282b70c7f246545eeb10e1100f.yml openapi_spec_hash: 9f40fc40e0269789116564dd953e71ef -config_hash: 5563a6ac95907ac79cb554a55a14e24d +config_hash: 13f5653f46b22729d4969d901dbc5c9b diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt new file mode 100644 index 00000000..d00617ac --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt @@ -0,0 +1,177 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ChannelPreference +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val channel: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of() + ) : this(channel, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): ChannelClassification = channel.getRequired("channel") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") + @ExcludeMissing + fun _channel(): JsonField = channel + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChannelPreference]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChannelPreference]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channelPreference: ChannelPreference) = apply { + channel = channelPreference.channel + additionalProperties = channelPreference.additionalProperties.toMutableMap() + } + + fun channel(channel: ChannelClassification) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [ChannelClassification] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChannelPreference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChannelPreference = + ChannelPreference( + checkRequired("channel", channel), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChannelPreference = apply { + if (validated) { + return@apply + } + + channel().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (channel.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChannelPreference && + channel == other.channel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(channel, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChannelPreference{channel=$channel, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt new file mode 100644 index 00000000..86c8d646 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt @@ -0,0 +1,203 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Rule +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val until: JsonField, + private val start: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("until") @ExcludeMissing until: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing start: JsonField = JsonMissing.of(), + ) : this(until, start, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun until(): String = until.getRequired("until") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun start(): Optional = start.getOptional("start") + + /** + * Returns the raw JSON value of [until]. + * + * Unlike [until], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until + + /** + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Rule]. + * + * The following fields are required: + * ```java + * .until() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rule]. */ + class Builder internal constructor() { + + private var until: JsonField? = null + private var start: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rule: Rule) = apply { + until = rule.until + start = rule.start + additionalProperties = rule.additionalProperties.toMutableMap() + } + + fun until(until: String) = until(JsonField.of(until)) + + /** + * Sets [Builder.until] to an arbitrary JSON value. + * + * You should usually call [Builder.until] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun until(until: JsonField) = apply { this.until = until } + + fun start(start: String?) = start(JsonField.ofNullable(start)) + + /** Alias for calling [Builder.start] with `start.orElse(null)`. */ + fun start(start: Optional) = start(start.getOrNull()) + + /** + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun start(start: JsonField) = apply { this.start = start } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .until() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rule = + Rule(checkRequired("until", until), start, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Rule = apply { + if (validated) { + return@apply + } + + until() + start() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (until.asKnown().isPresent) 1 else 0) + (if (start.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rule && + until == other.until && + start == other.start && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(until, start, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rule{until=$until, start=$start, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt new file mode 100644 index 00000000..f64eafd3 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BrandColors +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val primary: JsonField, + private val secondary: JsonField, + private val tertiary: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("primary") @ExcludeMissing primary: JsonField = JsonMissing.of(), + @JsonProperty("secondary") @ExcludeMissing secondary: JsonField = JsonMissing.of(), + @JsonProperty("tertiary") @ExcludeMissing tertiary: JsonField = JsonMissing.of(), + ) : this(primary, secondary, tertiary, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun primary(): Optional = primary.getOptional("primary") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun secondary(): Optional = secondary.getOptional("secondary") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tertiary(): Optional = tertiary.getOptional("tertiary") + + /** + * Returns the raw JSON value of [primary]. + * + * Unlike [primary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("primary") @ExcludeMissing fun _primary(): JsonField = primary + + /** + * Returns the raw JSON value of [secondary]. + * + * Unlike [secondary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("secondary") @ExcludeMissing fun _secondary(): JsonField = secondary + + /** + * Returns the raw JSON value of [tertiary]. + * + * Unlike [tertiary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tertiary") @ExcludeMissing fun _tertiary(): JsonField = tertiary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BrandColors]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandColors]. */ + class Builder internal constructor() { + + private var primary: JsonField = JsonMissing.of() + private var secondary: JsonField = JsonMissing.of() + private var tertiary: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandColors: BrandColors) = apply { + primary = brandColors.primary + secondary = brandColors.secondary + tertiary = brandColors.tertiary + additionalProperties = brandColors.additionalProperties.toMutableMap() + } + + fun primary(primary: String?) = primary(JsonField.ofNullable(primary)) + + /** Alias for calling [Builder.primary] with `primary.orElse(null)`. */ + fun primary(primary: Optional) = primary(primary.getOrNull()) + + /** + * Sets [Builder.primary] to an arbitrary JSON value. + * + * You should usually call [Builder.primary] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun primary(primary: JsonField) = apply { this.primary = primary } + + fun secondary(secondary: String?) = secondary(JsonField.ofNullable(secondary)) + + /** Alias for calling [Builder.secondary] with `secondary.orElse(null)`. */ + fun secondary(secondary: Optional) = secondary(secondary.getOrNull()) + + /** + * Sets [Builder.secondary] to an arbitrary JSON value. + * + * You should usually call [Builder.secondary] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun secondary(secondary: JsonField) = apply { this.secondary = secondary } + + fun tertiary(tertiary: String?) = tertiary(JsonField.ofNullable(tertiary)) + + /** Alias for calling [Builder.tertiary] with `tertiary.orElse(null)`. */ + fun tertiary(tertiary: Optional) = tertiary(tertiary.getOrNull()) + + /** + * Sets [Builder.tertiary] to an arbitrary JSON value. + * + * You should usually call [Builder.tertiary] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tertiary(tertiary: JsonField) = apply { this.tertiary = tertiary } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandColors]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrandColors = + BrandColors(primary, secondary, tertiary, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): BrandColors = apply { + if (validated) { + return@apply + } + + primary() + secondary() + tertiary() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (primary.asKnown().isPresent) 1 else 0) + + (if (secondary.asKnown().isPresent) 1 else 0) + + (if (tertiary.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandColors && + primary == other.primary && + secondary == other.secondary && + tertiary == other.tertiary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(primary, secondary, tertiary, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandColors{primary=$primary, secondary=$secondary, tertiary=$tertiary, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt index 06adac2c..32fbe06d 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt @@ -6,7 +6,6 @@ import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired import com.courier.api.errors.CourierInvalidDataException import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -20,7 +19,7 @@ import kotlin.jvm.optionals.getOrNull class BrandSettings @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val colors: JsonField, + private val colors: JsonField, private val email: JsonField, private val inapp: JsonValue, private val additionalProperties: MutableMap, @@ -28,7 +27,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("colors") @ExcludeMissing colors: JsonField = JsonMissing.of(), + @JsonProperty("colors") @ExcludeMissing colors: JsonField = JsonMissing.of(), @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), @JsonProperty("inapp") @ExcludeMissing inapp: JsonValue = JsonMissing.of(), ) : this(colors, email, inapp, mutableMapOf()) @@ -37,7 +36,7 @@ private constructor( * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun colors(): Optional = colors.getOptional("colors") + fun colors(): Optional = colors.getOptional("colors") /** * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -52,7 +51,7 @@ private constructor( * * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField = colors + @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField = colors /** * Returns the raw JSON value of [email]. @@ -82,7 +81,7 @@ private constructor( /** A builder for [BrandSettings]. */ class Builder internal constructor() { - private var colors: JsonField = JsonMissing.of() + private var colors: JsonField = JsonMissing.of() private var email: JsonField = JsonMissing.of() private var inapp: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -95,18 +94,19 @@ private constructor( additionalProperties = brandSettings.additionalProperties.toMutableMap() } - fun colors(colors: Colors?) = colors(JsonField.ofNullable(colors)) + fun colors(colors: BrandColors?) = colors(JsonField.ofNullable(colors)) /** Alias for calling [Builder.colors] with `colors.orElse(null)`. */ - fun colors(colors: Optional) = colors(colors.getOrNull()) + fun colors(colors: Optional) = colors(colors.getOrNull()) /** * Sets [Builder.colors] to an arbitrary JSON value. * - * You should usually call [Builder.colors] with a well-typed [Colors] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.colors] with a well-typed [BrandColors] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun colors(colors: JsonField) = apply { this.colors = colors } + fun colors(colors: JsonField) = apply { this.colors = colors } fun email(email: Email?) = email(JsonField.ofNullable(email)) @@ -181,369 +181,6 @@ private constructor( (colors.asKnown().getOrNull()?.validity() ?: 0) + (email.asKnown().getOrNull()?.validity() ?: 0) - class Colors - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val primary: JsonField, - private val secondary: JsonField, - private val tertiary: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("primary") @ExcludeMissing primary: JsonField = JsonMissing.of(), - @JsonProperty("secondary") - @ExcludeMissing - secondary: JsonField = JsonMissing.of(), - @JsonProperty("tertiary") @ExcludeMissing tertiary: JsonField = JsonMissing.of(), - ) : this(primary, secondary, tertiary, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun primary(): Optional = primary.getOptional("primary") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun secondary(): Optional = secondary.getOptional("secondary") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tertiary(): Optional = tertiary.getOptional("tertiary") - - /** - * Returns the raw JSON value of [primary]. - * - * Unlike [primary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("primary") @ExcludeMissing fun _primary(): JsonField = primary - - /** - * Returns the raw JSON value of [secondary]. - * - * Unlike [secondary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("secondary") @ExcludeMissing fun _secondary(): JsonField = secondary - - /** - * Returns the raw JSON value of [tertiary]. - * - * Unlike [tertiary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tertiary") @ExcludeMissing fun _tertiary(): JsonField = tertiary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Colors]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Colors]. */ - class Builder internal constructor() { - - private var primary: JsonField = JsonMissing.of() - private var secondary: JsonField = JsonMissing.of() - private var tertiary: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(colors: Colors) = apply { - primary = colors.primary - secondary = colors.secondary - tertiary = colors.tertiary - additionalProperties = colors.additionalProperties.toMutableMap() - } - - fun primary(primary: String?) = primary(JsonField.ofNullable(primary)) - - /** Alias for calling [Builder.primary] with `primary.orElse(null)`. */ - fun primary(primary: Optional) = primary(primary.getOrNull()) - - /** - * Sets [Builder.primary] to an arbitrary JSON value. - * - * You should usually call [Builder.primary] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun primary(primary: JsonField) = apply { this.primary = primary } - - fun secondary(secondary: String?) = secondary(JsonField.ofNullable(secondary)) - - /** Alias for calling [Builder.secondary] with `secondary.orElse(null)`. */ - fun secondary(secondary: Optional) = secondary(secondary.getOrNull()) - - /** - * Sets [Builder.secondary] to an arbitrary JSON value. - * - * You should usually call [Builder.secondary] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun secondary(secondary: JsonField) = apply { this.secondary = secondary } - - fun tertiary(tertiary: String?) = tertiary(JsonField.ofNullable(tertiary)) - - /** Alias for calling [Builder.tertiary] with `tertiary.orElse(null)`. */ - fun tertiary(tertiary: Optional) = tertiary(tertiary.getOrNull()) - - /** - * Sets [Builder.tertiary] to an arbitrary JSON value. - * - * You should usually call [Builder.tertiary] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tertiary(tertiary: JsonField) = apply { this.tertiary = tertiary } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Colors]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Colors = - Colors(primary, secondary, tertiary, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Colors = apply { - if (validated) { - return@apply - } - - primary() - secondary() - tertiary() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (primary.asKnown().isPresent) 1 else 0) + - (if (secondary.asKnown().isPresent) 1 else 0) + - (if (tertiary.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Colors && - primary == other.primary && - secondary == other.secondary && - tertiary == other.tertiary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(primary, secondary, tertiary, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Colors{primary=$primary, secondary=$secondary, tertiary=$tertiary, additionalProperties=$additionalProperties}" - } - - class Email - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val footer: JsonValue, - private val header: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("footer") @ExcludeMissing footer: JsonValue = JsonMissing.of(), - @JsonProperty("header") @ExcludeMissing header: JsonValue = JsonMissing.of(), - ) : this(footer, header, mutableMapOf()) - - @JsonProperty("footer") @ExcludeMissing fun _footer(): JsonValue = footer - - @JsonProperty("header") @ExcludeMissing fun _header(): JsonValue = header - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Email]. - * - * The following fields are required: - * ```java - * .footer() - * .header() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Email]. */ - class Builder internal constructor() { - - private var footer: JsonValue? = null - private var header: JsonValue? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(email: Email) = apply { - footer = email.footer - header = email.header - additionalProperties = email.additionalProperties.toMutableMap() - } - - fun footer(footer: JsonValue) = apply { this.footer = footer } - - fun header(header: JsonValue) = apply { this.header = header } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Email]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .footer() - * .header() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Email = - Email( - checkRequired("footer", footer), - checkRequired("header", header), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Email = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = 0 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Email && - footer == other.footer && - header == other.header && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(footer, header, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Email{footer=$footer, header=$header, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt new file mode 100644 index 00000000..84b7564e --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt @@ -0,0 +1,359 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class BrandSnippet +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val format: JsonField, + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(format, name, value, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun format(): Format = format.getRequired("format") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [format]. + * + * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BrandSnippet]. + * + * The following fields are required: + * ```java + * .format() + * .name() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrandSnippet]. */ + class Builder internal constructor() { + + private var format: JsonField? = null + private var name: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brandSnippet: BrandSnippet) = apply { + format = brandSnippet.format + name = brandSnippet.name + value = brandSnippet.value + additionalProperties = brandSnippet.additionalProperties.toMutableMap() + } + + fun format(format: Format) = format(JsonField.of(format)) + + /** + * Sets [Builder.format] to an arbitrary JSON value. + * + * You should usually call [Builder.format] with a well-typed [Format] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun format(format: JsonField) = apply { this.format = format } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrandSnippet]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .format() + * .name() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrandSnippet = + BrandSnippet( + checkRequired("format", format), + checkRequired("name", name), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrandSnippet = apply { + if (validated) { + return@apply + } + + format().validate() + name() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (format.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + class Format @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val HANDLEBARS = of("handlebars") + + @JvmStatic fun of(value: String) = Format(JsonField.of(value)) + } + + /** An enum containing [Format]'s known values. */ + enum class Known { + HANDLEBARS + } + + /** + * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Format] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + HANDLEBARS, + /** An enum member indicating that [Format] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + HANDLEBARS -> Value.HANDLEBARS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + HANDLEBARS -> Known.HANDLEBARS + else -> throw CourierInvalidDataException("Unknown Format: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Format = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Format && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrandSnippet && + format == other.format && + name == other.name && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(format, name, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrandSnippet{format=$format, name=$name, value=$value, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt index 730c58c8..848944dc 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt @@ -2,7 +2,6 @@ package com.courier.api.models.brands -import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing @@ -22,27 +21,29 @@ import kotlin.jvm.optionals.getOrNull class BrandSnippets @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val items: JsonField>, + private val items: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() + @JsonProperty("items") + @ExcludeMissing + items: JsonField> = JsonMissing.of() ) : this(items, mutableMapOf()) /** * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun items(): List = items.getRequired("items") + fun items(): List = items.getRequired("items") /** * Returns the raw JSON value of [items]. * * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -72,7 +73,7 @@ private constructor( /** A builder for [BrandSnippets]. */ class Builder internal constructor() { - private var items: JsonField>? = null + private var items: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -81,25 +82,25 @@ private constructor( additionalProperties = brandSnippets.additionalProperties.toMutableMap() } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = items(JsonField.of(items)) /** * Sets [Builder.items] to an arbitrary JSON value. * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.items] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun items(items: JsonField>) = apply { + fun items(items: JsonField>) = apply { this.items = items.map { it.toMutableList() } } /** - * Adds a single [Item] to [items]. + * Adds a single [BrandSnippet] to [items]. * * @throws IllegalStateException if the field was previously set to a non-list. */ - fun addItem(item: Item) = apply { + fun addItem(item: BrandSnippet) = apply { items = (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } } @@ -170,357 +171,6 @@ private constructor( internal fun validity(): Int = (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val format: JsonField, - private val name: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(format, name, value, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun format(): Format = format.getRequired("format") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [format]. - * - * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Item]. - * - * The following fields are required: - * ```java - * .format() - * .name() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var format: JsonField? = null - private var name: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - format = item.format - name = item.name - value = item.value - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun format(format: Format) = format(JsonField.of(format)) - - /** - * Sets [Builder.format] to an arbitrary JSON value. - * - * You should usually call [Builder.format] with a well-typed [Format] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun format(format: JsonField) = apply { this.format = format } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .format() - * .name() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - checkRequired("format", format), - checkRequired("name", name), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - format().validate() - name() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (format.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - class Format @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val HANDLEBARS = of("handlebars") - - @JvmStatic fun of(value: String) = Format(JsonField.of(value)) - } - - /** An enum containing [Format]'s known values. */ - enum class Known { - HANDLEBARS - } - - /** - * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Format] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HANDLEBARS, - /** - * An enum member indicating that [Format] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HANDLEBARS -> Value.HANDLEBARS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - HANDLEBARS -> Known.HANDLEBARS - else -> throw CourierInvalidDataException("Unknown Format: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Format = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Format && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - format == other.format && - name == other.name && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(format, name, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{format=$format, name=$name, value=$value, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt new file mode 100644 index 00000000..50153ae2 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkRequired +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +class Email +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val footer: JsonValue, + private val header: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("footer") @ExcludeMissing footer: JsonValue = JsonMissing.of(), + @JsonProperty("header") @ExcludeMissing header: JsonValue = JsonMissing.of(), + ) : this(footer, header, mutableMapOf()) + + @JsonProperty("footer") @ExcludeMissing fun _footer(): JsonValue = footer + + @JsonProperty("header") @ExcludeMissing fun _header(): JsonValue = header + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Email]. + * + * The following fields are required: + * ```java + * .footer() + * .header() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Email]. */ + class Builder internal constructor() { + + private var footer: JsonValue? = null + private var header: JsonValue? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(email: Email) = apply { + footer = email.footer + header = email.header + additionalProperties = email.additionalProperties.toMutableMap() + } + + fun footer(footer: JsonValue) = apply { this.footer = footer } + + fun header(header: JsonValue) = apply { this.header = header } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Email]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .footer() + * .header() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Email = + Email( + checkRequired("footer", footer), + checkRequired("header", header), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Email = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Email && + footer == other.footer && + header == other.header && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(footer, header, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Email{footer=$footer, header=$header, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt index 966be3c5..67d16aa5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt @@ -16,6 +16,7 @@ import com.courier.api.errors.CourierInvalidDataException import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content import com.courier.api.models.send.MessageContext +import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -2109,8 +2110,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: Content.ElementalContent) = - content(Content.ofElemental(elemental)) + fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) /** * Alias for calling [content] with diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt new file mode 100644 index 00000000..1117de10 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.ChannelPreference +import com.courier.api.models.Rule +import com.courier.api.models.users.preferences.PreferenceStatus +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotificationPreferenceDetails +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val channelPreferences: JsonField>, + private val rules: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("channel_preferences") + @ExcludeMissing + channelPreferences: JsonField> = JsonMissing.of(), + @JsonProperty("rules") @ExcludeMissing rules: JsonField> = JsonMissing.of(), + ) : this(status, channelPreferences, rules, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): PreferenceStatus = status.getRequired("status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channelPreferences(): Optional> = + channelPreferences.getOptional("channel_preferences") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rules(): Optional> = rules.getOptional("rules") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [channelPreferences]. + * + * Unlike [channelPreferences], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel_preferences") + @ExcludeMissing + fun _channelPreferences(): JsonField> = channelPreferences + + /** + * Returns the raw JSON value of [rules]. + * + * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [NotificationPreferenceDetails]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotificationPreferenceDetails]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var channelPreferences: JsonField>? = null + private var rules: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(notificationPreferenceDetails: NotificationPreferenceDetails) = apply { + status = notificationPreferenceDetails.status + channelPreferences = + notificationPreferenceDetails.channelPreferences.map { it.toMutableList() } + rules = notificationPreferenceDetails.rules.map { it.toMutableList() } + additionalProperties = notificationPreferenceDetails.additionalProperties.toMutableMap() + } + + fun status(status: PreferenceStatus) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun channelPreferences(channelPreferences: List?) = + channelPreferences(JsonField.ofNullable(channelPreferences)) + + /** + * Alias for calling [Builder.channelPreferences] with `channelPreferences.orElse(null)`. + */ + fun channelPreferences(channelPreferences: Optional>) = + channelPreferences(channelPreferences.getOrNull()) + + /** + * Sets [Builder.channelPreferences] to an arbitrary JSON value. + * + * You should usually call [Builder.channelPreferences] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun channelPreferences(channelPreferences: JsonField>) = apply { + this.channelPreferences = channelPreferences.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelPreference] to [channelPreferences]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannelPreference(channelPreference: ChannelPreference) = apply { + channelPreferences = + (channelPreferences ?: JsonField.of(mutableListOf())).also { + checkKnown("channelPreferences", it).add(channelPreference) + } + } + + fun rules(rules: List?) = rules(JsonField.ofNullable(rules)) + + /** Alias for calling [Builder.rules] with `rules.orElse(null)`. */ + fun rules(rules: Optional>) = rules(rules.getOrNull()) + + /** + * Sets [Builder.rules] to an arbitrary JSON value. + * + * You should usually call [Builder.rules] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rules(rules: JsonField>) = apply { + this.rules = rules.map { it.toMutableList() } + } + + /** + * Adds a single [Rule] to [rules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRule(rule: Rule) = apply { + rules = + (rules ?: JsonField.of(mutableListOf())).also { checkKnown("rules", it).add(rule) } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [NotificationPreferenceDetails]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): NotificationPreferenceDetails = + NotificationPreferenceDetails( + checkRequired("status", status), + (channelPreferences ?: JsonMissing.of()).map { it.toImmutable() }, + (rules ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): NotificationPreferenceDetails = apply { + if (validated) { + return@apply + } + + status().validate() + channelPreferences().ifPresent { it.forEach { it.validate() } } + rules().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (channelPreferences.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is NotificationPreferenceDetails && + status == other.status && + channelPreferences == other.channelPreferences && + rules == other.rules && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(status, channelPreferences, rules, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NotificationPreferenceDetails{status=$status, channelPreferences=$channelPreferences, rules=$rules, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt index e4ef9a8f..68e71844 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt @@ -1657,311 +1657,6 @@ private constructor( (if (traceId.asKnown().isPresent) 1 else 0) + (utm.asKnown().getOrNull()?.validity() ?: 0) - /** - * Identify the campaign that refers traffic to a specific website, and attributes the - * browser's website session. - */ - class Utm - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val campaign: JsonField, - private val content: JsonField, - private val medium: JsonField, - private val source: JsonField, - private val term: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("campaign") - @ExcludeMissing - campaign: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - content: JsonField = JsonMissing.of(), - @JsonProperty("medium") - @ExcludeMissing - medium: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - source: JsonField = JsonMissing.of(), - @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), - ) : this(campaign, content, medium, source, term, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun campaign(): Optional = campaign.getOptional("campaign") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun medium(): Optional = medium.getOptional("medium") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun term(): Optional = term.getOptional("term") - - /** - * Returns the raw JSON value of [campaign]. - * - * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [medium]. - * - * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - /** - * Returns the raw JSON value of [term]. - * - * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Utm]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Utm]. */ - class Builder internal constructor() { - - private var campaign: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var medium: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var term: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(utm: Utm) = apply { - campaign = utm.campaign - content = utm.content - medium = utm.medium - source = utm.source - term = utm.term - additionalProperties = utm.additionalProperties.toMutableMap() - } - - fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) - - /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ - fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) - - /** - * Sets [Builder.campaign] to an arbitrary JSON value. - * - * You should usually call [Builder.campaign] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun campaign(campaign: JsonField) = apply { this.campaign = campaign } - - fun content(content: String?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) - - /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ - fun medium(medium: Optional) = medium(medium.getOrNull()) - - /** - * Sets [Builder.medium] to an arbitrary JSON value. - * - * You should usually call [Builder.medium] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun medium(medium: JsonField) = apply { this.medium = medium } - - fun source(source: String?) = source(JsonField.ofNullable(source)) - - /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun term(term: String?) = term(JsonField.ofNullable(term)) - - /** Alias for calling [Builder.term] with `term.orElse(null)`. */ - fun term(term: Optional) = term(term.getOrNull()) - - /** - * Sets [Builder.term] to an arbitrary JSON value. - * - * You should usually call [Builder.term] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun term(term: JsonField) = apply { this.term = term } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Utm]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Utm = - Utm( - campaign, - content, - medium, - source, - term, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Utm = apply { - if (validated) { - return@apply - } - - campaign() - content() - medium() - source() - term() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (campaign.asKnown().isPresent) 1 else 0) + - (if (content.asKnown().isPresent) 1 else 0) + - (if (medium.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (term.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Utm && - campaign == other.campaign && - content == other.content && - medium == other.medium && - source == other.source && - term == other.term && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(campaign, content, medium, source, term, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt index e3d6bdfa..03d4d2e2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt @@ -4,17 +4,15 @@ package com.courier.api.models.send import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing import com.courier.api.core.JsonValue import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -29,7 +27,6 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional -import kotlin.jvm.optionals.getOrNull /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ @JsonDeserialize(using = Content.Deserializer::class) @@ -215,3823 +212,6 @@ private constructor( } } - class ElementalContent - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val elements: JsonField>, - private val version: JsonField, - private val brand: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), - ) : this(elements, version, brand, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * For example, "2022-01-01" - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalContent]. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalContent]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var version: JsonField? = null - private var brand: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalContent: ElementalContent) = apply { - elements = elementalContent.elements.map { it.toMutableList() } - version = elementalContent.version - brand = elementalContent.brand - additionalProperties = elementalContent.additionalProperties.toMutableMap() - } - - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [Element] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: Element) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `Element.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: Element.UnionMember0) = - addElement(Element.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `Element.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: Element.UnionMember1) = - addElement(Element.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `Element.ofType(type)`. */ - fun addElement(type: Element.Type) = addElement(Element.ofType(type)) - - /** Alias for calling [addElement] with `Element.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: Element.UnionMember3) = - addElement(Element.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `Element.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: Element.UnionMember4) = - addElement(Element.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `Element.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: Element.UnionMember5) = - addElement(Element.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `Element.ofType(type)`. */ - fun addElement(type: Element.Type) = addElement(Element.ofType(type)) - - /** Alias for calling [addElement] with `Element.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: Element.UnionMember7) = - addElement(Element.ofUnionMember7(unionMember7)) - - /** For example, "2022-01-01" */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - fun brand(brand: JsonValue) = apply { this.brand = brand } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalContent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalContent = - ElementalContent( - checkRequired("elements", elements).map { it.toImmutable() }, - checkRequired("version", version), - brand, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalContent = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - version() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - @JsonDeserialize(using = Element.Deserializer::class) - @JsonSerialize(using = Element.Serializer::class) - class Element - private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val type: Type? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val type: Type? = null, - private val unionMember7: UnionMember7? = null, - private val _json: JsonValue? = null, - ) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun type(): Optional = Optional.ofNullable(type) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - fun type(): Optional = Optional.ofNullable(type) - - fun unionMember7(): Optional = Optional.ofNullable(unionMember7) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isType(): Boolean = type != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun isUnionMember5(): Boolean = unionMember5 != null - - fun isType(): Boolean = type != null - - fun isUnionMember7(): Boolean = unionMember7 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asType(): Type = type.getOrThrow("type") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") - - fun asType(): Type = type.getOrThrow("type") - - fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - type != null -> visitor.visitType(type) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - type != null -> visitor.visitType(type) - unionMember7 != null -> visitor.visitUnionMember7(unionMember7) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Element = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } - - override fun visitType(type: Type) { - type.validate() - } - - override fun visitUnionMember3(unionMember3: UnionMember3) { - unionMember3.validate() - } - - override fun visitUnionMember4(unionMember4: UnionMember4) { - unionMember4.validate() - } - - override fun visitUnionMember5(unionMember5: UnionMember5) { - unionMember5.validate() - } - - override fun visitType(type: Type) { - type.validate() - } - - override fun visitUnionMember7(unionMember7: UnionMember7) { - unionMember7.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = - unionMember0.validity() - - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() - - override fun visitType(type: Type) = type.validity() - - override fun visitUnionMember3(unionMember3: UnionMember3) = - unionMember3.validity() - - override fun visitUnionMember4(unionMember4: UnionMember4) = - unionMember4.validity() - - override fun visitUnionMember5(unionMember5: UnionMember5) = - unionMember5.validity() - - override fun visitType(type: Type) = type.validity() - - override fun visitUnionMember7(unionMember7: UnionMember7) = - unionMember7.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Element && - unionMember0 == other.unionMember0 && - unionMember1 == other.unionMember1 && - type == other.type && - unionMember3 == other.unionMember3 && - unionMember4 == other.unionMember4 && - unionMember5 == other.unionMember5 && - type == other.type && - unionMember7 == other.unionMember7 - } - - override fun hashCode(): Int = - Objects.hash( - unionMember0, - unionMember1, - type, - unionMember3, - unionMember4, - unionMember5, - type, - unionMember7, - ) - - override fun toString(): String = - when { - unionMember0 != null -> "Element{unionMember0=$unionMember0}" - unionMember1 != null -> "Element{unionMember1=$unionMember1}" - type != null -> "Element{type=$type}" - unionMember3 != null -> "Element{unionMember3=$unionMember3}" - unionMember4 != null -> "Element{unionMember4=$unionMember4}" - unionMember5 != null -> "Element{unionMember5=$unionMember5}" - type != null -> "Element{type=$type}" - unionMember7 != null -> "Element{unionMember7=$unionMember7}" - _json != null -> "Element{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Element") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - Element(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = - Element(unionMember1 = unionMember1) - - @JvmStatic fun ofType(type: Type) = Element(type = type) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = - Element(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = - Element(unionMember4 = unionMember4) - - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = - Element(unionMember5 = unionMember5) - - @JvmStatic fun ofType(type: Type) = Element(type = type) - - @JvmStatic - fun ofUnionMember7(unionMember7: UnionMember7) = - Element(unionMember7 = unionMember7) - } - - /** - * An interface that defines how to map each variant of [Element] to a value of type - * [T]. - */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitType(type: Type): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun visitUnionMember5(unionMember5: UnionMember5): T - - fun visitType(type: Type): T - - fun visitUnionMember7(unionMember7: UnionMember7): T - - /** - * Maps an unknown variant of [Element] to a value of type [T]. - * - * An instance of [Element] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Element: $json") - } - } - - internal class Deserializer : BaseDeserializer(Element::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Element { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(type = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember4 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember5 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(type = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Element(unionMember7 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Element(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Element::class) { - - override fun serialize( - value: Element, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.type != null -> generator.writeObject(value.type) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value.type != null -> generator.writeObject(value.type) - value.unionMember7 != null -> generator.writeObject(value.unionMember7) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Element") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - channels = unionMember0.channels.map { it.toMutableList() } - if_ = unionMember0.if_ - loop = unionMember0.loop - ref = unionMember0.ref - type = unionMember0.type - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember0 = - UnionMember0( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val TEXT = of("text") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TEXT - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TEXT, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - channels = unionMember1.channels.map { it.toMutableList() } - if_ = unionMember1.if_ - loop = unionMember1.loop - ref = unionMember1.ref - type = unionMember1.type - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val META = of("meta") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - META - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - META, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - META -> Value.META - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - META -> Known.META - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class Type - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of() - ) : this(type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun type(): InnerType = type.getRequired("type") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Type]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Type]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties = type.additionalProperties.toMutableMap() - } - - fun type(type: InnerType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [InnerType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Type]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Type = - Type(checkRequired("type", type), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - type().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) - - class InnerType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CHANNEL = of("channel") - - @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) - } - - /** An enum containing [InnerType]'s known values. */ - enum class Known { - CHANNEL - } - - /** - * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [InnerType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHANNEL, - /** - * An enum member indicating that [InnerType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHANNEL -> Value.CHANNEL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CHANNEL -> Known.CHANNEL - else -> throw CourierInvalidDataException("Unknown InnerType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): InnerType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InnerType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember3 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember3]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - channels = unionMember3.channels.map { it.toMutableList() } - if_ = unionMember3.if_ - loop = unionMember3.loop - ref = unionMember3.ref - type = unionMember3.type - additionalProperties = unionMember3.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember3]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember3 = - UnionMember3( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember3 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val IMAGE = of("image") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMAGE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IMAGE, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IMAGE -> Value.IMAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - IMAGE -> Known.IMAGE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember4 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember4]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - channels = unionMember4.channels.map { it.toMutableList() } - if_ = unionMember4.if_ - loop = unionMember4.loop - ref = unionMember4.ref - type = unionMember4.type - additionalProperties = unionMember4.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember4]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember4 = - UnionMember4( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember4 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ACTION = of("action") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ACTION - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTION, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTION -> Value.ACTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ACTION -> Known.ACTION - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember5 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember5]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - channels = unionMember5.channels.map { it.toMutableList() } - if_ = unionMember5.if_ - loop = unionMember5.loop - ref = unionMember5.ref - type = unionMember5.type - additionalProperties = unionMember5.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember5]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember5 = - UnionMember5( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember5 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DIVIDER = of("divider") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - DIVIDER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDER, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDER -> Value.DIVIDER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DIVIDER -> Known.DIVIDER - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember5 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class Type - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of() - ) : this(type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun type(): InnerType = type.getRequired("type") - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Type]. - * - * The following fields are required: - * ```java - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Type]. */ - class Builder internal constructor() { - - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(type: Type) = apply { - this.type = type.type - additionalProperties = type.additionalProperties.toMutableMap() - } - - fun type(type: InnerType) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [InnerType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Type]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Type = - Type(checkRequired("type", type), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - type().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (type.asKnown().getOrNull()?.validity() ?: 0) - - class InnerType - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GROUP = of("group") - - @JvmStatic fun of(value: String) = InnerType(JsonField.of(value)) - } - - /** An enum containing [InnerType]'s known values. */ - enum class Known { - GROUP - } - - /** - * An enum containing [InnerType]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [InnerType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUP, - /** - * An enum member indicating that [InnerType] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUP -> Value.GROUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - GROUP -> Known.GROUP - else -> throw CourierInvalidDataException("Unknown InnerType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): InnerType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InnerType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Type{type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember7 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") - @ExcludeMissing - loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember7]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember7: UnionMember7) = apply { - channels = unionMember7.channels.map { it.toMutableList() } - if_ = unionMember7.if_ - loop = unionMember7.loop - ref = unionMember7.ref - type = unionMember7.type - additionalProperties = unionMember7.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember7]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember7 = - UnionMember7( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember7 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val QUOTE = of("quote") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - QUOTE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - QUOTE, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - QUOTE -> Value.QUOTE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - QUOTE -> Known.QUOTE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember7 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalContent && - elements == other.elements && - version == other.version && - brand == other.brand && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, version, brand, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" - } - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ class ElementalContentSugar @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt index d9a75557..50851d78 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt @@ -13,6 +13,7 @@ import com.courier.api.core.checkRequired import com.courier.api.core.getOrThrow import com.courier.api.errors.CourierInvalidDataException import com.courier.api.models.bulk.UserRecipient +import com.courier.api.models.tenants.templates.ElementalContent import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -897,8 +898,7 @@ private constructor( fun content(content: JsonField) = apply { this.content = content } /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: Content.ElementalContent) = - content(Content.ofElemental(elemental)) + fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) /** * Alias for calling [content] with diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt new file mode 100644 index 00000000..8504b223 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Utm +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val campaign: JsonField, + private val content: JsonField, + private val medium: JsonField, + private val source: JsonField, + private val term: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("campaign") @ExcludeMissing campaign: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("medium") @ExcludeMissing medium: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), + ) : this(campaign, content, medium, source, term, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun campaign(): Optional = campaign.getOptional("campaign") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun medium(): Optional = medium.getOptional("medium") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun term(): Optional = term.getOptional("term") + + /** + * Returns the raw JSON value of [campaign]. + * + * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [medium]. + * + * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [term]. + * + * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Utm]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Utm]. */ + class Builder internal constructor() { + + private var campaign: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var medium: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var term: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(utm: Utm) = apply { + campaign = utm.campaign + content = utm.content + medium = utm.medium + source = utm.source + term = utm.term + additionalProperties = utm.additionalProperties.toMutableMap() + } + + fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) + + /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ + fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) + + /** + * Sets [Builder.campaign] to an arbitrary JSON value. + * + * You should usually call [Builder.campaign] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun campaign(campaign: JsonField) = apply { this.campaign = campaign } + + fun content(content: String?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) + + /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ + fun medium(medium: Optional) = medium(medium.getOrNull()) + + /** + * Sets [Builder.medium] to an arbitrary JSON value. + * + * You should usually call [Builder.medium] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun medium(medium: JsonField) = apply { this.medium = medium } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun term(term: String?) = term(JsonField.ofNullable(term)) + + /** Alias for calling [Builder.term] with `term.orElse(null)`. */ + fun term(term: Optional) = term(term.getOrNull()) + + /** + * Sets [Builder.term] to an arbitrary JSON value. + * + * You should usually call [Builder.term] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun term(term: JsonField) = apply { this.term = term } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Utm]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Utm = + Utm(campaign, content, medium, source, term, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Utm = apply { + if (validated) { + return@apply + } + + campaign() + content() + medium() + source() + term() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (campaign.asKnown().isPresent) 1 else 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (if (medium.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (term.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Utm && + campaign == other.campaign && + content == other.content && + medium == other.medium && + source == other.source && + term == other.term && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(campaign, content, medium, source, term, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt similarity index 90% rename from courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponse.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt index 83f870a5..e5b4b448 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt @@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects -class TemplateRetrieveResponse +class BaseTemplateTenantAssociation @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, @@ -129,7 +129,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [TemplateRetrieveResponse]. + * Returns a mutable builder for constructing an instance of + * [BaseTemplateTenantAssociation]. * * The following fields are required: * ```java @@ -143,7 +144,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [TemplateRetrieveResponse]. */ + /** A builder for [BaseTemplateTenantAssociation]. */ class Builder internal constructor() { private var id: JsonField? = null @@ -154,13 +155,13 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(templateRetrieveResponse: TemplateRetrieveResponse) = apply { - id = templateRetrieveResponse.id - createdAt = templateRetrieveResponse.createdAt - publishedAt = templateRetrieveResponse.publishedAt - updatedAt = templateRetrieveResponse.updatedAt - version = templateRetrieveResponse.version - additionalProperties = templateRetrieveResponse.additionalProperties.toMutableMap() + internal fun from(baseTemplateTenantAssociation: BaseTemplateTenantAssociation) = apply { + id = baseTemplateTenantAssociation.id + createdAt = baseTemplateTenantAssociation.createdAt + publishedAt = baseTemplateTenantAssociation.publishedAt + updatedAt = baseTemplateTenantAssociation.updatedAt + version = baseTemplateTenantAssociation.version + additionalProperties = baseTemplateTenantAssociation.additionalProperties.toMutableMap() } /** The template's id */ @@ -241,7 +242,7 @@ private constructor( } /** - * Returns an immutable instance of [TemplateRetrieveResponse]. + * Returns an immutable instance of [BaseTemplateTenantAssociation]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -256,8 +257,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): TemplateRetrieveResponse = - TemplateRetrieveResponse( + fun build(): BaseTemplateTenantAssociation = + BaseTemplateTenantAssociation( checkRequired("id", id), checkRequired("createdAt", createdAt), checkRequired("publishedAt", publishedAt), @@ -269,7 +270,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TemplateRetrieveResponse = apply { + fun validate(): BaseTemplateTenantAssociation = apply { if (validated) { return@apply } @@ -308,7 +309,7 @@ private constructor( return true } - return other is TemplateRetrieveResponse && + return other is BaseTemplateTenantAssociation && id == other.id && createdAt == other.createdAt && publishedAt == other.publishedAt && @@ -324,5 +325,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "TemplateRetrieveResponse{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" + "BaseTemplateTenantAssociation{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt new file mode 100644 index 00000000..0700d91f --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt @@ -0,0 +1,572 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ElementalChannelNode +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val channel: JsonField, + private val channels: JsonField>, + private val elements: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val raw: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(channel, channels, elements, if_, loop, raw, ref, mutableMapOf()) + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` is + * `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elements(): Optional> = elements.getOptional("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalChannelNode]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalChannelNode]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channels: JsonField>? = null + private var elements: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalChannelNode: ElementalChannelNode) = apply { + channel = elementalChannelNode.channel + channels = elementalChannelNode.channels.map { it.toMutableList() } + elements = elementalChannelNode.elements.map { it.toMutableList() } + if_ = elementalChannelNode.if_ + loop = elementalChannelNode.loop + raw = elementalChannelNode.raw + ref = elementalChannelNode.ref + additionalProperties = elementalChannelNode.additionalProperties.toMutableMap() + } + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` + * is `required`. + */ + fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) + + /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ + fun elements(elements: Optional>) = elements(elements.getOrNull()) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + */ + fun raw(raw: Raw?) = raw(JsonField.ofNullable(raw)) + + /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ + fun raw(raw: Optional) = raw(raw.getOrNull()) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [Raw] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalChannelNode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalChannelNode = + ElementalChannelNode( + checkRequired("channel", channel), + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + (elements ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + raw, + ref, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalChannelNode = apply { + if (validated) { + return@apply + } + + channel() + channels() + elements().ifPresent { it.forEach { it.validate() } } + if_() + loop() + raw().ifPresent { it.validate() } + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (raw.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. + */ + class Raw + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Raw]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Raw]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(raw: Raw) = apply { + additionalProperties = raw.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Raw]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Raw = Raw(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Raw = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Raw && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Raw{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalChannelNode && + channel == other.channel && + channels == other.channels && + elements == other.elements && + if_ == other.if_ && + loop == other.loop && + raw == other.raw && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, channels, elements, if_, loop, raw, ref, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalChannelNode{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt new file mode 100644 index 00000000..536579a9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ElementalContent +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val elements: JsonField>, + private val version: JsonField, + private val brand: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), + @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), + ) : this(elements, version, brand, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * For example, "2022-01-01" + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun version(): String = version.getRequired("version") + + @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [version]. + * + * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalContent]. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalContent]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var version: JsonField? = null + private var brand: JsonValue = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalContent: ElementalContent) = apply { + elements = elementalContent.elements.map { it.toMutableList() } + version = elementalContent.version + brand = elementalContent.brand + additionalProperties = elementalContent.additionalProperties.toMutableMap() + } + + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + /** For example, "2022-01-01" */ + fun version(version: String) = version(JsonField.of(version)) + + /** + * Sets [Builder.version] to an arbitrary JSON value. + * + * You should usually call [Builder.version] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun version(version: JsonField) = apply { this.version = version } + + fun brand(brand: JsonValue) = apply { this.brand = brand } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalContent]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * .version() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalContent = + ElementalContent( + checkRequired("elements", elements).map { it.toImmutable() }, + checkRequired("version", version), + brand, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalContent = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + version() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (version.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalContent && + elements == other.elements && + version == other.version && + brand == other.brand && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, version, brand, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt new file mode 100644 index 00000000..ca5b8af9 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ElementalGroupNode +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val elements: JsonField>, + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + ) : this(elements, channels, if_, loop, ref, mutableMapOf()) + + /** + * Sub elements to render. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ElementalGroupNode]. + * + * The following fields are required: + * ```java + * .elements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ElementalGroupNode]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(elementalGroupNode: ElementalGroupNode) = apply { + elements = elementalGroupNode.elements.map { it.toMutableList() } + channels = elementalGroupNode.channels.map { it.toMutableList() } + if_ = elementalGroupNode.if_ + loop = elementalGroupNode.loop + ref = elementalGroupNode.ref + additionalProperties = elementalGroupNode.additionalProperties.toMutableMap() + } + + /** Sub elements to render. */ + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: ElementalNode.UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: ElementalNode.UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: ElementalNode.UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: ElementalNode.UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: ElementalNode.UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: ElementalNode.UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: ElementalNode.UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: ElementalNode.UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ElementalGroupNode]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ElementalGroupNode = + ElementalGroupNode( + checkRequired("elements", elements).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ElementalGroupNode = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + channels() + if_() + loop() + ref() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalGroupNode && + elements == other.elements && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, channels, if_, loop, ref, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ElementalGroupNode{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt new file mode 100644 index 00000000..0f1d982c --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt @@ -0,0 +1,4182 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is sent + * through email, and a more concise message in a push notification. Channel elements are only valid + * as top-level elements; you cannot nest channel elements. If there is a channel element specified + * at the top-level of the document, all sibling elements must be channel elements. Note: As an + * alternative, most elements support a `channel` property. Which allows you to selectively display + * an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for + * more details. + */ +@JsonDeserialize(using = ElementalNode.Deserializer::class) +@JsonSerialize(using = ElementalNode.Serializer::class) +class ElementalNode +private constructor( + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val unionMember3: UnionMember3? = null, + private val unionMember4: UnionMember4? = null, + private val unionMember5: UnionMember5? = null, + private val unionMember6: UnionMember6? = null, + private val unionMember7: UnionMember7? = null, + private val _json: JsonValue? = null, +) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun unionMember4(): Optional = Optional.ofNullable(unionMember4) + + fun unionMember5(): Optional = Optional.ofNullable(unionMember5) + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun unionMember6(): Optional = Optional.ofNullable(unionMember6) + + fun unionMember7(): Optional = Optional.ofNullable(unionMember7) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUnionMember3(): Boolean = unionMember3 != null + + fun isUnionMember4(): Boolean = unionMember4 != null + + fun isUnionMember5(): Boolean = unionMember5 != null + + fun isUnionMember6(): Boolean = unionMember6 != null + + fun isUnionMember7(): Boolean = unionMember7 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") + + fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") + + fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) + unionMember4 != null -> visitor.visitUnionMember4(unionMember4) + unionMember5 != null -> visitor.visitUnionMember5(unionMember5) + unionMember6 != null -> visitor.visitUnionMember6(unionMember6) + unionMember7 != null -> visitor.visitUnionMember7(unionMember7) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ElementalNode = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } + + override fun visitUnionMember4(unionMember4: UnionMember4) { + unionMember4.validate() + } + + override fun visitUnionMember5(unionMember5: UnionMember5) { + unionMember5.validate() + } + + override fun visitUnionMember6(unionMember6: UnionMember6) { + unionMember6.validate() + } + + override fun visitUnionMember7(unionMember7: UnionMember7) { + unionMember7.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + + override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() + + override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() + + override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() + + override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() + + override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalNode && + unionMember0 == other.unionMember0 && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + unionMember3 == other.unionMember3 && + unionMember4 == other.unionMember4 && + unionMember5 == other.unionMember5 && + unionMember6 == other.unionMember6 && + unionMember7 == other.unionMember7 + } + + override fun hashCode(): Int = + Objects.hash( + unionMember0, + unionMember1, + unionMember2, + unionMember3, + unionMember4, + unionMember5, + unionMember6, + unionMember7, + ) + + override fun toString(): String = + when { + unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" + unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" + unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" + unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" + unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" + unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" + unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" + unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" + _json != null -> "ElementalNode{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ElementalNode") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) + + /** + * The channel element allows a notification to be customized based on which channel it is + * sent through. For example, you may want to display a detailed message when the + * notification is sent through email, and a more concise message in a push notification. + * Channel elements are only valid as top-level elements; you cannot nest channel elements. + * If there is a channel element specified at the top-level of the document, all sibling + * elements must be channel elements. Note: As an alternative, most elements support a + * `channel` property. Which allows you to selectively display an individual element on a + * per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) + + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) + + @JvmStatic + fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) + + @JvmStatic + fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) + + /** + * Allows you to group elements together. This can be useful when used in combination with + * "if" or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + @JvmStatic + fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) + + @JvmStatic + fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) + } + + /** + * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + /** + * The channel element allows a notification to be customized based on which channel it is + * sent through. For example, you may want to display a detailed message when the + * notification is sent through email, and a more concise message in a push notification. + * Channel elements are only valid as top-level elements; you cannot nest channel elements. + * If there is a channel element specified at the top-level of the document, all sibling + * elements must be channel elements. Note: As an alternative, most elements support a + * `channel` property. Which allows you to selectively display an individual element on a + * per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUnionMember3(unionMember3: UnionMember3): T + + fun visitUnionMember4(unionMember4: UnionMember4): T + + fun visitUnionMember5(unionMember5: UnionMember5): T + + /** + * Allows you to group elements together. This can be useful when used in combination with + * "if" or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + fun visitUnionMember6(unionMember6: UnionMember6): T + + fun visitUnionMember7(unionMember7: UnionMember7): T + + /** + * Maps an unknown variant of [ElementalNode] to a value of type [T]. + * + * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ElementalNode: $json") + } + } + + internal class Deserializer : BaseDeserializer(ElementalNode::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember4 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember5 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember6 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember7 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ElementalNode(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ElementalNode::class) { + + override fun serialize( + value: ElementalNode, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) + value.unionMember4 != null -> generator.writeObject(value.unionMember4) + value.unionMember5 != null -> generator.writeObject(value.unionMember5) + value.unionMember6 != null -> generator.writeObject(value.unionMember6) + value.unionMember7 != null -> generator.writeObject(value.unionMember7) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ElementalNode") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + channels = unionMember0.channels.map { it.toMutableList() } + if_ = unionMember0.if_ + loop = unionMember0.loop + ref = unionMember0.ref + type = unionMember0.type + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + channels = unionMember1.channels.map { it.toMutableList() } + if_ = unionMember1.if_ + loop = unionMember1.loop + ref = unionMember1.ref + type = unionMember1.type + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val META = of("meta") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + META + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + META, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + META -> Value.META + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + META -> Known.META + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * The channel element allows a notification to be customized based on which channel it is sent + * through. For example, you may want to display a detailed message when the notification is + * sent through email, and a more concise message in a push notification. Channel elements are + * only valid as top-level elements; you cannot nest channel elements. If there is a channel + * element specified at the top-level of the document, all sibling elements must be channel + * elements. Note: As an alternative, most elements support a `channel` property. Which allows + * you to selectively display an individual element on a per channel basis. See the + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val channels: JsonField>, + private val elements: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val raw: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("raw") + @ExcludeMissing + raw: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channel, channels, elements, if_, loop, raw, ref, type, mutableMapOf()) + + fun toElementalChannelNode(): ElementalChannelNode = + ElementalChannelNode.builder() + .channel(channel) + .channels(channels) + .elements(elements) + .if_(if_) + .loop(loop) + .raw(raw) + .ref(ref) + .build() + + /** + * The channel the contents of this element should be applied to. Can be `email`, `push`, + * `direct_message`, `sms` or a provider such as slack + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): String = channel.getRequired("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, `elements` + * is `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun elements(): Optional> = elements.getOptional("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun raw(): Optional = raw.getOptional("raw") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [raw]. + * + * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember2]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var channels: JsonField>? = null + private var elements: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var raw: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + channel = unionMember2.channel + channels = unionMember2.channels.map { it.toMutableList() } + elements = unionMember2.elements.map { it.toMutableList() } + if_ = unionMember2.if_ + loop = unionMember2.loop + raw = unionMember2.raw + ref = unionMember2.ref + type = unionMember2.type + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + /** + * The channel the contents of this element should be applied to. Can be `email`, + * `push`, `direct_message`, `sms` or a provider such as slack + */ + fun channel(channel: String) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** + * An array of elements to apply to the channel. If `raw` has not been specified, + * `elements` is `required`. + */ + fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) + + /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ + fun elements(elements: Optional>) = elements(elements.getOrNull()) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + /** + * Raw data to apply to the channel. If `elements` has not been specified, `raw` is + * `required`. + */ + fun raw(raw: ElementalChannelNode.Raw?) = raw(JsonField.ofNullable(raw)) + + /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ + fun raw(raw: Optional) = raw(raw.getOrNull()) + + /** + * Sets [Builder.raw] to an arbitrary JSON value. + * + * You should usually call [Builder.raw] with a well-typed [ElementalChannelNode.Raw] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun raw(raw: JsonField) = apply { this.raw = raw } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember2 = + UnionMember2( + checkRequired("channel", channel), + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + (elements ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + raw, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + channel() + channels() + elements().ifPresent { it.forEach { it.validate() } } + if_() + loop() + raw().ifPresent { it.validate() } + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (channel.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (raw.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHANNEL = of("channel") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CHANNEL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHANNEL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHANNEL -> Value.CHANNEL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHANNEL -> Known.CHANNEL + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + channel == other.channel && + channels == other.channels && + elements == other.elements && + if_ == other.if_ && + loop == other.loop && + raw == other.raw && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + channel, + channels, + elements, + if_, + loop, + raw, + ref, + type, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + channels = unionMember3.channels.map { it.toMutableList() } + if_ = unionMember3.if_ + loop = unionMember3.loop + ref = unionMember3.ref + type = unionMember3.type + additionalProperties = unionMember3.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = + UnionMember3( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IMAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IMAGE -> Value.IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IMAGE -> Known.IMAGE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember4 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember4]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember4: UnionMember4) = apply { + channels = unionMember4.channels.map { it.toMutableList() } + if_ = unionMember4.if_ + loop = unionMember4.loop + ref = unionMember4.ref + type = unionMember4.type + additionalProperties = unionMember4.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember4]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember4 = + UnionMember4( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember4 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTION = of("action") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACTION + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTION, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTION -> Value.ACTION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTION -> Known.ACTION + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember4 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember5 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember5]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember5: UnionMember5) = apply { + channels = unionMember5.channels.map { it.toMutableList() } + if_ = unionMember5.if_ + loop = unionMember5.loop + ref = unionMember5.ref + type = unionMember5.type + additionalProperties = unionMember5.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember5]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember5 = + UnionMember5( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember5 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DIVIDER = of("divider") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIVIDER + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIVIDER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIVIDER -> Value.DIVIDER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DIVIDER -> Known.DIVIDER + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember5 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * Allows you to group elements together. This can be useful when used in combination with "if" + * or "loop". See + * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) + * for more details. + */ + class UnionMember6 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val elements: JsonField>, + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("elements") + @ExcludeMissing + elements: JsonField> = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(elements, channels, if_, loop, ref, type, mutableMapOf()) + + fun toElementalGroupNode(): ElementalGroupNode = + ElementalGroupNode.builder() + .elements(elements) + .channels(channels) + .if_(if_) + .loop(loop) + .ref(ref) + .build() + + /** + * Sub elements to render. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun elements(): List = elements.getRequired("elements") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [elements]. + * + * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("elements") + @ExcludeMissing + fun _elements(): JsonField> = elements + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnionMember6]. + * + * The following fields are required: + * ```java + * .elements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember6]. */ + class Builder internal constructor() { + + private var elements: JsonField>? = null + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember6: UnionMember6) = apply { + elements = unionMember6.elements.map { it.toMutableList() } + channels = unionMember6.channels.map { it.toMutableList() } + if_ = unionMember6.if_ + loop = unionMember6.loop + ref = unionMember6.ref + type = unionMember6.type + additionalProperties = unionMember6.additionalProperties.toMutableMap() + } + + /** Sub elements to render. */ + fun elements(elements: List) = elements(JsonField.of(elements)) + + /** + * Sets [Builder.elements] to an arbitrary JSON value. + * + * You should usually call [Builder.elements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun elements(elements: JsonField>) = apply { + this.elements = elements.map { it.toMutableList() } + } + + /** + * Adds a single [ElementalNode] to [elements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addElement(element: ElementalNode) = apply { + elements = + (elements ?: JsonField.of(mutableListOf())).also { + checkKnown("elements", it).add(element) + } + } + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ + fun addElement(unionMember0: UnionMember0) = + addElement(ElementalNode.ofUnionMember0(unionMember0)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ + fun addElement(unionMember1: UnionMember1) = + addElement(ElementalNode.ofUnionMember1(unionMember1)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ + fun addElement(unionMember2: UnionMember2) = + addElement(ElementalNode.ofUnionMember2(unionMember2)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ + fun addElement(unionMember3: UnionMember3) = + addElement(ElementalNode.ofUnionMember3(unionMember3)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ + fun addElement(unionMember4: UnionMember4) = + addElement(ElementalNode.ofUnionMember4(unionMember4)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ + fun addElement(unionMember5: UnionMember5) = + addElement(ElementalNode.ofUnionMember5(unionMember5)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ + fun addElement(unionMember6: UnionMember6) = + addElement(ElementalNode.ofUnionMember6(unionMember6)) + + /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ + fun addElement(unionMember7: UnionMember7) = + addElement(ElementalNode.ofUnionMember7(unionMember7)) + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember6]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .elements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember6 = + UnionMember6( + checkRequired("elements", elements).map { it.toImmutable() }, + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember6 = apply { + if (validated) { + return@apply + } + + elements().forEach { it.validate() } + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val GROUP = of("group") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + GROUP + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + GROUP, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + GROUP -> Value.GROUP + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + GROUP -> Known.GROUP + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember6 && + elements == other.elements && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(elements, channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember6{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember7 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember7]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember7: UnionMember7) = apply { + channels = unionMember7.channels.map { it.toMutableList() } + if_ = unionMember7.if_ + loop = unionMember7.loop + ref = unionMember7.ref + type = unionMember7.type + additionalProperties = unionMember7.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember7]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember7 = + UnionMember7( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember7 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val QUOTE = of("quote") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + QUOTE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + QUOTE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + QUOTE -> Value.QUOTE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + QUOTE -> Known.QUOTE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember7 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt index 9824531c..5447eab6 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt @@ -479,10 +479,10 @@ private constructor( private constructor( private val id: JsonField, private val createdAt: JsonField, - private val data: JsonField, private val publishedAt: JsonField, private val updatedAt: JsonField, private val version: JsonField, + private val data: JsonField, private val additionalProperties: MutableMap, ) { @@ -492,7 +492,6 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), @JsonProperty("published_at") @ExcludeMissing publishedAt: JsonField = JsonMissing.of(), @@ -500,7 +499,17 @@ private constructor( @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(id, createdAt, data, publishedAt, updatedAt, version, mutableMapOf()) + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + ) : this(id, createdAt, publishedAt, updatedAt, version, data, mutableMapOf()) + + fun toBaseTemplateTenantAssociation(): BaseTemplateTenantAssociation = + BaseTemplateTenantAssociation.builder() + .id(id) + .createdAt(createdAt) + .publishedAt(publishedAt) + .updatedAt(updatedAt) + .version(version) + .build() /** * The template's id @@ -518,14 +527,6 @@ private constructor( */ fun createdAt(): String = createdAt.getRequired("created_at") - /** - * The template's data containing it's routing configs - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun data(): Data = data.getRequired("data") - /** * The timestamp at which the template was published * @@ -550,6 +551,14 @@ private constructor( */ fun version(): String = version.getRequired("version") + /** + * The template's data containing it's routing configs + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun data(): Data = data.getRequired("data") + /** * Returns the raw JSON value of [id]. * @@ -564,13 +573,6 @@ private constructor( */ @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - /** * Returns the raw JSON value of [publishedAt]. * @@ -594,6 +596,13 @@ private constructor( */ @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -615,10 +624,10 @@ private constructor( * ```java * .id() * .createdAt() - * .data() * .publishedAt() * .updatedAt() * .version() + * .data() * ``` */ @JvmStatic fun builder() = Builder() @@ -629,20 +638,20 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null - private var data: JsonField? = null private var publishedAt: JsonField? = null private var updatedAt: JsonField? = null private var version: JsonField? = null + private var data: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(item: Item) = apply { id = item.id createdAt = item.createdAt - data = item.data publishedAt = item.publishedAt updatedAt = item.updatedAt version = item.version + data = item.data additionalProperties = item.additionalProperties.toMutableMap() } @@ -670,18 +679,6 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** The template's data containing it's routing configs */ - fun data(data: Data) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - /** The timestamp at which the template was published */ fun publishedAt(publishedAt: String) = publishedAt(JsonField.of(publishedAt)) @@ -720,6 +717,18 @@ private constructor( */ fun version(version: JsonField) = apply { this.version = version } + /** The template's data containing it's routing configs */ + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -748,10 +757,10 @@ private constructor( * ```java * .id() * .createdAt() - * .data() * .publishedAt() * .updatedAt() * .version() + * .data() * ``` * * @throws IllegalStateException if any required field is unset. @@ -760,10 +769,10 @@ private constructor( Item( checkRequired("id", id), checkRequired("createdAt", createdAt), - checkRequired("data", data), checkRequired("publishedAt", publishedAt), checkRequired("updatedAt", updatedAt), checkRequired("version", version), + checkRequired("data", data), additionalProperties.toMutableMap(), ) } @@ -777,10 +786,10 @@ private constructor( id() createdAt() - data().validate() publishedAt() updatedAt() version() + data().validate() validated = true } @@ -802,10 +811,10 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + (if (publishedAt.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) + (if (version.asKnown().isPresent) 1 else 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) /** The template's data containing it's routing configs */ class Data @@ -978,21 +987,21 @@ private constructor( return other is Item && id == other.id && createdAt == other.createdAt && - data == other.data && publishedAt == other.publishedAt && updatedAt == other.updatedAt && version == other.version && + data == other.data && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, data, publishedAt, updatedAt, version, additionalProperties) + Objects.hash(id, createdAt, publishedAt, updatedAt, version, data, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Item{id=$id, createdAt=$createdAt, data=$data, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" + "Item{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, data=$data, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt index 520ed971..57f29c9f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt @@ -5,10 +5,10 @@ package com.courier.api.services.async.tenants import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -30,7 +30,7 @@ interface TemplateServiceAsync { fun retrieve( templateId: String, params: TemplateRetrieveParams, - ): CompletableFuture = + ): CompletableFuture = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ @@ -38,18 +38,18 @@ interface TemplateServiceAsync { templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = + ): CompletableFuture = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ - fun retrieve(params: TemplateRetrieveParams): CompletableFuture = + fun retrieve(params: TemplateRetrieveParams): CompletableFuture = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** List Templates in Tenant */ fun list(tenantId: String): CompletableFuture = @@ -107,7 +107,7 @@ interface TemplateServiceAsync { fun retrieve( templateId: String, params: TemplateRetrieveParams, - ): CompletableFuture> = + ): CompletableFuture> = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ @@ -115,20 +115,20 @@ interface TemplateServiceAsync { templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams - ): CompletableFuture> = + ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> /** * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt index 23155206..7cf0f7a1 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt @@ -15,10 +15,10 @@ import com.courier.api.core.http.HttpResponse.Handler import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.parseable import com.courier.api.core.prepareAsync +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -38,7 +38,7 @@ class TemplateServiceAsyncImpl internal constructor(private val clientOptions: C override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // get /tenants/{tenant_id}/templates/{template_id} withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } @@ -62,13 +62,13 @@ class TemplateServiceAsyncImpl internal constructor(private val clientOptions: C clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("templateId", params.templateId().getOrNull()) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt index d1b08f8c..95f8bc9b 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt @@ -5,10 +5,10 @@ package com.courier.api.services.blocking.tenants import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -27,26 +27,28 @@ interface TemplateService { fun withOptions(modifier: Consumer): TemplateService /** Get a Template in Tenant */ - fun retrieve(templateId: String, params: TemplateRetrieveParams): TemplateRetrieveResponse = - retrieve(templateId, params, RequestOptions.none()) + fun retrieve( + templateId: String, + params: TemplateRetrieveParams, + ): BaseTemplateTenantAssociation = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ fun retrieve( templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): TemplateRetrieveResponse = + ): BaseTemplateTenantAssociation = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ - fun retrieve(params: TemplateRetrieveParams): TemplateRetrieveResponse = + fun retrieve(params: TemplateRetrieveParams): BaseTemplateTenantAssociation = retrieve(params, RequestOptions.none()) /** @see retrieve */ fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): TemplateRetrieveResponse + ): BaseTemplateTenantAssociation /** List Templates in Tenant */ fun list(tenantId: String): TemplateListResponse = list(tenantId, TemplateListParams.none()) @@ -95,7 +97,7 @@ interface TemplateService { fun retrieve( templateId: String, params: TemplateRetrieveParams, - ): HttpResponseFor = + ): HttpResponseFor = retrieve(templateId, params, RequestOptions.none()) /** @see retrieve */ @@ -104,20 +106,21 @@ interface TemplateService { templateId: String, params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = + ): HttpResponseFor = retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) /** @see retrieve */ @MustBeClosed - fun retrieve(params: TemplateRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) + fun retrieve( + params: TemplateRetrieveParams + ): HttpResponseFor = retrieve(params, RequestOptions.none()) /** @see retrieve */ @MustBeClosed fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor /** * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt index 787d7be2..71d74426 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt @@ -15,10 +15,10 @@ import com.courier.api.core.http.HttpResponse.Handler import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.parseable import com.courier.api.core.prepare +import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation import com.courier.api.models.tenants.templates.TemplateListParams import com.courier.api.models.tenants.templates.TemplateListResponse import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import com.courier.api.models.tenants.templates.TemplateRetrieveResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -37,7 +37,7 @@ class TemplateServiceImpl internal constructor(private val clientOptions: Client override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): TemplateRetrieveResponse = + ): BaseTemplateTenantAssociation = // get /tenants/{tenant_id}/templates/{template_id} withRawResponse().retrieve(params, requestOptions).parse() @@ -61,13 +61,13 @@ class TemplateServiceImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) override fun retrieve( params: TemplateRetrieveParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { // We check here instead of in the params builder because this can be specified // positionally or in the params class. checkRequired("templateId", params.templateId().getOrNull()) diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt new file mode 100644 index 00000000..5c23daa0 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt @@ -0,0 +1,35 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models + +import com.courier.api.core.jsonMapper +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChannelPreferenceTest { + + @Test + fun create() { + val channelPreference = + ChannelPreference.builder().channel(ChannelClassification.DIRECT_MESSAGE).build() + + assertThat(channelPreference.channel()).isEqualTo(ChannelClassification.DIRECT_MESSAGE) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val channelPreference = + ChannelPreference.builder().channel(ChannelClassification.DIRECT_MESSAGE).build() + + val roundtrippedChannelPreference = + jsonMapper.readValue( + jsonMapper.writeValueAsString(channelPreference), + jacksonTypeRef(), + ) + + assertThat(roundtrippedChannelPreference).isEqualTo(channelPreference) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt new file mode 100644 index 00000000..ddd2f81c --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class RuleTest { + + @Test + fun create() { + val rule = Rule.builder().until("until").start("start").build() + + assertThat(rule.until()).isEqualTo("until") + assertThat(rule.start()).contains("start") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val rule = Rule.builder().until("until").start("start").build() + + val roundtrippedRule = + jsonMapper.readValue(jsonMapper.writeValueAsString(rule), jacksonTypeRef()) + + assertThat(roundtrippedRule).isEqualTo(rule) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt new file mode 100644 index 00000000..b5febdd0 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandColorsTest { + + @Test + fun create() { + val brandColors = + BrandColors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + + assertThat(brandColors.primary()).contains("primary") + assertThat(brandColors.secondary()).contains("secondary") + assertThat(brandColors.tertiary()).contains("tertiary") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val brandColors = + BrandColors.builder() + .primary("primary") + .secondary("secondary") + .tertiary("tertiary") + .build() + + val roundtrippedBrandColors = + jsonMapper.readValue( + jsonMapper.writeValueAsString(brandColors), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrandColors).isEqualTo(brandColors) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt index 96f6815e..71b4671f 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt @@ -15,14 +15,14 @@ internal class BrandCreateParamsTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -34,8 +34,8 @@ internal class BrandCreateParamsTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -53,14 +53,14 @@ internal class BrandCreateParamsTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -72,8 +72,8 @@ internal class BrandCreateParamsTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -89,14 +89,14 @@ internal class BrandCreateParamsTest { .isEqualTo( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -109,8 +109,8 @@ internal class BrandCreateParamsTest { .contains( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt index 9783ee59..b117317d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt @@ -24,14 +24,14 @@ internal class BrandListResponseTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -45,8 +45,8 @@ internal class BrandListResponseTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -68,14 +68,14 @@ internal class BrandListResponseTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -89,8 +89,8 @@ internal class BrandListResponseTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -115,14 +115,14 @@ internal class BrandListResponseTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -136,8 +136,8 @@ internal class BrandListResponseTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt index 6ac00664..ca07a8d4 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt @@ -15,14 +15,14 @@ internal class BrandSettingsTest { val brandSettings = BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -32,7 +32,7 @@ internal class BrandSettingsTest { assertThat(brandSettings.colors()) .contains( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") @@ -40,7 +40,7 @@ internal class BrandSettingsTest { ) assertThat(brandSettings.email()) .contains( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -54,14 +54,14 @@ internal class BrandSettingsTest { val brandSettings = BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt new file mode 100644 index 00000000..c90e1882 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrandSnippetTest { + + @Test + fun create() { + val brandSnippet = + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + + assertThat(brandSnippet.format()).isEqualTo(BrandSnippet.Format.HANDLEBARS) + assertThat(brandSnippet.name()).isEqualTo("name") + assertThat(brandSnippet.value()).isEqualTo("value") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val brandSnippet = + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) + .name("name") + .value("value") + .build() + + val roundtrippedBrandSnippet = + jsonMapper.readValue( + jsonMapper.writeValueAsString(brandSnippet), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrandSnippet).isEqualTo(brandSnippet) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt index c003b5cb..d5974d04 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt @@ -14,8 +14,8 @@ internal class BrandSnippetsTest { val brandSnippets = BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -24,8 +24,8 @@ internal class BrandSnippetsTest { assertThat(brandSnippets.items()) .containsExactly( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -38,8 +38,8 @@ internal class BrandSnippetsTest { val brandSnippets = BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt index 9552cfd3..c1e82887 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt @@ -20,14 +20,14 @@ internal class BrandTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -41,8 +41,8 @@ internal class BrandTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -58,14 +58,14 @@ internal class BrandTest { .isEqualTo( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -80,8 +80,8 @@ internal class BrandTest { .contains( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -101,14 +101,14 @@ internal class BrandTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -122,8 +122,8 @@ internal class BrandTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt index 93c77d55..74019c70 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt @@ -16,14 +16,14 @@ internal class BrandUpdateParamsTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -34,8 +34,8 @@ internal class BrandUpdateParamsTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -63,14 +63,14 @@ internal class BrandUpdateParamsTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -81,8 +81,8 @@ internal class BrandUpdateParamsTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -98,14 +98,14 @@ internal class BrandUpdateParamsTest { .contains( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -117,8 +117,8 @@ internal class BrandUpdateParamsTest { .contains( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt new file mode 100644 index 00000000..5caab9aa --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.brands + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class EmailTest { + + @Test + fun create() { + val email = + Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + + assertThat(email._footer()).isEqualTo(JsonValue.from(mapOf())) + assertThat(email._header()).isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val email = + Email.builder() + .footer(JsonValue.from(mapOf())) + .header(JsonValue.from(mapOf())) + .build() + + val roundtrippedEmail = + jsonMapper.readValue(jsonMapper.writeValueAsString(email), jacksonTypeRef()) + + assertThat(roundtrippedEmail).isEqualTo(email) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt index c3d43d77..0726af46 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt @@ -5,6 +5,7 @@ package com.courier.api.models.bulk import com.courier.api.core.JsonValue import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.Utm import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -77,7 +78,7 @@ internal class BulkCreateJobParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -220,7 +221,7 @@ internal class BulkCreateJobParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -358,7 +359,7 @@ internal class BulkCreateJobParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt index aa7a864a..ca80b199 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt @@ -6,6 +6,7 @@ import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.Utm import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -94,7 +95,7 @@ internal class BulkRetrieveJobResponseTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -253,7 +254,7 @@ internal class BulkRetrieveJobResponseTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -413,7 +414,7 @@ internal class BulkRetrieveJobResponseTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt index 8ca3dd87..83892784 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt @@ -6,6 +6,7 @@ import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.Utm import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -78,7 +79,7 @@ internal class InboundBulkMessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -213,7 +214,7 @@ internal class InboundBulkMessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -350,7 +351,7 @@ internal class InboundBulkMessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt new file mode 100644 index 00000000..e404844f --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.lists.subscriptions + +import com.courier.api.core.jsonMapper +import com.courier.api.models.ChannelPreference +import com.courier.api.models.Rule +import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification +import com.courier.api.models.users.preferences.PreferenceStatus +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class NotificationPreferenceDetailsTest { + + @Test + fun create() { + val notificationPreferenceDetails = + NotificationPreferenceDetails.builder() + .status(PreferenceStatus.OPTED_IN) + .addChannelPreference( + ChannelPreference.builder() + .channel(ChannelClassification.DIRECT_MESSAGE) + .build() + ) + .addRule(Rule.builder().until("until").start("start").build()) + .build() + + assertThat(notificationPreferenceDetails.status()).isEqualTo(PreferenceStatus.OPTED_IN) + assertThat(notificationPreferenceDetails.channelPreferences().getOrNull()) + .containsExactly( + ChannelPreference.builder().channel(ChannelClassification.DIRECT_MESSAGE).build() + ) + assertThat(notificationPreferenceDetails.rules().getOrNull()) + .containsExactly(Rule.builder().until("until").start("start").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val notificationPreferenceDetails = + NotificationPreferenceDetails.builder() + .status(PreferenceStatus.OPTED_IN) + .addChannelPreference( + ChannelPreference.builder() + .channel(ChannelClassification.DIRECT_MESSAGE) + .build() + ) + .addRule(Rule.builder().until("until").start("start").build()) + .build() + + val roundtrippedNotificationPreferenceDetails = + jsonMapper.readValue( + jsonMapper.writeValueAsString(notificationPreferenceDetails), + jacksonTypeRef(), + ) + + assertThat(roundtrippedNotificationPreferenceDetails) + .isEqualTo(notificationPreferenceDetails) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt index bc1a4bff..02a48bd3 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt @@ -59,7 +59,7 @@ internal class BaseMessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -175,7 +175,7 @@ internal class BaseMessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -294,7 +294,7 @@ internal class BaseMessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt index 698992ba..04338e09 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt @@ -5,6 +5,8 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.templates.ElementalContent +import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,14 +19,14 @@ internal class ContentTest { @Test fun ofElemental() { val elemental = - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -42,14 +44,14 @@ internal class ContentTest { val jsonMapper = jsonMapper() val content = Content.ofElemental( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt index 04188b3c..55ed144b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt @@ -5,6 +5,8 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper import com.courier.api.errors.CourierInvalidDataException +import com.courier.api.models.tenants.templates.ElementalContent +import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -63,7 +65,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -146,14 +148,14 @@ internal class MessageTest { .build() ) .content( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -222,7 +224,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -309,14 +311,14 @@ internal class MessageTest { .build() ) .content( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") @@ -381,7 +383,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -526,7 +528,7 @@ internal class MessageTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index 372fd470..3889f463 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -61,7 +61,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -208,7 +208,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -357,7 +357,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt new file mode 100644 index 00000000..889e13b8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtmTest { + + @Test + fun create() { + val utm = + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + + assertThat(utm.campaign()).contains("campaign") + assertThat(utm.content()).contains("content") + assertThat(utm.medium()).contains("medium") + assertThat(utm.source()).contains("source") + assertThat(utm.term()).contains("term") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val utm = + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + + val roundtrippedUtm = + jsonMapper.readValue(jsonMapper.writeValueAsString(utm), jacksonTypeRef()) + + assertThat(roundtrippedUtm).isEqualTo(utm) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt new file mode 100644 index 00000000..dda241ef --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BaseTemplateTenantAssociationTest { + + @Test + fun create() { + val baseTemplateTenantAssociation = + BaseTemplateTenantAssociation.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .build() + + assertThat(baseTemplateTenantAssociation.id()).isEqualTo("id") + assertThat(baseTemplateTenantAssociation.createdAt()).isEqualTo("created_at") + assertThat(baseTemplateTenantAssociation.publishedAt()).isEqualTo("published_at") + assertThat(baseTemplateTenantAssociation.updatedAt()).isEqualTo("updated_at") + assertThat(baseTemplateTenantAssociation.version()).isEqualTo("version") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val baseTemplateTenantAssociation = + BaseTemplateTenantAssociation.builder() + .id("id") + .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") + .build() + + val roundtrippedBaseTemplateTenantAssociation = + jsonMapper.readValue( + jsonMapper.writeValueAsString(baseTemplateTenantAssociation), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBaseTemplateTenantAssociation) + .isEqualTo(baseTemplateTenantAssociation) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt new file mode 100644 index 00000000..40d76a91 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalChannelNodeTest { + + @Test + fun create() { + val elementalChannelNode = + ElementalChannelNode.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .build() + + assertThat(elementalChannelNode.channel()).isEqualTo("channel") + assertThat(elementalChannelNode.channels().getOrNull()).containsExactly("string") + assertThat(elementalChannelNode.elements().getOrNull()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalChannelNode.if_()).contains("if") + assertThat(elementalChannelNode.loop()).contains("loop") + assertThat(elementalChannelNode.raw()) + .contains( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + assertThat(elementalChannelNode.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalChannelNode = + ElementalChannelNode.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .build() + + val roundtrippedElementalChannelNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalChannelNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalChannelNode).isEqualTo(elementalChannelNode) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt new file mode 100644 index 00000000..1a816605 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalContentTest { + + @Test + fun create() { + val elementalContent = + ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + + assertThat(elementalContent.elements()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalContent.version()).isEqualTo("version") + assertThat(elementalContent._brand()).isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalContent = + ElementalContent.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .version("version") + .brand(JsonValue.from(mapOf())) + .build() + + val roundtrippedElementalContent = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalContent), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalContent).isEqualTo(elementalContent) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt new file mode 100644 index 00000000..57ed362b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ElementalGroupNodeTest { + + @Test + fun create() { + val elementalGroupNode = + ElementalGroupNode.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .build() + + assertThat(elementalGroupNode.elements()) + .containsExactly( + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + ) + assertThat(elementalGroupNode.channels().getOrNull()).containsExactly("string") + assertThat(elementalGroupNode.if_()).contains("if") + assertThat(elementalGroupNode.loop()).contains("loop") + assertThat(elementalGroupNode.ref()).contains("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val elementalGroupNode = + ElementalGroupNode.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .build() + + val roundtrippedElementalGroupNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalGroupNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalGroupNode).isEqualTo(elementalGroupNode) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt new file mode 100644 index 00000000..a6fe92cb --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt @@ -0,0 +1,450 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.tenants.templates + +import com.courier.api.core.JsonValue +import com.courier.api.core.jsonMapper +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ElementalNodeTest { + + @Test + fun ofUnionMember0() { + val unionMember0 = + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + + val elementalNode = ElementalNode.ofUnionMember0(unionMember0) + + assertThat(elementalNode.unionMember0()).contains(unionMember0) + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember0( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember1() { + val unionMember1 = + ElementalNode.UnionMember1.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember1.Type.META) + .build() + + val elementalNode = ElementalNode.ofUnionMember1(unionMember1) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).contains(unionMember1) + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember1Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember1( + ElementalNode.UnionMember1.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember1.Type.META) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember2() { + val unionMember2 = + ElementalNode.UnionMember2.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .type(ElementalNode.UnionMember2.Type.CHANNEL) + .build() + + val elementalNode = ElementalNode.ofUnionMember2(unionMember2) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).contains(unionMember2) + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember2Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember2( + ElementalNode.UnionMember2.builder() + .channel("channel") + .addChannel("string") + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .if_("if") + .loop("loop") + .raw( + ElementalChannelNode.Raw.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .ref("ref") + .type(ElementalNode.UnionMember2.Type.CHANNEL) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember3() { + val unionMember3 = + ElementalNode.UnionMember3.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember3.Type.IMAGE) + .build() + + val elementalNode = ElementalNode.ofUnionMember3(unionMember3) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).contains(unionMember3) + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember3Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember3( + ElementalNode.UnionMember3.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember3.Type.IMAGE) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember4() { + val unionMember4 = + ElementalNode.UnionMember4.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember4.Type.ACTION) + .build() + + val elementalNode = ElementalNode.ofUnionMember4(unionMember4) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).contains(unionMember4) + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember4Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember4( + ElementalNode.UnionMember4.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember4.Type.ACTION) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember5() { + val unionMember5 = + ElementalNode.UnionMember5.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember5.Type.DIVIDER) + .build() + + val elementalNode = ElementalNode.ofUnionMember5(unionMember5) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).contains(unionMember5) + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember5Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember5( + ElementalNode.UnionMember5.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember5.Type.DIVIDER) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember6() { + val unionMember6 = + ElementalNode.UnionMember6.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember6.Type.GROUP) + .build() + + val elementalNode = ElementalNode.ofUnionMember6(unionMember6) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).contains(unionMember6) + assertThat(elementalNode.unionMember7()).isEmpty + } + + @Test + fun ofUnionMember6Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember6( + ElementalNode.UnionMember6.builder() + .addElement( + ElementalNode.UnionMember0.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember0.Type.TEXT) + .build() + ) + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember6.Type.GROUP) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + @Test + fun ofUnionMember7() { + val unionMember7 = + ElementalNode.UnionMember7.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember7.Type.QUOTE) + .build() + + val elementalNode = ElementalNode.ofUnionMember7(unionMember7) + + assertThat(elementalNode.unionMember0()).isEmpty + assertThat(elementalNode.unionMember1()).isEmpty + assertThat(elementalNode.unionMember2()).isEmpty + assertThat(elementalNode.unionMember3()).isEmpty + assertThat(elementalNode.unionMember4()).isEmpty + assertThat(elementalNode.unionMember5()).isEmpty + assertThat(elementalNode.unionMember6()).isEmpty + assertThat(elementalNode.unionMember7()).contains(unionMember7) + } + + @Test + fun ofUnionMember7Roundtrip() { + val jsonMapper = jsonMapper() + val elementalNode = + ElementalNode.ofUnionMember7( + ElementalNode.UnionMember7.builder() + .addChannel("string") + .if_("if") + .loop("loop") + .ref("ref") + .type(ElementalNode.UnionMember7.Type.QUOTE) + .build() + ) + + val roundtrippedElementalNode = + jsonMapper.readValue( + jsonMapper.writeValueAsString(elementalNode), + jacksonTypeRef(), + ) + + assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val elementalNode = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { elementalNode.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt index 41303da7..427e61d3 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt @@ -23,6 +23,9 @@ internal class TemplateListResponseTest { TemplateListResponse.Item.builder() .id("id") .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") .data( TemplateListResponse.Item.Data.builder() .routing( @@ -33,9 +36,6 @@ internal class TemplateListResponseTest { ) .build() ) - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") .build() ) .nextUrl("next_url") @@ -50,6 +50,9 @@ internal class TemplateListResponseTest { TemplateListResponse.Item.builder() .id("id") .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") .data( TemplateListResponse.Item.Data.builder() .routing( @@ -60,9 +63,6 @@ internal class TemplateListResponseTest { ) .build() ) - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") .build() ) assertThat(templateListResponse.nextUrl()).contains("next_url") @@ -81,6 +81,9 @@ internal class TemplateListResponseTest { TemplateListResponse.Item.builder() .id("id") .createdAt("created_at") + .publishedAt("published_at") + .updatedAt("updated_at") + .version("version") .data( TemplateListResponse.Item.Data.builder() .routing( @@ -91,9 +94,6 @@ internal class TemplateListResponseTest { ) .build() ) - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") .build() ) .nextUrl("next_url") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt deleted file mode 100644 index de5d7b67..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveResponseTest.kt +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TemplateRetrieveResponseTest { - - @Test - fun create() { - val templateRetrieveResponse = - TemplateRetrieveResponse.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .build() - - assertThat(templateRetrieveResponse.id()).isEqualTo("id") - assertThat(templateRetrieveResponse.createdAt()).isEqualTo("created_at") - assertThat(templateRetrieveResponse.publishedAt()).isEqualTo("published_at") - assertThat(templateRetrieveResponse.updatedAt()).isEqualTo("updated_at") - assertThat(templateRetrieveResponse.version()).isEqualTo("version") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val templateRetrieveResponse = - TemplateRetrieveResponse.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .build() - - val roundtrippedTemplateRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(templateRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTemplateRetrieveResponse).isEqualTo(templateRetrieveResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index 674007a8..74cb21e0 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -22,6 +22,7 @@ import com.courier.api.models.send.Content import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -130,7 +131,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -301,7 +302,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -472,7 +473,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -643,7 +644,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -814,7 +815,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -985,7 +986,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1156,7 +1157,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1327,7 +1328,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1498,7 +1499,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1669,7 +1670,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1840,7 +1841,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2011,7 +2012,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2182,7 +2183,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2353,7 +2354,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2524,7 +2525,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2695,7 +2696,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2864,7 +2865,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index 68d82b1f..ef3450ef 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -11,6 +11,7 @@ import com.courier.api.models.send.Content import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -99,7 +100,7 @@ internal class ServiceParamsTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt index ddb33187..e5c3cfbb 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt @@ -5,11 +5,14 @@ package com.courier.api.services.async import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue +import com.courier.api.models.brands.BrandColors import com.courier.api.models.brands.BrandCreateParams import com.courier.api.models.brands.BrandListParams import com.courier.api.models.brands.BrandSettings +import com.courier.api.models.brands.BrandSnippet import com.courier.api.models.brands.BrandSnippets import com.courier.api.models.brands.BrandUpdateParams +import com.courier.api.models.brands.Email import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -34,14 +37,14 @@ internal class BrandServiceAsyncTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -53,8 +56,8 @@ internal class BrandServiceAsyncTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -102,14 +105,14 @@ internal class BrandServiceAsyncTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -120,8 +123,8 @@ internal class BrandServiceAsyncTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt index 63de477a..e976a17d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt @@ -14,6 +14,7 @@ import com.courier.api.models.bulk.UserRecipient import com.courier.api.models.lists.subscriptions.RecipientPreferences import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -256,7 +257,7 @@ internal class BulkServiceAsyncTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 902afcc0..4a4c7bbb 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -11,6 +11,7 @@ import com.courier.api.models.send.Content import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -81,7 +82,7 @@ internal class SendServiceAsyncTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt index 27d4470b..f650a197 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt @@ -23,7 +23,7 @@ internal class TemplateServiceAsyncTest { .build() val templateServiceAsync = client.tenants().templates() - val templateFuture = + val baseTemplateTenantAssociationFuture = templateServiceAsync.retrieve( TemplateRetrieveParams.builder() .tenantId("tenant_id") @@ -31,8 +31,8 @@ internal class TemplateServiceAsyncTest { .build() ) - val template = templateFuture.get() - template.validate() + val baseTemplateTenantAssociation = baseTemplateTenantAssociationFuture.get() + baseTemplateTenantAssociation.validate() } @Disabled("Prism tests are disabled") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt index 739ae31c..a89fb29e 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt @@ -5,11 +5,14 @@ package com.courier.api.services.blocking import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue +import com.courier.api.models.brands.BrandColors import com.courier.api.models.brands.BrandCreateParams import com.courier.api.models.brands.BrandListParams import com.courier.api.models.brands.BrandSettings +import com.courier.api.models.brands.BrandSnippet import com.courier.api.models.brands.BrandSnippets import com.courier.api.models.brands.BrandUpdateParams +import com.courier.api.models.brands.Email import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -34,14 +37,14 @@ internal class BrandServiceTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -53,8 +56,8 @@ internal class BrandServiceTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() @@ -100,14 +103,14 @@ internal class BrandServiceTest { .settings( BrandSettings.builder() .colors( - BrandSettings.Colors.builder() + BrandColors.builder() .primary("primary") .secondary("secondary") .tertiary("tertiary") .build() ) .email( - BrandSettings.Email.builder() + Email.builder() .footer(JsonValue.from(mapOf())) .header(JsonValue.from(mapOf())) .build() @@ -118,8 +121,8 @@ internal class BrandServiceTest { .snippets( BrandSnippets.builder() .addItem( - BrandSnippets.Item.builder() - .format(BrandSnippets.Item.Format.HANDLEBARS) + BrandSnippet.builder() + .format(BrandSnippet.Format.HANDLEBARS) .name("name") .value("value") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt index 199f1705..e1dce8ba 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt @@ -14,6 +14,7 @@ import com.courier.api.models.bulk.UserRecipient import com.courier.api.models.lists.subscriptions.RecipientPreferences import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -253,7 +254,7 @@ internal class BulkServiceTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index 9bc19a3e..d4487726 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -11,6 +11,7 @@ import com.courier.api.models.send.Content import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -81,7 +82,7 @@ internal class SendServiceTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt index a7c32e45..2476c72d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt @@ -23,7 +23,7 @@ internal class TemplateServiceTest { .build() val templateService = client.tenants().templates() - val template = + val baseTemplateTenantAssociation = templateService.retrieve( TemplateRetrieveParams.builder() .tenantId("tenant_id") @@ -31,7 +31,7 @@ internal class TemplateServiceTest { .build() ) - template.validate() + baseTemplateTenantAssociation.validate() } @Disabled("Prism tests are disabled") diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt index 26c8af84..34bdb5b3 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -9,6 +9,9 @@ import com.courier.api.models.automations.invoke.MergeAlgorithm import com.courier.api.models.send.BaseMessage import com.courier.api.models.send.Content import com.courier.api.models.send.MessageContext +import com.courier.api.models.send.Utm +import com.courier.api.models.tenants.templates.ElementalContent +import com.courier.api.models.tenants.templates.ElementalNode import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -119,7 +122,7 @@ internal class ProGuardCompatibilityTest { .addTag("string") .traceId("trace_id") .utm( - BaseMessage.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -198,14 +201,14 @@ internal class ProGuardCompatibilityTest { val jsonMapper = jsonMapper() val content = Content.ofElemental( - Content.ElementalContent.builder() + ElementalContent.builder() .addElement( - Content.ElementalContent.Element.UnionMember0.builder() + ElementalNode.UnionMember0.builder() .addChannel("string") .if_("if") .loop("loop") .ref("ref") - .type(Content.ElementalContent.Element.UnionMember0.Type.TEXT) + .type(ElementalNode.UnionMember0.Type.TEXT) .build() ) .version("version") From 1d5dae306c780129e17111dae95b55bc600ad6e9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 19:25:12 +0000 Subject: [PATCH 20/33] feat(api): manual updates --- .stats.yml | 8 +- README.md | 128 +- .../com/courier/api/client/CourierClient.kt | 75 - .../courier/api/client/CourierClientAsync.kt | 75 - .../api/client/CourierClientAsyncImpl.kt | 202 - .../courier/api/client/CourierClientImpl.kt | 190 - .../courier/api/core/handlers/EmptyHandler.kt | 12 - .../courier/api/models/ChannelPreference.kt | 177 - .../kotlin/com/courier/api/models/Rule.kt | 203 - .../courier/api/models/audiences/Audience.kt | 364 - .../models/audiences/AudienceDeleteParams.kt | 229 - .../audiences/AudienceListMembersParams.kt | 216 - .../audiences/AudienceListMembersResponse.kt | 538 - .../models/audiences/AudienceListParams.kt | 191 - .../models/audiences/AudienceListResponse.kt | 221 - .../audiences/AudienceRetrieveParams.kt | 194 - .../models/audiences/AudienceUpdateParams.kt | 577 - .../audiences/AudienceUpdateResponse.kt | 172 - .../courier/api/models/audiences/Filter.kt | 660 -- .../api/models/audiences/FilterConfig.kt | 656 -- .../models/audiences/NestedFilterConfig.kt | 439 - .../courier/api/models/audiences/Paging.kt | 203 - .../api/models/auditevents/AuditEvent.kt | 703 -- .../auditevents/AuditEventListParams.kt | 191 - .../auditevents/AuditEventListResponse.kt | 226 - .../auditevents/AuditEventRetrieveParams.kt | 194 - .../api/models/auth/AuthIssueTokenParams.kt | 477 - .../api/models/auth/AuthIssueTokenResponse.kt | 157 - .../invoke/AutomationInvokeParams.kt | 377 - .../invoke/AutomationInvokeResponse.kt | 170 - .../automations/invoke/AutomationStep.kt | 190 - .../invoke/InvokeInvokeAdHocParams.kt | 9457 ----------------- .../invoke/InvokeInvokeByTemplateParams.kt | 224 - .../automations/invoke/MergeAlgorithm.kt | 144 - .../com/courier/api/models/brands/Brand.kt | 452 - .../courier/api/models/brands/BrandColors.kt | 228 - .../api/models/brands/BrandCreateParams.kt | 618 -- .../api/models/brands/BrandDeleteParams.kt | 229 - .../api/models/brands/BrandListParams.kt | 191 - .../api/models/brands/BrandListResponse.kt | 224 - .../api/models/brands/BrandRetrieveParams.kt | 189 - .../api/models/brands/BrandSettings.kt | 202 - .../courier/api/models/brands/BrandSnippet.kt | 359 - .../api/models/brands/BrandSnippets.kt | 190 - .../api/models/brands/BrandUpdateParams.kt | 577 - .../com/courier/api/models/brands/Email.kt | 161 - .../api/models/bulk/BulkAddUsersParams.kt | 462 - .../api/models/bulk/BulkCreateJobParams.kt | 416 - .../api/models/bulk/BulkCreateJobResponse.kt | 170 - .../api/models/bulk/BulkListUsersParams.kt | 216 - .../api/models/bulk/BulkListUsersResponse.kt | 710 -- .../api/models/bulk/BulkRetrieveJobParams.kt | 189 - .../models/bulk/BulkRetrieveJobResponse.kt | 612 -- .../api/models/bulk/BulkRunJobParams.kt | 229 - .../api/models/bulk/InboundBulkMessage.kt | 2294 ---- .../api/models/bulk/InboundBulkMessageUser.kt | 264 - .../courier/api/models/bulk/UserRecipient.kt | 1046 -- .../models/inbound/InboundTrackEventParams.kt | 925 -- .../inbound/InboundTrackEventResponse.kt | 177 - .../com/courier/api/models/lists/List.kt | 277 - .../api/models/lists/ListDeleteParams.kt | 229 - .../api/models/lists/ListListParams.kt | 220 - .../api/models/lists/ListListResponse.kt | 222 - .../api/models/lists/ListRestoreParams.kt | 219 - .../api/models/lists/ListRetrieveParams.kt | 189 - .../api/models/lists/ListUpdateParams.kt | 508 - .../NotificationPreferenceDetails.kt | 292 - .../PutSubscriptionsRecipient.kt | 222 - .../subscriptions/RecipientPreferences.kt | 407 - .../subscriptions/SubscriptionAddParams.kt | 473 - .../subscriptions/SubscriptionListParams.kt | 214 - .../subscriptions/SubscriptionListResponse.kt | 467 - .../SubscriptionSubscribeParams.kt | 473 - .../SubscriptionSubscribeUserParams.kt | 452 - .../SubscriptionUnsubscribeUserParams.kt | 262 - .../models/messages/MessageCancelParams.kt | 234 - .../models/messages/MessageContentParams.kt | 193 - .../models/messages/MessageContentResponse.kt | 1015 -- .../api/models/messages/MessageDetails.kt | 1009 -- .../models/messages/MessageHistoryParams.kt | 214 - .../models/messages/MessageHistoryResponse.kt | 289 - .../api/models/messages/MessageListParams.kt | 475 - .../models/messages/MessageListResponse.kt | 234 - .../models/messages/MessageRetrieveParams.kt | 193 - .../messages/MessageRetrieveResponse.kt | 814 -- .../notifications/NotificationGetContent.kt | 1906 ---- .../notifications/NotificationListParams.kt | 215 - .../notifications/NotificationListResponse.kt | 1014 -- .../NotificationRetrieveContentParams.kt | 197 - .../models/notifications/checks/BaseCheck.kt | 490 - .../api/models/notifications/checks/Check.kt | 280 - .../notifications/checks/CheckDeleteParams.kt | 257 - .../notifications/checks/CheckListParams.kt | 216 - .../notifications/checks/CheckListResponse.kt | 190 - .../notifications/checks/CheckUpdateParams.kt | 471 - .../checks/CheckUpdateResponse.kt | 190 - .../draft/DraftRetrieveContentParams.kt | 190 - .../models/profiles/ProfileCreateParams.kt | 534 - .../models/profiles/ProfileCreateResponse.kt | 291 - .../models/profiles/ProfileDeleteParams.kt | 229 - .../models/profiles/ProfileReplaceParams.kt | 536 - .../models/profiles/ProfileReplaceResponse.kt | 291 - .../models/profiles/ProfileRetrieveParams.kt | 189 - .../profiles/ProfileRetrieveResponse.kt | 318 - .../models/profiles/ProfileUpdateParams.kt | 699 -- .../models/profiles/lists/ListDeleteParams.kt | 229 - .../profiles/lists/ListDeleteResponse.kt | 288 - .../profiles/lists/ListRetrieveParams.kt | 214 - .../profiles/lists/ListRetrieveResponse.kt | 547 - .../profiles/lists/ListSubscribeParams.kt | 664 -- .../profiles/lists/ListSubscribeResponse.kt | 291 - .../models/requests/RequestArchiveParams.kt | 229 - .../courier/api/models/send/BaseMessage.kt | 3017 ------ .../api/models/send/BaseMessageSendTo.kt | 7483 ------------- .../com/courier/api/models/send/Content.kt | 412 - .../com/courier/api/models/send/Message.kt | 1873 ---- .../courier/api/models/send/MessageContext.kt | 10 +- .../{notifications => send}/MessageRouting.kt | 2 +- .../MessageRoutingChannel.kt | 2 +- .../api/models/send/MsTeamsBaseProperties.kt | 208 - .../com/courier/api/models/send/Recipient.kt | 7185 +------------ .../api/models/send/SendMessageParams.kt | 429 - .../api/models/send/SendSendMessageParams.kt | 5284 +++++++++ ...Response.kt => SendSendMessageResponse.kt} | 47 +- .../api/models/send/SlackBaseProperties.kt | 175 - .../kotlin/com/courier/api/models/send/Utm.kt | 293 - .../api/models/tenants/DefaultPreferences.kt | 512 - .../com/courier/api/models/tenants/Tenant.kt | 655 -- .../api/models/tenants/TenantDeleteParams.kt | 229 - .../api/models/tenants/TenantListParams.kt | 234 - .../api/models/tenants/TenantListResponse.kt | 501 - .../models/tenants/TenantListUsersParams.kt | 236 - .../models/tenants/TenantListUsersResponse.kt | 502 - .../models/tenants/TenantRetrieveParams.kt | 189 - .../api/models/tenants/TenantUpdateParams.kt | 1055 -- .../items/ChannelClassification.kt | 158 - .../items/ItemDeleteParams.kt | 258 - .../items/ItemUpdateParams.kt | 242 - .../items/SubscriptionTopicNew.kt | 428 - .../BaseTemplateTenantAssociation.kt | 329 - .../tenants/templates/ElementalChannelNode.kt | 572 - .../tenants/templates/ElementalContent.kt | 274 - .../tenants/templates/ElementalGroupNode.kt | 385 - .../models/tenants/templates/ElementalNode.kt | 4182 -------- .../tenants/templates/TemplateListParams.kt | 236 - .../tenants/templates/TemplateListResponse.kt | 1030 -- .../templates/TemplateRetrieveParams.kt | 217 - .../translations/TranslationRetrieveParams.kt | 217 - .../translations/TranslationUpdateParams.kt | 230 - .../preferences/PreferenceRetrieveParams.kt | 214 - .../preferences/PreferenceRetrieveResponse.kt | 230 - .../PreferenceRetrieveTopicParams.kt | 238 - .../PreferenceRetrieveTopicResponse.kt | 175 - .../users/preferences/PreferenceStatus.kt | 139 - .../PreferenceUpdateOrCreateTopicParams.kt | 745 -- .../PreferenceUpdateOrCreateTopicResponse.kt | 174 - .../users/preferences/TopicPreference.kt | 417 - .../users/tenants/TenantAddMultipleParams.kt | 467 - .../users/tenants/TenantAddSingleParams.kt | 537 - .../models/users/tenants/TenantAssociation.kt | 508 - .../models/users/tenants/TenantListParams.kt | 236 - .../users/tenants/TenantListResponse.kt | 501 - .../users/tenants/TenantRemoveAllParams.kt | 229 - .../users/tenants/TenantRemoveSingleParams.kt | 259 - .../users/tokens/TokenAddMultipleParams.kt | 230 - .../users/tokens/TokenAddSingleParams.kt | 233 - .../models/users/tokens/TokenDeleteParams.kt | 258 - .../models/users/tokens/TokenListParams.kt | 189 - .../users/tokens/TokenRetrieveParams.kt | 217 - .../users/tokens/TokenRetrieveResponse.kt | 616 -- .../models/users/tokens/TokenUpdateParams.kt | 706 -- .../api/models/users/tokens/UserToken.kt | 1309 --- .../services/async/AudienceServiceAsync.kt | 389 - .../async/AudienceServiceAsyncImpl.kt | 250 - .../services/async/AuditEventServiceAsync.kt | 162 - .../async/AuditEventServiceAsyncImpl.kt | 128 - .../api/services/async/AuthServiceAsync.kt | 62 - .../services/async/AuthServiceAsyncImpl.kt | 86 - .../services/async/AutomationServiceAsync.kt | 42 - .../async/AutomationServiceAsyncImpl.kt | 42 - .../api/services/async/BrandServiceAsync.kt | 302 - .../services/async/BrandServiceAsyncImpl.kt | 243 - .../api/services/async/BulkServiceAsync.kt | 335 - .../services/async/BulkServiceAsyncImpl.kt | 243 - .../api/services/async/InboundServiceAsync.kt | 66 - .../services/async/InboundServiceAsyncImpl.kt | 86 - .../api/services/async/ListServiceAsync.kt | 319 - .../services/async/ListServiceAsyncImpl.kt | 248 - .../api/services/async/MessageServiceAsync.kt | 404 - .../services/async/MessageServiceAsyncImpl.kt | 256 - .../async/NotificationServiceAsync.kt | 175 - .../async/NotificationServiceAsyncImpl.kt | 152 - .../api/services/async/ProfileServiceAsync.kt | 361 - .../services/async/ProfileServiceAsyncImpl.kt | 259 - .../api/services/async/RequestServiceAsync.kt | 110 - .../services/async/RequestServiceAsyncImpl.kt | 82 - .../api/services/async/SendServiceAsync.kt | 36 +- .../services/async/SendServiceAsyncImpl.kt | 24 +- .../api/services/async/TenantServiceAsync.kt | 371 - .../services/async/TenantServiceAsyncImpl.kt | 274 - .../services/async/TranslationServiceAsync.kt | 142 - .../async/TranslationServiceAsyncImpl.kt | 118 - .../api/services/async/UserServiceAsync.kt | 47 - .../services/async/UserServiceAsyncImpl.kt | 68 - .../async/automations/InvokeServiceAsync.kt | 127 - .../automations/InvokeServiceAsyncImpl.kt | 130 - .../async/lists/SubscriptionServiceAsync.kt | 331 - .../lists/SubscriptionServiceAsyncImpl.kt | 241 - .../async/notifications/CheckServiceAsync.kt | 193 - .../notifications/CheckServiceAsyncImpl.kt | 184 - .../async/notifications/DraftServiceAsync.kt | 118 - .../notifications/DraftServiceAsyncImpl.kt | 89 - .../async/profiles/ListServiceAsync.kt | 250 - .../async/profiles/ListServiceAsyncImpl.kt | 176 - .../tenants/DefaultPreferenceServiceAsync.kt | 42 - .../DefaultPreferenceServiceAsyncImpl.kt | 44 - .../async/tenants/TemplateServiceAsync.kt | 174 - .../async/tenants/TemplateServiceAsyncImpl.kt | 136 - .../defaultpreferences/ItemServiceAsync.kt | 133 - .../ItemServiceAsyncImpl.kt | 129 - .../async/users/PreferenceServiceAsync.kt | 239 - .../async/users/PreferenceServiceAsyncImpl.kt | 185 - .../async/users/TenantServiceAsync.kt | 345 - .../async/users/TenantServiceAsyncImpl.kt | 231 - .../services/async/users/TokenServiceAsync.kt | 382 - .../async/users/TokenServiceAsyncImpl.kt | 273 - .../api/services/blocking/AudienceService.kt | 382 - .../services/blocking/AudienceServiceImpl.kt | 232 - .../services/blocking/AuditEventService.kt | 158 - .../blocking/AuditEventServiceImpl.kt | 121 - .../api/services/blocking/AuthService.kt | 62 - .../api/services/blocking/AuthServiceImpl.kt | 81 - .../services/blocking/AutomationService.kt | 39 - .../blocking/AutomationServiceImpl.kt | 42 - .../api/services/blocking/BrandService.kt | 287 - .../api/services/blocking/BrandServiceImpl.kt | 213 - .../api/services/blocking/BulkService.kt | 328 - .../api/services/blocking/BulkServiceImpl.kt | 222 - .../api/services/blocking/InboundService.kt | 63 - .../services/blocking/InboundServiceImpl.kt | 82 - .../api/services/blocking/ListService.kt | 308 - .../api/services/blocking/ListServiceImpl.kt | 219 - .../api/services/blocking/MessageService.kt | 396 - .../services/blocking/MessageServiceImpl.kt | 240 - .../services/blocking/NotificationService.kt | 171 - .../blocking/NotificationServiceImpl.kt | 145 - .../api/services/blocking/ProfileService.kt | 346 - .../services/blocking/ProfileServiceImpl.kt | 239 - .../api/services/blocking/RequestService.kt | 103 - .../services/blocking/RequestServiceImpl.kt | 76 - .../api/services/blocking/SendService.kt | 30 +- .../api/services/blocking/SendServiceImpl.kt | 24 +- .../api/services/blocking/TenantService.kt | 354 - .../services/blocking/TenantServiceImpl.kt | 250 - .../services/blocking/TranslationService.kt | 140 - .../blocking/TranslationServiceImpl.kt | 109 - .../api/services/blocking/UserService.kt | 47 - .../api/services/blocking/UserServiceImpl.kt | 65 - .../blocking/automations/InvokeService.kt | 126 - .../blocking/automations/InvokeServiceImpl.kt | 123 - .../blocking/lists/SubscriptionService.kt | 321 - .../blocking/lists/SubscriptionServiceImpl.kt | 223 - .../blocking/notifications/CheckService.kt | 189 - .../notifications/CheckServiceImpl.kt | 169 - .../blocking/notifications/DraftService.kt | 113 - .../notifications/DraftServiceImpl.kt | 85 - .../services/blocking/profiles/ListService.kt | 243 - .../blocking/profiles/ListServiceImpl.kt | 165 - .../tenants/DefaultPreferenceService.kt | 42 - .../tenants/DefaultPreferenceServiceImpl.kt | 42 - .../blocking/tenants/TemplateService.kt | 169 - .../blocking/tenants/TemplateServiceImpl.kt | 129 - .../tenants/defaultpreferences/ItemService.kt | 127 - .../defaultpreferences/ItemServiceImpl.kt | 117 - .../blocking/users/PreferenceService.kt | 239 - .../blocking/users/PreferenceServiceImpl.kt | 175 - .../services/blocking/users/TenantService.kt | 336 - .../blocking/users/TenantServiceImpl.kt | 207 - .../services/blocking/users/TokenService.kt | 369 - .../blocking/users/TokenServiceImpl.kt | 243 - .../api/models/ChannelPreferenceTest.kt | 35 - .../kotlin/com/courier/api/models/RuleTest.kt | 30 - .../audiences/AudienceDeleteParamsTest.kt | 23 - .../AudienceListMembersParamsTest.kt | 43 - .../AudienceListMembersResponseTest.kt | 67 - .../audiences/AudienceListParamsTest.kt | 33 - .../audiences/AudienceListResponseTest.kt | 88 - .../audiences/AudienceRetrieveParamsTest.kt | 23 - .../api/models/audiences/AudienceTest.kt | 74 - .../audiences/AudienceUpdateParamsTest.kt | 73 - .../audiences/AudienceUpdateResponseTest.kt | 84 - .../api/models/audiences/FilterConfigTest.kt | 115 - .../api/models/audiences/FilterTest.kt | 109 - .../audiences/NestedFilterConfigTest.kt | 62 - .../api/models/audiences/PagingTest.kt | 30 - .../auditevents/AuditEventListParamsTest.kt | 33 - .../auditevents/AuditEventListResponseTest.kt | 71 - .../AuditEventRetrieveParamsTest.kt | 23 - .../api/models/auditevents/AuditEventTest.kt | 55 - .../models/auth/AuthIssueTokenParamsTest.kt | 24 - .../models/auth/AuthIssueTokenResponseTest.kt | 32 - .../invoke/AutomationInvokeParamsTest.kt | 65 - .../invoke/AutomationInvokeResponseTest.kt | 35 - .../automations/invoke/AutomationStepTest.kt | 33 - .../invoke/InvokeInvokeAdHocParamsTest.kt | 149 - .../InvokeInvokeByTemplateParamsTest.kt | 94 - .../api/models/brands/BrandColorsTest.kt | 44 - .../models/brands/BrandCreateParamsTest.kt | 135 - .../models/brands/BrandDeleteParamsTest.kt | 23 - .../api/models/brands/BrandListParamsTest.kt | 33 - .../models/brands/BrandListResponseTest.kt | 159 - .../models/brands/BrandRetrieveParamsTest.kt | 23 - .../api/models/brands/BrandSettingsTest.kt | 80 - .../api/models/brands/BrandSnippetTest.kt | 44 - .../api/models/brands/BrandSnippetsTest.kt | 57 - .../courier/api/models/brands/BrandTest.kt | 140 - .../models/brands/BrandUpdateParamsTest.kt | 138 - .../courier/api/models/brands/EmailTest.kt | 39 - .../api/models/bulk/BulkAddUsersParamsTest.kt | 433 - .../models/bulk/BulkCreateJobParamsTest.kt | 442 - .../models/bulk/BulkCreateJobResponseTest.kt | 32 - .../models/bulk/BulkListUsersParamsTest.kt | 42 - .../models/bulk/BulkListUsersResponseTest.kt | 436 - .../models/bulk/BulkRetrieveJobParamsTest.kt | 23 - .../bulk/BulkRetrieveJobResponseTest.kt | 511 - .../api/models/bulk/BulkRunJobParamsTest.kt | 23 - .../api/models/bulk/InboundBulkMessageTest.kt | 431 - .../models/bulk/InboundBulkMessageUserTest.kt | 369 - .../api/models/bulk/UserRecipientTest.kt | 201 - .../inbound/InboundTrackEventParamsTest.kt | 91 - .../inbound/InboundTrackEventResponseTest.kt | 39 - .../api/models/lists/ListDeleteParamsTest.kt | 23 - .../api/models/lists/ListListParamsTest.kt | 36 - .../api/models/lists/ListListResponseTest.kt | 60 - .../api/models/lists/ListRestoreParamsTest.kt | 44 - .../models/lists/ListRetrieveParamsTest.kt | 23 - .../com/courier/api/models/lists/ListTest.kt | 34 - .../api/models/lists/ListUpdateParamsTest.kt | 163 - .../NotificationPreferenceDetailsTest.kt | 62 - .../PutSubscriptionsRecipientTest.kt | 156 - .../subscriptions/RecipientPreferencesTest.kt | 128 - .../SubscriptionAddParamsTest.kt | 217 - .../SubscriptionListParamsTest.kt | 42 - .../SubscriptionListResponseTest.kt | 206 - .../SubscriptionSubscribeParamsTest.kt | 217 - .../SubscriptionSubscribeUserParamsTest.kt | 162 - .../SubscriptionUnsubscribeUserParamsTest.kt | 25 - .../messages/MessageCancelParamsTest.kt | 23 - .../messages/MessageContentParamsTest.kt | 23 - .../messages/MessageContentResponseTest.kt | 99 - .../api/models/messages/MessageDetailsTest.kt | 71 - .../messages/MessageHistoryParamsTest.kt | 42 - .../messages/MessageHistoryResponseTest.kt | 52 - .../models/messages/MessageListParamsTest.kt | 82 - .../messages/MessageListResponseTest.kt | 89 - .../messages/MessageRetrieveParamsTest.kt | 23 - .../messages/MessageRetrieveResponseTest.kt | 89 - .../NotificationGetContentTest.kt | 154 - .../NotificationListParamsTest.kt | 34 - .../NotificationListResponseTest.kt | 119 - .../NotificationRetrieveContentParamsTest.kt | 23 - .../notifications/checks/BaseCheckTest.kt | 44 - .../checks/CheckDeleteParamsTest.kt | 24 - .../checks/CheckListParamsTest.kt | 24 - .../checks/CheckListResponseTest.kt | 60 - .../models/notifications/checks/CheckTest.kt | 44 - .../checks/CheckUpdateParamsTest.kt | 72 - .../checks/CheckUpdateResponseTest.kt | 60 - .../draft/DraftRetrieveContentParamsTest.kt | 23 - .../profiles/ProfileCreateParamsTest.kt | 61 - .../profiles/ProfileCreateResponseTest.kt | 34 - .../profiles/ProfileDeleteParamsTest.kt | 23 - .../profiles/ProfileReplaceParamsTest.kt | 61 - .../profiles/ProfileReplaceResponseTest.kt | 34 - .../profiles/ProfileRetrieveParamsTest.kt | 23 - .../profiles/ProfileRetrieveResponseTest.kt | 170 - .../profiles/ProfileUpdateParamsTest.kt | 52 - .../profiles/lists/ListDeleteParamsTest.kt | 23 - .../profiles/lists/ListDeleteResponseTest.kt | 34 - .../profiles/lists/ListRetrieveParamsTest.kt | 42 - .../lists/ListRetrieveResponseTest.kt | 213 - .../profiles/lists/ListSubscribeParamsTest.kt | 214 - .../lists/ListSubscribeResponseTest.kt | 34 - .../requests/RequestArchiveParamsTest.kt | 23 - .../api/models/send/BaseMessageSendToTest.kt | 96 - .../api/models/send/BaseMessageTest.kt | 370 - .../courier/api/models/send/ContentTest.kt | 109 - .../MessageRoutingChannelTest.kt | 2 +- .../MessageRoutingTest.kt | 2 +- .../courier/api/models/send/MessageTest.kt | 643 -- .../models/send/MsTeamsBasePropertiesTest.kt | 35 - .../courier/api/models/send/RecipientTest.kt | 633 +- .../api/models/send/SendMessageParamsTest.kt | 488 - .../models/send/SendMessageResponseTest.kt | 34 - .../models/send/SendSendMessageParamsTest.kt | 666 ++ .../send/SendSendMessageResponseTest.kt | 39 + .../models/send/SlackBasePropertiesTest.kt | 32 - .../com/courier/api/models/send/UtmTest.kt | 47 - .../models/tenants/DefaultPreferencesTest.kt | 63 - .../models/tenants/TenantDeleteParamsTest.kt | 23 - .../models/tenants/TenantListParamsTest.kt | 49 - .../models/tenants/TenantListResponseTest.kt | 144 - .../tenants/TenantListUsersParamsTest.kt | 44 - .../tenants/TenantListUsersResponseTest.kt | 90 - .../tenants/TenantRetrieveParamsTest.kt | 23 - .../courier/api/models/tenants/TenantTest.kt | 116 - .../models/tenants/TenantUpdateParamsTest.kt | 126 - .../items/ItemDeleteParamsTest.kt | 24 - .../items/ItemUpdateParamsTest.kt | 91 - .../items/SubscriptionTopicNewTest.kt | 46 - .../BaseTemplateTenantAssociationTest.kt | 51 - .../templates/ElementalChannelNodeTest.kt | 98 - .../tenants/templates/ElementalContentTest.kt | 72 - .../templates/ElementalGroupNodeTest.kt | 78 - .../tenants/templates/ElementalNodeTest.kt | 450 - .../templates/TemplateListParamsTest.kt | 44 - .../templates/TemplateListResponseTest.kt | 110 - .../templates/TemplateRetrieveParamsTest.kt | 25 - .../TranslationRetrieveParamsTest.kt | 24 - .../TranslationUpdateParamsTest.kt | 35 - .../PreferenceRetrieveParamsTest.kt | 44 - .../PreferenceRetrieveResponseTest.kt | 72 - .../PreferenceRetrieveTopicParamsTest.kt | 55 - .../PreferenceRetrieveTopicResponseTest.kt | 68 - ...PreferenceUpdateOrCreateTopicParamsTest.kt | 141 - ...eferenceUpdateOrCreateTopicResponseTest.kt | 35 - .../users/preferences/TopicPreferenceTest.kt | 56 - .../tenants/TenantAddMultipleParamsTest.kt | 92 - .../tenants/TenantAddSingleParamsTest.kt | 63 - .../users/tenants/TenantAssociationTest.kt | 61 - .../users/tenants/TenantListParamsTest.kt | 43 - .../users/tenants/TenantListResponseTest.kt | 89 - .../tenants/TenantRemoveAllParamsTest.kt | 23 - .../tenants/TenantRemoveSingleParamsTest.kt | 25 - .../tokens/TokenAddMultipleParamsTest.kt | 23 - .../users/tokens/TokenAddSingleParamsTest.kt | 143 - .../users/tokens/TokenDeleteParamsTest.kt | 24 - .../users/tokens/TokenListParamsTest.kt | 23 - .../users/tokens/TokenRetrieveParamsTest.kt | 24 - .../users/tokens/TokenRetrieveResponseTest.kt | 113 - .../users/tokens/TokenUpdateParamsTest.kt | 69 - .../api/models/users/tokens/UserTokenTest.kt | 104 - .../courier/api/services/ErrorHandlingTest.kt | 2421 +++-- .../courier/api/services/ServiceParamsTest.kt | 144 +- .../async/AudienceServiceAsyncTest.kt | 117 - .../async/AuditEventServiceAsyncTest.kt | 47 - .../services/async/AuthServiceAsyncTest.kt | 33 - .../services/async/BrandServiceAsyncTest.kt | 172 - .../services/async/BulkServiceAsyncTest.kt | 385 - .../services/async/InboundServiceAsyncTest.kt | 46 - .../services/async/ListServiceAsyncTest.kt | 156 - .../services/async/MessageServiceAsyncTest.kt | 116 - .../async/NotificationServiceAsyncTest.kt | 49 - .../services/async/ProfileServiceAsyncTest.kt | 127 - .../services/async/RequestServiceAsyncTest.kt | 28 - .../services/async/SendServiceAsyncTest.kt | 145 +- .../services/async/TenantServiceAsyncTest.kt | 143 - .../async/TranslationServiceAsyncTest.kt | 55 - .../automations/InvokeServiceAsyncTest.kt | 99 - .../lists/SubscriptionServiceAsyncTest.kt | 278 - .../notifications/CheckServiceAsyncTest.kt | 83 - .../notifications/DraftServiceAsyncTest.kt | 29 - .../async/profiles/ListServiceAsyncTest.kt | 128 - .../async/tenants/TemplateServiceAsyncTest.kt | 60 - .../ItemServiceAsyncTest.kt | 63 - .../async/users/PreferenceServiceAsyncTest.kt | 91 - .../async/users/TenantServiceAsyncTest.kt | 129 - .../async/users/TokenServiceAsyncTest.kt | 162 - .../services/blocking/AudienceServiceTest.kt | 110 - .../blocking/AuditEventServiceTest.kt | 45 - .../api/services/blocking/AuthServiceTest.kt | 32 - .../api/services/blocking/BrandServiceTest.kt | 165 - .../api/services/blocking/BulkServiceTest.kt | 377 - .../services/blocking/InboundServiceTest.kt | 45 - .../api/services/blocking/ListServiceTest.kt | 138 - .../services/blocking/MessageServiceTest.kt | 111 - .../blocking/NotificationServiceTest.kt | 47 - .../services/blocking/ProfileServiceTest.kt | 115 - .../services/blocking/RequestServiceTest.kt | 26 - .../api/services/blocking/SendServiceTest.kt | 145 +- .../services/blocking/TenantServiceTest.kt | 137 - .../blocking/TranslationServiceTest.kt | 45 - .../blocking/automations/InvokeServiceTest.kt | 97 - .../blocking/lists/SubscriptionServiceTest.kt | 256 - .../notifications/CheckServiceTest.kt | 78 - .../notifications/DraftServiceTest.kt | 28 - .../blocking/profiles/ListServiceTest.kt | 125 - .../blocking/tenants/TemplateServiceTest.kt | 58 - .../defaultpreferences/ItemServiceTest.kt | 57 - .../blocking/users/PreferenceServiceTest.kt | 88 - .../blocking/users/TenantServiceTest.kt | 117 - .../blocking/users/TokenServiceTest.kt | 143 - .../api/proguard/ProGuardCompatibilityTest.kt | 185 +- 493 files changed, 8915 insertions(+), 133186 deletions(-) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/{notifications => send}/MessageRouting.kt (99%) rename courier-java-core/src/main/kotlin/com/courier/api/models/{notifications => send}/MessageRoutingChannel.kt (99%) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt rename courier-java-core/src/main/kotlin/com/courier/api/models/send/{SendMessageResponse.kt => SendSendMessageResponse.kt} (74%) delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt delete mode 100644 courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt rename courier-java-core/src/test/kotlin/com/courier/api/models/{notifications => send}/MessageRoutingChannelTest.kt (98%) rename courier-java-core/src/test/kotlin/com/courier/api/models/{notifications => send}/MessageRoutingTest.kt (96%) delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 2eb4ff1b..8f5c8e4b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 77 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-f2aedc1eadc5dfc25984cacada32b0b603b441282b70c7f246545eeb10e1100f.yml -openapi_spec_hash: 9f40fc40e0269789116564dd953e71ef -config_hash: 13f5653f46b22729d4969d901dbc5c9b +configured_endpoints: 1 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-851bd80e56022cef0ab7c12f24f6ff89aab45140bcc7274810661a344a4541b1.yml +openapi_spec_hash: 302486c729027393a465d01fe9d006eb +config_hash: 16d43e6b36e03e2a6139adae633325a5 diff --git a/README.md b/README.md index ea98fbba..69c1d4b6 100644 --- a/README.md +++ b/README.md @@ -48,27 +48,22 @@ This library requires Java 8 or later. ```java import com.courier.api.client.CourierClient; import com.courier.api.client.okhttp.CourierOkHttpClient; -import com.courier.api.core.JsonValue; -import com.courier.api.models.send.BaseMessage; -import com.courier.api.models.send.BaseMessageSendTo; -import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendMessageParams; -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClient client = CourierOkHttpClient.fromEnv(); -SendMessageParams params = SendMessageParams.builder() - .message(Message.TemplateMessage.builder() - .to(BaseMessageSendTo.To.UnionMember1.builder().build()) - .template("your_template") - .data(BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) +SendSendMessageParams params = SendSendMessageParams.builder() + .message(SendSendMessageParams.Message.builder() + .content(SendSendMessageParams.Message.Content.builder() + .body("body") + .title("title") .build()) .build()) .build(); -SendMessageResponse response = client.send().message(params); +SendSendMessageResponse response = client.send().sendMessage(params); ``` ## Client configuration @@ -141,7 +136,7 @@ The `withOptions()` method does not affect the original client or service. To send a request to the Courier API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.send().message(...)` should be called with an instance of `SendMessageParams`, and it will return an instance of `SendMessageResponse`. +For example, `client.send().sendMessage(...)` should be called with an instance of `SendSendMessageParams`, and it will return an instance of `SendSendMessageResponse`. ## Immutability @@ -158,28 +153,23 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.courier.api.client.CourierClient; import com.courier.api.client.okhttp.CourierOkHttpClient; -import com.courier.api.core.JsonValue; -import com.courier.api.models.send.BaseMessage; -import com.courier.api.models.send.BaseMessageSendTo; -import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendMessageParams; -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; import java.util.concurrent.CompletableFuture; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClient client = CourierOkHttpClient.fromEnv(); -SendMessageParams params = SendMessageParams.builder() - .message(Message.TemplateMessage.builder() - .to(BaseMessageSendTo.To.UnionMember1.builder().build()) - .template("your_template") - .data(BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) +SendSendMessageParams params = SendSendMessageParams.builder() + .message(SendSendMessageParams.Message.builder() + .content(SendSendMessageParams.Message.Content.builder() + .body("body") + .title("title") .build()) .build()) .build(); -CompletableFuture response = client.async().send().message(params); +CompletableFuture response = client.async().send().sendMessage(params); ``` Or create an asynchronous client from the beginning: @@ -187,28 +177,23 @@ Or create an asynchronous client from the beginning: ```java import com.courier.api.client.CourierClientAsync; import com.courier.api.client.okhttp.CourierOkHttpClientAsync; -import com.courier.api.core.JsonValue; -import com.courier.api.models.send.BaseMessage; -import com.courier.api.models.send.BaseMessageSendTo; -import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendMessageParams; -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; import java.util.concurrent.CompletableFuture; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClientAsync client = CourierOkHttpClientAsync.fromEnv(); -SendMessageParams params = SendMessageParams.builder() - .message(Message.TemplateMessage.builder() - .to(BaseMessageSendTo.To.UnionMember1.builder().build()) - .template("your_template") - .data(BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) +SendSendMessageParams params = SendSendMessageParams.builder() + .message(SendSendMessageParams.Message.builder() + .content(SendSendMessageParams.Message.Content.builder() + .body("body") + .title("title") .build()) .build()) .build(); -CompletableFuture response = client.send().message(params); +CompletableFuture response = client.send().sendMessage(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -220,25 +205,20 @@ The SDK defines methods that deserialize responses into instances of Java classe To access this data, prefix any HTTP method call on a client or service with `withRawResponse()`: ```java -import com.courier.api.core.JsonValue; import com.courier.api.core.http.Headers; import com.courier.api.core.http.HttpResponseFor; -import com.courier.api.models.send.BaseMessage; -import com.courier.api.models.send.BaseMessageSendTo; -import com.courier.api.models.send.Message; -import com.courier.api.models.send.SendMessageParams; -import com.courier.api.models.send.SendMessageResponse; - -SendMessageParams params = SendMessageParams.builder() - .message(Message.TemplateMessage.builder() - .to(BaseMessageSendTo.To.UnionMember1.builder().build()) - .template("your_template") - .data(BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) +import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendSendMessageResponse; + +SendSendMessageParams params = SendSendMessageParams.builder() + .message(SendSendMessageParams.Message.builder() + .content(SendSendMessageParams.Message.Content.builder() + .body("body") + .title("title") .build()) .build()) .build(); -HttpResponseFor response = client.send().withRawResponse().message(params); +HttpResponseFor response = client.send().withRawResponse().sendMessage(params); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -247,9 +227,9 @@ Headers headers = response.headers(); You can still deserialize the response into an instance of a Java class if needed: ```java -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageResponse; -SendMessageResponse parsedResponse = response.parse(); +SendSendMessageResponse parsedResponse = response.parse(); ``` ## Error handling @@ -345,9 +325,9 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageResponse; -SendMessageResponse response = client.send().message( +SendSendMessageResponse response = client.send().sendMessage( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() ); ``` @@ -452,9 +432,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendSendMessageParams; -SendMessageParams params = SendMessageParams.builder() +SendSendMessageParams params = SendSendMessageParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -467,10 +447,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams; +import com.courier.api.models.send.SendSendMessageParams; -InvokeInvokeAdHocParams params = InvokeInvokeAdHocParams.builder() - .automation(InvokeInvokeAdHocParams.Automation.builder() +SendSendMessageParams params = SendSendMessageParams.builder() + .message(SendSendMessageParams.Message.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -482,9 +462,9 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendSendMessageParams; -SendMessageParams params = SendMessageParams.builder() +SendSendMessageParams params = SendSendMessageParams.builder() .message(JsonValue.from(42)) .build(); ``` @@ -534,9 +514,9 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](courier- ```java import com.courier.api.core.JsonMissing; -import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendSendMessageParams; -SendMessageParams params = SendMessageParams.builder() +SendSendMessageParams params = SendSendMessageParams.builder() .message(JsonMissing.of()) .build(); ``` @@ -549,7 +529,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.courier.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.send().message(params)._additionalProperties(); +Map additionalProperties = client.send().sendMessage(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -577,10 +557,10 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.courier.api.core.JsonField; -import com.courier.api.models.send.Message; +import com.courier.api.models.send.SendSendMessageParams; import java.util.Optional; -JsonField message = client.send().message(params)._message(); +JsonField message = client.send().sendMessage(params)._message(); if (message.isMissing()) { // The property is absent from the JSON response @@ -605,17 +585,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Co If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageResponse; -SendMessageResponse response = client.send().message(params).validate(); +SendSendMessageResponse response = client.send().sendMessage(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.courier.api.models.send.SendMessageResponse; +import com.courier.api.models.send.SendSendMessageResponse; -SendMessageResponse response = client.send().message( +SendSendMessageResponse response = client.send().sendMessage( params, RequestOptions.builder().responseValidation(true).build() ); ``` diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt index 180e5483..fdb5e7d2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClient.kt @@ -3,22 +3,7 @@ package com.courier.api.client import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.AudienceService -import com.courier.api.services.blocking.AuditEventService -import com.courier.api.services.blocking.AuthService -import com.courier.api.services.blocking.AutomationService -import com.courier.api.services.blocking.BrandService -import com.courier.api.services.blocking.BulkService -import com.courier.api.services.blocking.InboundService -import com.courier.api.services.blocking.ListService -import com.courier.api.services.blocking.MessageService -import com.courier.api.services.blocking.NotificationService -import com.courier.api.services.blocking.ProfileService -import com.courier.api.services.blocking.RequestService import com.courier.api.services.blocking.SendService -import com.courier.api.services.blocking.TenantService -import com.courier.api.services.blocking.TranslationService -import com.courier.api.services.blocking.UserService import java.util.function.Consumer /** @@ -59,36 +44,6 @@ interface CourierClient { fun send(): SendService - fun audiences(): AudienceService - - fun auditEvents(): AuditEventService - - fun auth(): AuthService - - fun automations(): AutomationService - - fun brands(): BrandService - - fun bulk(): BulkService - - fun inbound(): InboundService - - fun lists(): ListService - - fun messages(): MessageService - - fun requests(): RequestService - - fun notifications(): NotificationService - - fun profiles(): ProfileService - - fun tenants(): TenantService - - fun translations(): TranslationService - - fun users(): UserService - /** * Closes this client, relinquishing any underlying resources. * @@ -113,35 +68,5 @@ interface CourierClient { fun withOptions(modifier: Consumer): CourierClient.WithRawResponse fun send(): SendService.WithRawResponse - - fun audiences(): AudienceService.WithRawResponse - - fun auditEvents(): AuditEventService.WithRawResponse - - fun auth(): AuthService.WithRawResponse - - fun automations(): AutomationService.WithRawResponse - - fun brands(): BrandService.WithRawResponse - - fun bulk(): BulkService.WithRawResponse - - fun inbound(): InboundService.WithRawResponse - - fun lists(): ListService.WithRawResponse - - fun messages(): MessageService.WithRawResponse - - fun requests(): RequestService.WithRawResponse - - fun notifications(): NotificationService.WithRawResponse - - fun profiles(): ProfileService.WithRawResponse - - fun tenants(): TenantService.WithRawResponse - - fun translations(): TranslationService.WithRawResponse - - fun users(): UserService.WithRawResponse } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt index c9af54aa..d67e6589 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsync.kt @@ -3,22 +3,7 @@ package com.courier.api.client import com.courier.api.core.ClientOptions -import com.courier.api.services.async.AudienceServiceAsync -import com.courier.api.services.async.AuditEventServiceAsync -import com.courier.api.services.async.AuthServiceAsync -import com.courier.api.services.async.AutomationServiceAsync -import com.courier.api.services.async.BrandServiceAsync -import com.courier.api.services.async.BulkServiceAsync -import com.courier.api.services.async.InboundServiceAsync -import com.courier.api.services.async.ListServiceAsync -import com.courier.api.services.async.MessageServiceAsync -import com.courier.api.services.async.NotificationServiceAsync -import com.courier.api.services.async.ProfileServiceAsync -import com.courier.api.services.async.RequestServiceAsync import com.courier.api.services.async.SendServiceAsync -import com.courier.api.services.async.TenantServiceAsync -import com.courier.api.services.async.TranslationServiceAsync -import com.courier.api.services.async.UserServiceAsync import java.util.function.Consumer /** @@ -59,36 +44,6 @@ interface CourierClientAsync { fun send(): SendServiceAsync - fun audiences(): AudienceServiceAsync - - fun auditEvents(): AuditEventServiceAsync - - fun auth(): AuthServiceAsync - - fun automations(): AutomationServiceAsync - - fun brands(): BrandServiceAsync - - fun bulk(): BulkServiceAsync - - fun inbound(): InboundServiceAsync - - fun lists(): ListServiceAsync - - fun messages(): MessageServiceAsync - - fun requests(): RequestServiceAsync - - fun notifications(): NotificationServiceAsync - - fun profiles(): ProfileServiceAsync - - fun tenants(): TenantServiceAsync - - fun translations(): TranslationServiceAsync - - fun users(): UserServiceAsync - /** * Closes this client, relinquishing any underlying resources. * @@ -117,35 +72,5 @@ interface CourierClientAsync { ): CourierClientAsync.WithRawResponse fun send(): SendServiceAsync.WithRawResponse - - fun audiences(): AudienceServiceAsync.WithRawResponse - - fun auditEvents(): AuditEventServiceAsync.WithRawResponse - - fun auth(): AuthServiceAsync.WithRawResponse - - fun automations(): AutomationServiceAsync.WithRawResponse - - fun brands(): BrandServiceAsync.WithRawResponse - - fun bulk(): BulkServiceAsync.WithRawResponse - - fun inbound(): InboundServiceAsync.WithRawResponse - - fun lists(): ListServiceAsync.WithRawResponse - - fun messages(): MessageServiceAsync.WithRawResponse - - fun requests(): RequestServiceAsync.WithRawResponse - - fun notifications(): NotificationServiceAsync.WithRawResponse - - fun profiles(): ProfileServiceAsync.WithRawResponse - - fun tenants(): TenantServiceAsync.WithRawResponse - - fun translations(): TranslationServiceAsync.WithRawResponse - - fun users(): UserServiceAsync.WithRawResponse } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt index 01a0126c..276614ac 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientAsyncImpl.kt @@ -4,38 +4,8 @@ package com.courier.api.client import com.courier.api.core.ClientOptions import com.courier.api.core.getPackageVersion -import com.courier.api.services.async.AudienceServiceAsync -import com.courier.api.services.async.AudienceServiceAsyncImpl -import com.courier.api.services.async.AuditEventServiceAsync -import com.courier.api.services.async.AuditEventServiceAsyncImpl -import com.courier.api.services.async.AuthServiceAsync -import com.courier.api.services.async.AuthServiceAsyncImpl -import com.courier.api.services.async.AutomationServiceAsync -import com.courier.api.services.async.AutomationServiceAsyncImpl -import com.courier.api.services.async.BrandServiceAsync -import com.courier.api.services.async.BrandServiceAsyncImpl -import com.courier.api.services.async.BulkServiceAsync -import com.courier.api.services.async.BulkServiceAsyncImpl -import com.courier.api.services.async.InboundServiceAsync -import com.courier.api.services.async.InboundServiceAsyncImpl -import com.courier.api.services.async.ListServiceAsync -import com.courier.api.services.async.ListServiceAsyncImpl -import com.courier.api.services.async.MessageServiceAsync -import com.courier.api.services.async.MessageServiceAsyncImpl -import com.courier.api.services.async.NotificationServiceAsync -import com.courier.api.services.async.NotificationServiceAsyncImpl -import com.courier.api.services.async.ProfileServiceAsync -import com.courier.api.services.async.ProfileServiceAsyncImpl -import com.courier.api.services.async.RequestServiceAsync -import com.courier.api.services.async.RequestServiceAsyncImpl import com.courier.api.services.async.SendServiceAsync import com.courier.api.services.async.SendServiceAsyncImpl -import com.courier.api.services.async.TenantServiceAsync -import com.courier.api.services.async.TenantServiceAsyncImpl -import com.courier.api.services.async.TranslationServiceAsync -import com.courier.api.services.async.TranslationServiceAsyncImpl -import com.courier.api.services.async.UserServiceAsync -import com.courier.api.services.async.UserServiceAsyncImpl import java.util.function.Consumer class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : CourierClientAsync { @@ -57,58 +27,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier private val send: SendServiceAsync by lazy { SendServiceAsyncImpl(clientOptionsWithUserAgent) } - private val audiences: AudienceServiceAsync by lazy { - AudienceServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val auditEvents: AuditEventServiceAsync by lazy { - AuditEventServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val auth: AuthServiceAsync by lazy { AuthServiceAsyncImpl(clientOptionsWithUserAgent) } - - private val automations: AutomationServiceAsync by lazy { - AutomationServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val brands: BrandServiceAsync by lazy { - BrandServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val bulk: BulkServiceAsync by lazy { BulkServiceAsyncImpl(clientOptionsWithUserAgent) } - - private val inbound: InboundServiceAsync by lazy { - InboundServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val lists: ListServiceAsync by lazy { ListServiceAsyncImpl(clientOptionsWithUserAgent) } - - private val messages: MessageServiceAsync by lazy { - MessageServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val requests: RequestServiceAsync by lazy { - RequestServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val notifications: NotificationServiceAsync by lazy { - NotificationServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val profiles: ProfileServiceAsync by lazy { - ProfileServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val tenants: TenantServiceAsync by lazy { - TenantServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val translations: TranslationServiceAsync by lazy { - TranslationServiceAsyncImpl(clientOptionsWithUserAgent) - } - - private val users: UserServiceAsync by lazy { UserServiceAsyncImpl(clientOptionsWithUserAgent) } - override fun sync(): CourierClient = sync override fun withRawResponse(): CourierClientAsync.WithRawResponse = withRawResponse @@ -118,36 +36,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier override fun send(): SendServiceAsync = send - override fun audiences(): AudienceServiceAsync = audiences - - override fun auditEvents(): AuditEventServiceAsync = auditEvents - - override fun auth(): AuthServiceAsync = auth - - override fun automations(): AutomationServiceAsync = automations - - override fun brands(): BrandServiceAsync = brands - - override fun bulk(): BulkServiceAsync = bulk - - override fun inbound(): InboundServiceAsync = inbound - - override fun lists(): ListServiceAsync = lists - - override fun messages(): MessageServiceAsync = messages - - override fun requests(): RequestServiceAsync = requests - - override fun notifications(): NotificationServiceAsync = notifications - - override fun profiles(): ProfileServiceAsync = profiles - - override fun tenants(): TenantServiceAsync = tenants - - override fun translations(): TranslationServiceAsync = translations - - override fun users(): UserServiceAsync = users - override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -157,66 +45,6 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier SendServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val audiences: AudienceServiceAsync.WithRawResponse by lazy { - AudienceServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val auditEvents: AuditEventServiceAsync.WithRawResponse by lazy { - AuditEventServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val auth: AuthServiceAsync.WithRawResponse by lazy { - AuthServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val automations: AutomationServiceAsync.WithRawResponse by lazy { - AutomationServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val brands: BrandServiceAsync.WithRawResponse by lazy { - BrandServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val bulk: BulkServiceAsync.WithRawResponse by lazy { - BulkServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val inbound: InboundServiceAsync.WithRawResponse by lazy { - InboundServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val lists: ListServiceAsync.WithRawResponse by lazy { - ListServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val messages: MessageServiceAsync.WithRawResponse by lazy { - MessageServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val requests: RequestServiceAsync.WithRawResponse by lazy { - RequestServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val notifications: NotificationServiceAsync.WithRawResponse by lazy { - NotificationServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val profiles: ProfileServiceAsync.WithRawResponse by lazy { - ProfileServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val tenants: TenantServiceAsync.WithRawResponse by lazy { - TenantServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val translations: TranslationServiceAsync.WithRawResponse by lazy { - TranslationServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val users: UserServiceAsync.WithRawResponse by lazy { - UserServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - override fun withOptions( modifier: Consumer ): CourierClientAsync.WithRawResponse = @@ -225,35 +53,5 @@ class CourierClientAsyncImpl(private val clientOptions: ClientOptions) : Courier ) override fun send(): SendServiceAsync.WithRawResponse = send - - override fun audiences(): AudienceServiceAsync.WithRawResponse = audiences - - override fun auditEvents(): AuditEventServiceAsync.WithRawResponse = auditEvents - - override fun auth(): AuthServiceAsync.WithRawResponse = auth - - override fun automations(): AutomationServiceAsync.WithRawResponse = automations - - override fun brands(): BrandServiceAsync.WithRawResponse = brands - - override fun bulk(): BulkServiceAsync.WithRawResponse = bulk - - override fun inbound(): InboundServiceAsync.WithRawResponse = inbound - - override fun lists(): ListServiceAsync.WithRawResponse = lists - - override fun messages(): MessageServiceAsync.WithRawResponse = messages - - override fun requests(): RequestServiceAsync.WithRawResponse = requests - - override fun notifications(): NotificationServiceAsync.WithRawResponse = notifications - - override fun profiles(): ProfileServiceAsync.WithRawResponse = profiles - - override fun tenants(): TenantServiceAsync.WithRawResponse = tenants - - override fun translations(): TranslationServiceAsync.WithRawResponse = translations - - override fun users(): UserServiceAsync.WithRawResponse = users } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt index 9332ccdc..1b8030c5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/client/CourierClientImpl.kt @@ -4,38 +4,8 @@ package com.courier.api.client import com.courier.api.core.ClientOptions import com.courier.api.core.getPackageVersion -import com.courier.api.services.blocking.AudienceService -import com.courier.api.services.blocking.AudienceServiceImpl -import com.courier.api.services.blocking.AuditEventService -import com.courier.api.services.blocking.AuditEventServiceImpl -import com.courier.api.services.blocking.AuthService -import com.courier.api.services.blocking.AuthServiceImpl -import com.courier.api.services.blocking.AutomationService -import com.courier.api.services.blocking.AutomationServiceImpl -import com.courier.api.services.blocking.BrandService -import com.courier.api.services.blocking.BrandServiceImpl -import com.courier.api.services.blocking.BulkService -import com.courier.api.services.blocking.BulkServiceImpl -import com.courier.api.services.blocking.InboundService -import com.courier.api.services.blocking.InboundServiceImpl -import com.courier.api.services.blocking.ListService -import com.courier.api.services.blocking.ListServiceImpl -import com.courier.api.services.blocking.MessageService -import com.courier.api.services.blocking.MessageServiceImpl -import com.courier.api.services.blocking.NotificationService -import com.courier.api.services.blocking.NotificationServiceImpl -import com.courier.api.services.blocking.ProfileService -import com.courier.api.services.blocking.ProfileServiceImpl -import com.courier.api.services.blocking.RequestService -import com.courier.api.services.blocking.RequestServiceImpl import com.courier.api.services.blocking.SendService import com.courier.api.services.blocking.SendServiceImpl -import com.courier.api.services.blocking.TenantService -import com.courier.api.services.blocking.TenantServiceImpl -import com.courier.api.services.blocking.TranslationService -import com.courier.api.services.blocking.TranslationServiceImpl -import com.courier.api.services.blocking.UserService -import com.courier.api.services.blocking.UserServiceImpl import java.util.function.Consumer class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClient { @@ -57,46 +27,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien private val send: SendService by lazy { SendServiceImpl(clientOptionsWithUserAgent) } - private val audiences: AudienceService by lazy { - AudienceServiceImpl(clientOptionsWithUserAgent) - } - - private val auditEvents: AuditEventService by lazy { - AuditEventServiceImpl(clientOptionsWithUserAgent) - } - - private val auth: AuthService by lazy { AuthServiceImpl(clientOptionsWithUserAgent) } - - private val automations: AutomationService by lazy { - AutomationServiceImpl(clientOptionsWithUserAgent) - } - - private val brands: BrandService by lazy { BrandServiceImpl(clientOptionsWithUserAgent) } - - private val bulk: BulkService by lazy { BulkServiceImpl(clientOptionsWithUserAgent) } - - private val inbound: InboundService by lazy { InboundServiceImpl(clientOptionsWithUserAgent) } - - private val lists: ListService by lazy { ListServiceImpl(clientOptionsWithUserAgent) } - - private val messages: MessageService by lazy { MessageServiceImpl(clientOptionsWithUserAgent) } - - private val requests: RequestService by lazy { RequestServiceImpl(clientOptionsWithUserAgent) } - - private val notifications: NotificationService by lazy { - NotificationServiceImpl(clientOptionsWithUserAgent) - } - - private val profiles: ProfileService by lazy { ProfileServiceImpl(clientOptionsWithUserAgent) } - - private val tenants: TenantService by lazy { TenantServiceImpl(clientOptionsWithUserAgent) } - - private val translations: TranslationService by lazy { - TranslationServiceImpl(clientOptionsWithUserAgent) - } - - private val users: UserService by lazy { UserServiceImpl(clientOptionsWithUserAgent) } - override fun async(): CourierClientAsync = async override fun withRawResponse(): CourierClient.WithRawResponse = withRawResponse @@ -106,36 +36,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien override fun send(): SendService = send - override fun audiences(): AudienceService = audiences - - override fun auditEvents(): AuditEventService = auditEvents - - override fun auth(): AuthService = auth - - override fun automations(): AutomationService = automations - - override fun brands(): BrandService = brands - - override fun bulk(): BulkService = bulk - - override fun inbound(): InboundService = inbound - - override fun lists(): ListService = lists - - override fun messages(): MessageService = messages - - override fun requests(): RequestService = requests - - override fun notifications(): NotificationService = notifications - - override fun profiles(): ProfileService = profiles - - override fun tenants(): TenantService = tenants - - override fun translations(): TranslationService = translations - - override fun users(): UserService = users - override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -145,66 +45,6 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien SendServiceImpl.WithRawResponseImpl(clientOptions) } - private val audiences: AudienceService.WithRawResponse by lazy { - AudienceServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val auditEvents: AuditEventService.WithRawResponse by lazy { - AuditEventServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val auth: AuthService.WithRawResponse by lazy { - AuthServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val automations: AutomationService.WithRawResponse by lazy { - AutomationServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val brands: BrandService.WithRawResponse by lazy { - BrandServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val bulk: BulkService.WithRawResponse by lazy { - BulkServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val inbound: InboundService.WithRawResponse by lazy { - InboundServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val lists: ListService.WithRawResponse by lazy { - ListServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val messages: MessageService.WithRawResponse by lazy { - MessageServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val requests: RequestService.WithRawResponse by lazy { - RequestServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val notifications: NotificationService.WithRawResponse by lazy { - NotificationServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val profiles: ProfileService.WithRawResponse by lazy { - ProfileServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val tenants: TenantService.WithRawResponse by lazy { - TenantServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val translations: TranslationService.WithRawResponse by lazy { - TranslationServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val users: UserService.WithRawResponse by lazy { - UserServiceImpl.WithRawResponseImpl(clientOptions) - } - override fun withOptions( modifier: Consumer ): CourierClient.WithRawResponse = @@ -213,35 +53,5 @@ class CourierClientImpl(private val clientOptions: ClientOptions) : CourierClien ) override fun send(): SendService.WithRawResponse = send - - override fun audiences(): AudienceService.WithRawResponse = audiences - - override fun auditEvents(): AuditEventService.WithRawResponse = auditEvents - - override fun auth(): AuthService.WithRawResponse = auth - - override fun automations(): AutomationService.WithRawResponse = automations - - override fun brands(): BrandService.WithRawResponse = brands - - override fun bulk(): BulkService.WithRawResponse = bulk - - override fun inbound(): InboundService.WithRawResponse = inbound - - override fun lists(): ListService.WithRawResponse = lists - - override fun messages(): MessageService.WithRawResponse = messages - - override fun requests(): RequestService.WithRawResponse = requests - - override fun notifications(): NotificationService.WithRawResponse = notifications - - override fun profiles(): ProfileService.WithRawResponse = profiles - - override fun tenants(): TenantService.WithRawResponse = tenants - - override fun translations(): TranslationService.WithRawResponse = translations - - override fun users(): UserService.WithRawResponse = users } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt b/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt deleted file mode 100644 index e4628b3a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/core/handlers/EmptyHandler.kt +++ /dev/null @@ -1,12 +0,0 @@ -@file:JvmName("EmptyHandler") - -package com.courier.api.core.handlers - -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler - -@JvmSynthetic internal fun emptyHandler(): Handler = EmptyHandlerInternal - -private object EmptyHandlerInternal : Handler { - override fun handle(response: HttpResponse): Void? = null -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt deleted file mode 100644 index d00617ac..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/ChannelPreference.kt +++ /dev/null @@ -1,177 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ChannelPreference -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val channel: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("channel") - @ExcludeMissing - channel: JsonField = JsonMissing.of() - ) : this(channel, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): ChannelClassification = channel.getRequired("channel") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") - @ExcludeMissing - fun _channel(): JsonField = channel - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ChannelPreference]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ChannelPreference]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(channelPreference: ChannelPreference) = apply { - channel = channelPreference.channel - additionalProperties = channelPreference.additionalProperties.toMutableMap() - } - - fun channel(channel: ChannelClassification) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [ChannelClassification] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ChannelPreference]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ChannelPreference = - ChannelPreference( - checkRequired("channel", channel), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ChannelPreference = apply { - if (validated) { - return@apply - } - - channel().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (channel.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChannelPreference && - channel == other.channel && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(channel, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ChannelPreference{channel=$channel, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt deleted file mode 100644 index 86c8d646..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/Rule.kt +++ /dev/null @@ -1,203 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class Rule -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val until: JsonField, - private val start: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("until") @ExcludeMissing until: JsonField = JsonMissing.of(), - @JsonProperty("start") @ExcludeMissing start: JsonField = JsonMissing.of(), - ) : this(until, start, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun until(): String = until.getRequired("until") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun start(): Optional = start.getOptional("start") - - /** - * Returns the raw JSON value of [until]. - * - * Unlike [until], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until - - /** - * Returns the raw JSON value of [start]. - * - * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Rule]. - * - * The following fields are required: - * ```java - * .until() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Rule]. */ - class Builder internal constructor() { - - private var until: JsonField? = null - private var start: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(rule: Rule) = apply { - until = rule.until - start = rule.start - additionalProperties = rule.additionalProperties.toMutableMap() - } - - fun until(until: String) = until(JsonField.of(until)) - - /** - * Sets [Builder.until] to an arbitrary JSON value. - * - * You should usually call [Builder.until] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun until(until: JsonField) = apply { this.until = until } - - fun start(start: String?) = start(JsonField.ofNullable(start)) - - /** Alias for calling [Builder.start] with `start.orElse(null)`. */ - fun start(start: Optional) = start(start.getOrNull()) - - /** - * Sets [Builder.start] to an arbitrary JSON value. - * - * You should usually call [Builder.start] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun start(start: JsonField) = apply { this.start = start } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Rule]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .until() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Rule = - Rule(checkRequired("until", until), start, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Rule = apply { - if (validated) { - return@apply - } - - until() - start() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (until.asKnown().isPresent) 1 else 0) + (if (start.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Rule && - until == other.until && - start == other.start && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(until, start, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Rule{until=$until, start=$start, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt deleted file mode 100644 index 265d41e2..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Audience.kt +++ /dev/null @@ -1,364 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class Audience -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val createdAt: JsonField, - private val description: JsonField, - private val filter: JsonField, - private val name: JsonField, - private val updatedAt: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), - ) : this(id, createdAt, description, filter, name, updatedAt, mutableMapOf()) - - /** - * A unique identifier representing the audience_id - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): String = createdAt.getRequired("created_at") - - /** - * A description of the audience - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun description(): String = description.getRequired("description") - - /** - * The operator to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun filter(): Filter = filter.getRequired("filter") - - /** - * The name of the audience - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updatedAt(): String = updatedAt.getRequired("updated_at") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [filter]. - * - * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Audience]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .description() - * .filter() - * .name() - * .updatedAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Audience]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var description: JsonField? = null - private var filter: JsonField? = null - private var name: JsonField? = null - private var updatedAt: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(audience: Audience) = apply { - id = audience.id - createdAt = audience.createdAt - description = audience.description - filter = audience.filter - name = audience.name - updatedAt = audience.updatedAt - additionalProperties = audience.additionalProperties.toMutableMap() - } - - /** A unique identifier representing the audience_id */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** A description of the audience */ - fun description(description: String) = description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun description(description: JsonField) = apply { this.description = description } - - /** The operator to use for filtering */ - fun filter(filter: Filter) = filter(JsonField.of(filter)) - - /** - * Sets [Builder.filter] to an arbitrary JSON value. - * - * You should usually call [Builder.filter] with a well-typed [Filter] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** Alias for calling [filter] with `Filter.ofUnionMember0(unionMember0)`. */ - fun filter(unionMember0: Filter.UnionMember0) = filter(Filter.ofUnionMember0(unionMember0)) - - /** Alias for calling [filter] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. */ - fun filter(nestedFilterConfig: NestedFilterConfig) = - filter(Filter.ofNestedFilterConfig(nestedFilterConfig)) - - /** The name of the audience */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Audience]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .description() - * .filter() - * .name() - * .updatedAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Audience = - Audience( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("description", description), - checkRequired("filter", filter), - checkRequired("name", name), - checkRequired("updatedAt", updatedAt), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Audience = apply { - if (validated) { - return@apply - } - - id() - createdAt() - description() - filter().validate() - name() - updatedAt() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (filter.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Audience && - id == other.id && - createdAt == other.createdAt && - description == other.description && - filter == other.filter && - name == other.name && - updatedAt == other.updatedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, description, filter, name, updatedAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Audience{id=$id, createdAt=$createdAt, description=$description, filter=$filter, name=$name, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt deleted file mode 100644 index 913ee5cb..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Deletes the specified audience. */ -class AudienceDeleteParams -private constructor( - private val audienceId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun audienceId(): Optional = Optional.ofNullable(audienceId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AudienceDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AudienceDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceDeleteParams]. */ - class Builder internal constructor() { - - private var audienceId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(audienceDeleteParams: AudienceDeleteParams) = apply { - audienceId = audienceDeleteParams.audienceId - additionalHeaders = audienceDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = audienceDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = audienceDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } - - /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ - fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [AudienceDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AudienceDeleteParams = - AudienceDeleteParams( - audienceId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> audienceId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceDeleteParams && - audienceId == other.audienceId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(audienceId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "AudienceDeleteParams{audienceId=$audienceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt deleted file mode 100644 index 828b67d6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersParams.kt +++ /dev/null @@ -1,216 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get list of members of an audience. */ -class AudienceListMembersParams -private constructor( - private val audienceId: String?, - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun audienceId(): Optional = Optional.ofNullable(audienceId) - - /** A unique identifier that allows for fetching the next set of members */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AudienceListMembersParams = builder().build() - - /** - * Returns a mutable builder for constructing an instance of [AudienceListMembersParams]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceListMembersParams]. */ - class Builder internal constructor() { - - private var audienceId: String? = null - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(audienceListMembersParams: AudienceListMembersParams) = apply { - audienceId = audienceListMembersParams.audienceId - cursor = audienceListMembersParams.cursor - additionalHeaders = audienceListMembersParams.additionalHeaders.toBuilder() - additionalQueryParams = audienceListMembersParams.additionalQueryParams.toBuilder() - } - - fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } - - /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ - fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) - - /** A unique identifier that allows for fetching the next set of members */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AudienceListMembersParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AudienceListMembersParams = - AudienceListMembersParams( - audienceId, - cursor, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> audienceId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceListMembersParams && - audienceId == other.audienceId && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(audienceId, cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AudienceListMembersParams{audienceId=$audienceId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt deleted file mode 100644 index 3f048565..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListMembersResponse.kt +++ /dev/null @@ -1,538 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class AudienceListMembersResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AudienceListMembersResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceListMembersResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(audienceListMembersResponse: AudienceListMembersResponse) = apply { - items = audienceListMembersResponse.items.map { it.toMutableList() } - paging = audienceListMembersResponse.paging - additionalProperties = audienceListMembersResponse.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Item] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Item) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AudienceListMembersResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AudienceListMembersResponse = - AudienceListMembersResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AudienceListMembersResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val addedAt: JsonField, - private val audienceId: JsonField, - private val audienceVersion: JsonField, - private val memberId: JsonField, - private val reason: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("added_at") @ExcludeMissing addedAt: JsonField = JsonMissing.of(), - @JsonProperty("audience_id") - @ExcludeMissing - audienceId: JsonField = JsonMissing.of(), - @JsonProperty("audience_version") - @ExcludeMissing - audienceVersion: JsonField = JsonMissing.of(), - @JsonProperty("member_id") - @ExcludeMissing - memberId: JsonField = JsonMissing.of(), - @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), - ) : this(addedAt, audienceId, audienceVersion, memberId, reason, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun addedAt(): String = addedAt.getRequired("added_at") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun audienceId(): String = audienceId.getRequired("audience_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun audienceVersion(): Long = audienceVersion.getRequired("audience_version") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun memberId(): String = memberId.getRequired("member_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun reason(): String = reason.getRequired("reason") - - /** - * Returns the raw JSON value of [addedAt]. - * - * Unlike [addedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("added_at") @ExcludeMissing fun _addedAt(): JsonField = addedAt - - /** - * Returns the raw JSON value of [audienceId]. - * - * Unlike [audienceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("audience_id") - @ExcludeMissing - fun _audienceId(): JsonField = audienceId - - /** - * Returns the raw JSON value of [audienceVersion]. - * - * Unlike [audienceVersion], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("audience_version") - @ExcludeMissing - fun _audienceVersion(): JsonField = audienceVersion - - /** - * Returns the raw JSON value of [memberId]. - * - * Unlike [memberId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("member_id") @ExcludeMissing fun _memberId(): JsonField = memberId - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Item]. - * - * The following fields are required: - * ```java - * .addedAt() - * .audienceId() - * .audienceVersion() - * .memberId() - * .reason() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var addedAt: JsonField? = null - private var audienceId: JsonField? = null - private var audienceVersion: JsonField? = null - private var memberId: JsonField? = null - private var reason: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - addedAt = item.addedAt - audienceId = item.audienceId - audienceVersion = item.audienceVersion - memberId = item.memberId - reason = item.reason - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun addedAt(addedAt: String) = addedAt(JsonField.of(addedAt)) - - /** - * Sets [Builder.addedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.addedAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun addedAt(addedAt: JsonField) = apply { this.addedAt = addedAt } - - fun audienceId(audienceId: String) = audienceId(JsonField.of(audienceId)) - - /** - * Sets [Builder.audienceId] to an arbitrary JSON value. - * - * You should usually call [Builder.audienceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun audienceId(audienceId: JsonField) = apply { this.audienceId = audienceId } - - fun audienceVersion(audienceVersion: Long) = - audienceVersion(JsonField.of(audienceVersion)) - - /** - * Sets [Builder.audienceVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.audienceVersion] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun audienceVersion(audienceVersion: JsonField) = apply { - this.audienceVersion = audienceVersion - } - - fun memberId(memberId: String) = memberId(JsonField.of(memberId)) - - /** - * Sets [Builder.memberId] to an arbitrary JSON value. - * - * You should usually call [Builder.memberId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun memberId(memberId: JsonField) = apply { this.memberId = memberId } - - fun reason(reason: String) = reason(JsonField.of(reason)) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .addedAt() - * .audienceId() - * .audienceVersion() - * .memberId() - * .reason() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - checkRequired("addedAt", addedAt), - checkRequired("audienceId", audienceId), - checkRequired("audienceVersion", audienceVersion), - checkRequired("memberId", memberId), - checkRequired("reason", reason), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - addedAt() - audienceId() - audienceVersion() - memberId() - reason() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (addedAt.asKnown().isPresent) 1 else 0) + - (if (audienceId.asKnown().isPresent) 1 else 0) + - (if (audienceVersion.asKnown().isPresent) 1 else 0) + - (if (memberId.asKnown().isPresent) 1 else 0) + - (if (reason.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - addedAt == other.addedAt && - audienceId == other.audienceId && - audienceVersion == other.audienceVersion && - memberId == other.memberId && - reason == other.reason && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - addedAt, - audienceId, - audienceVersion, - memberId, - reason, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{addedAt=$addedAt, audienceId=$audienceId, audienceVersion=$audienceVersion, memberId=$memberId, reason=$reason, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceListMembersResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AudienceListMembersResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt deleted file mode 100644 index da6a10dc..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListParams.kt +++ /dev/null @@ -1,191 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get the audiences associated with the authorization token. */ -class AudienceListParams -private constructor( - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** A unique identifier that allows for fetching the next set of audiences */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AudienceListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AudienceListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceListParams]. */ - class Builder internal constructor() { - - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(audienceListParams: AudienceListParams) = apply { - cursor = audienceListParams.cursor - additionalHeaders = audienceListParams.additionalHeaders.toBuilder() - additionalQueryParams = audienceListParams.additionalQueryParams.toBuilder() - } - - /** A unique identifier that allows for fetching the next set of audiences */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AudienceListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AudienceListParams = - AudienceListParams(cursor, additionalHeaders.build(), additionalQueryParams.build()) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceListParams && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AudienceListParams{cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt deleted file mode 100644 index 63852dcc..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceListResponse.kt +++ /dev/null @@ -1,221 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class AudienceListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AudienceListResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceListResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(audienceListResponse: AudienceListResponse) = apply { - items = audienceListResponse.items.map { it.toMutableList() } - paging = audienceListResponse.paging - additionalProperties = audienceListResponse.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Audience] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Audience) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AudienceListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AudienceListResponse = - AudienceListResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AudienceListResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceListResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AudienceListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt deleted file mode 100644 index af099647..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceRetrieveParams.kt +++ /dev/null @@ -1,194 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns the specified audience by id. */ -class AudienceRetrieveParams -private constructor( - private val audienceId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun audienceId(): Optional = Optional.ofNullable(audienceId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AudienceRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AudienceRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceRetrieveParams]. */ - class Builder internal constructor() { - - private var audienceId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(audienceRetrieveParams: AudienceRetrieveParams) = apply { - audienceId = audienceRetrieveParams.audienceId - additionalHeaders = audienceRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = audienceRetrieveParams.additionalQueryParams.toBuilder() - } - - fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } - - /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ - fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AudienceRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AudienceRetrieveParams = - AudienceRetrieveParams( - audienceId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> audienceId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceRetrieveParams && - audienceId == other.audienceId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(audienceId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AudienceRetrieveParams{audienceId=$audienceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt deleted file mode 100644 index 6aabb901..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateParams.kt +++ /dev/null @@ -1,577 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Creates or updates audience. */ -class AudienceUpdateParams -private constructor( - private val audienceId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun audienceId(): Optional = Optional.ofNullable(audienceId) - - /** - * A description of the audience - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = body.description() - - /** - * The operator to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun filter(): Optional = body.filter() - - /** - * The name of the audience - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = body.name() - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _description(): JsonField = body._description() - - /** - * Returns the raw JSON value of [filter]. - * - * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _filter(): JsonField = body._filter() - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _name(): JsonField = body._name() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AudienceUpdateParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AudienceUpdateParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceUpdateParams]. */ - class Builder internal constructor() { - - private var audienceId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(audienceUpdateParams: AudienceUpdateParams) = apply { - audienceId = audienceUpdateParams.audienceId - body = audienceUpdateParams.body.toBuilder() - additionalHeaders = audienceUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = audienceUpdateParams.additionalQueryParams.toBuilder() - } - - fun audienceId(audienceId: String?) = apply { this.audienceId = audienceId } - - /** Alias for calling [Builder.audienceId] with `audienceId.orElse(null)`. */ - fun audienceId(audienceId: Optional) = audienceId(audienceId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [description] - * - [filter] - * - [name] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** A description of the audience */ - fun description(description: String?) = apply { body.description(description) } - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun description(description: JsonField) = apply { body.description(description) } - - /** The operator to use for filtering */ - fun filter(filter: Filter?) = apply { body.filter(filter) } - - /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ - fun filter(filter: Optional) = filter(filter.getOrNull()) - - /** - * Sets [Builder.filter] to an arbitrary JSON value. - * - * You should usually call [Builder.filter] with a well-typed [Filter] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun filter(filter: JsonField) = apply { body.filter(filter) } - - /** Alias for calling [filter] with `Filter.ofUnionMember0(unionMember0)`. */ - fun filter(unionMember0: Filter.UnionMember0) = apply { body.filter(unionMember0) } - - /** Alias for calling [filter] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. */ - fun filter(nestedFilterConfig: NestedFilterConfig) = apply { - body.filter(nestedFilterConfig) - } - - /** The name of the audience */ - fun name(name: String?) = apply { body.name(name) } - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { body.name(name) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AudienceUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AudienceUpdateParams = - AudienceUpdateParams( - audienceId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> audienceId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val description: JsonField, - private val filter: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("filter") @ExcludeMissing filter: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(description, filter, name, mutableMapOf()) - - /** - * A description of the audience - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * The operator to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun filter(): Optional = filter.getOptional("filter") - - /** - * The name of the audience - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [filter]. - * - * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var description: JsonField = JsonMissing.of() - private var filter: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - description = body.description - filter = body.filter - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** A description of the audience */ - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** The operator to use for filtering */ - fun filter(filter: Filter?) = filter(JsonField.ofNullable(filter)) - - /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ - fun filter(filter: Optional) = filter(filter.getOrNull()) - - /** - * Sets [Builder.filter] to an arbitrary JSON value. - * - * You should usually call [Builder.filter] with a well-typed [Filter] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun filter(filter: JsonField) = apply { this.filter = filter } - - /** Alias for calling [filter] with `Filter.ofUnionMember0(unionMember0)`. */ - fun filter(unionMember0: Filter.UnionMember0) = - filter(Filter.ofUnionMember0(unionMember0)) - - /** - * Alias for calling [filter] with `Filter.ofNestedFilterConfig(nestedFilterConfig)`. - */ - fun filter(nestedFilterConfig: NestedFilterConfig) = - filter(Filter.ofNestedFilterConfig(nestedFilterConfig)) - - /** The name of the audience */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(description, filter, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - description() - filter().ifPresent { it.validate() } - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (description.asKnown().isPresent) 1 else 0) + - (filter.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - description == other.description && - filter == other.filter && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(description, filter, name, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{description=$description, filter=$filter, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceUpdateParams && - audienceId == other.audienceId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(audienceId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AudienceUpdateParams{audienceId=$audienceId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt deleted file mode 100644 index 103d0ec4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/AudienceUpdateResponse.kt +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class AudienceUpdateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val audience: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("audience") @ExcludeMissing audience: JsonField = JsonMissing.of() - ) : this(audience, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun audience(): Audience = audience.getRequired("audience") - - /** - * Returns the raw JSON value of [audience]. - * - * Unlike [audience], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("audience") @ExcludeMissing fun _audience(): JsonField = audience - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AudienceUpdateResponse]. - * - * The following fields are required: - * ```java - * .audience() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceUpdateResponse]. */ - class Builder internal constructor() { - - private var audience: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(audienceUpdateResponse: AudienceUpdateResponse) = apply { - audience = audienceUpdateResponse.audience - additionalProperties = audienceUpdateResponse.additionalProperties.toMutableMap() - } - - fun audience(audience: Audience) = audience(JsonField.of(audience)) - - /** - * Sets [Builder.audience] to an arbitrary JSON value. - * - * You should usually call [Builder.audience] with a well-typed [Audience] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun audience(audience: JsonField) = apply { this.audience = audience } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AudienceUpdateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .audience() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AudienceUpdateResponse = - AudienceUpdateResponse( - checkRequired("audience", audience), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AudienceUpdateResponse = apply { - if (validated) { - return@apply - } - - audience().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (audience.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceUpdateResponse && - audience == other.audience && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(audience, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AudienceUpdateResponse{audience=$audience, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt deleted file mode 100644 index 80e05a56..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Filter.kt +++ /dev/null @@ -1,660 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** The operator to use for filtering */ -@JsonDeserialize(using = Filter.Deserializer::class) -@JsonSerialize(using = Filter.Serializer::class) -class Filter -private constructor( - private val unionMember0: UnionMember0? = null, - private val nestedFilterConfig: NestedFilterConfig? = null, - private val _json: JsonValue? = null, -) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - /** The operator to use for filtering */ - fun nestedFilterConfig(): Optional = Optional.ofNullable(nestedFilterConfig) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isNestedFilterConfig(): Boolean = nestedFilterConfig != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - /** The operator to use for filtering */ - fun asNestedFilterConfig(): NestedFilterConfig = - nestedFilterConfig.getOrThrow("nestedFilterConfig") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - nestedFilterConfig != null -> visitor.visitNestedFilterConfig(nestedFilterConfig) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitNestedFilterConfig(nestedFilterConfig: NestedFilterConfig) { - nestedFilterConfig.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - - override fun visitNestedFilterConfig(nestedFilterConfig: NestedFilterConfig) = - nestedFilterConfig.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - unionMember0 == other.unionMember0 && - nestedFilterConfig == other.nestedFilterConfig - } - - override fun hashCode(): Int = Objects.hash(unionMember0, nestedFilterConfig) - - override fun toString(): String = - when { - unionMember0 != null -> "Filter{unionMember0=$unionMember0}" - nestedFilterConfig != null -> "Filter{nestedFilterConfig=$nestedFilterConfig}" - _json != null -> "Filter{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Filter") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = Filter(unionMember0 = unionMember0) - - /** The operator to use for filtering */ - @JvmStatic - fun ofNestedFilterConfig(nestedFilterConfig: NestedFilterConfig) = - Filter(nestedFilterConfig = nestedFilterConfig) - } - - /** An interface that defines how to map each variant of [Filter] to a value of type [T]. */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - /** The operator to use for filtering */ - fun visitNestedFilterConfig(nestedFilterConfig: NestedFilterConfig): T - - /** - * Maps an unknown variant of [Filter] to a value of type [T]. - * - * An instance of [Filter] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Filter: $json") - } - } - - internal class Deserializer : BaseDeserializer(Filter::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Filter { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Filter(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Filter(nestedFilterConfig = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> Filter(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Filter::class) { - - override fun serialize( - value: Filter, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.nestedFilterConfig != null -> generator.writeObject(value.nestedFilterConfig) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Filter") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val operator: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(operator, path, value, mutableMapOf()) - - /** - * The operator to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * The attribe name from profile whose value will be operated against the filter value - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun path(): String = path.getRequired("path") - - /** - * The value to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember0]. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var operator: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - operator = unionMember0.operator - path = unionMember0.path - value = unionMember0.value - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - /** The operator to use for filtering */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** - * The attribe name from profile whose value will be operated against the filter value - */ - fun path(path: String) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun path(path: JsonField) = apply { this.path = path } - - /** The value to use for filtering */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember0 = - UnionMember0( - checkRequired("operator", operator), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - operator().validate() - path() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (if (path.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The operator to use for filtering */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ENDS_WITH = of("ENDS_WITH") - - @JvmField val EQ = of("EQ") - - @JvmField val EXISTS = of("EXISTS") - - @JvmField val GT = of("GT") - - @JvmField val GTE = of("GTE") - - @JvmField val INCLUDES = of("INCLUDES") - - @JvmField val IS_AFTER = of("IS_AFTER") - - @JvmField val IS_BEFORE = of("IS_BEFORE") - - @JvmField val LT = of("LT") - - @JvmField val LTE = of("LTE") - - @JvmField val NEQ = of("NEQ") - - @JvmField val OMIT = of("OMIT") - - @JvmField val STARTS_WITH = of("STARTS_WITH") - - @JvmField val AND = of("AND") - - @JvmField val OR = of("OR") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - ENDS_WITH, - EQ, - EXISTS, - GT, - GTE, - INCLUDES, - IS_AFTER, - IS_BEFORE, - LT, - LTE, - NEQ, - OMIT, - STARTS_WITH, - AND, - OR, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ENDS_WITH, - EQ, - EXISTS, - GT, - GTE, - INCLUDES, - IS_AFTER, - IS_BEFORE, - LT, - LTE, - NEQ, - OMIT, - STARTS_WITH, - AND, - OR, - /** - * An enum member indicating that [Operator] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ENDS_WITH -> Value.ENDS_WITH - EQ -> Value.EQ - EXISTS -> Value.EXISTS - GT -> Value.GT - GTE -> Value.GTE - INCLUDES -> Value.INCLUDES - IS_AFTER -> Value.IS_AFTER - IS_BEFORE -> Value.IS_BEFORE - LT -> Value.LT - LTE -> Value.LTE - NEQ -> Value.NEQ - OMIT -> Value.OMIT - STARTS_WITH -> Value.STARTS_WITH - AND -> Value.AND - OR -> Value.OR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ENDS_WITH -> Known.ENDS_WITH - EQ -> Known.EQ - EXISTS -> Known.EXISTS - GT -> Known.GT - GTE -> Known.GTE - INCLUDES -> Known.INCLUDES - IS_AFTER -> Known.IS_AFTER - IS_BEFORE -> Known.IS_BEFORE - LT -> Known.LT - LTE -> Known.LTE - NEQ -> Known.NEQ - OMIT -> Known.OMIT - STARTS_WITH -> Known.STARTS_WITH - AND -> Known.AND - OR -> Known.OR - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - operator == other.operator && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(operator, path, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt deleted file mode 100644 index d48f3590..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/FilterConfig.kt +++ /dev/null @@ -1,656 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** The operator to use for filtering */ -@JsonDeserialize(using = FilterConfig.Deserializer::class) -@JsonSerialize(using = FilterConfig.Serializer::class) -class FilterConfig -private constructor( - private val unionMember0: UnionMember0? = null, - private val nested: NestedFilterConfig? = null, - private val _json: JsonValue? = null, -) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - /** The operator to use for filtering */ - fun nested(): Optional = Optional.ofNullable(nested) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isNested(): Boolean = nested != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - /** The operator to use for filtering */ - fun asNested(): NestedFilterConfig = nested.getOrThrow("nested") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - nested != null -> visitor.visitNested(nested) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): FilterConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitNested(nested: NestedFilterConfig) { - nested.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - - override fun visitNested(nested: NestedFilterConfig) = nested.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is FilterConfig && unionMember0 == other.unionMember0 && nested == other.nested - } - - override fun hashCode(): Int = Objects.hash(unionMember0, nested) - - override fun toString(): String = - when { - unionMember0 != null -> "FilterConfig{unionMember0=$unionMember0}" - nested != null -> "FilterConfig{nested=$nested}" - _json != null -> "FilterConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid FilterConfig") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = FilterConfig(unionMember0 = unionMember0) - - /** The operator to use for filtering */ - @JvmStatic fun ofNested(nested: NestedFilterConfig) = FilterConfig(nested = nested) - } - - /** - * An interface that defines how to map each variant of [FilterConfig] to a value of type [T]. - */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - /** The operator to use for filtering */ - fun visitNested(nested: NestedFilterConfig): T - - /** - * Maps an unknown variant of [FilterConfig] to a value of type [T]. - * - * An instance of [FilterConfig] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown FilterConfig: $json") - } - } - - internal class Deserializer : BaseDeserializer(FilterConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): FilterConfig { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - FilterConfig(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - FilterConfig(nested = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> FilterConfig(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(FilterConfig::class) { - - override fun serialize( - value: FilterConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.nested != null -> generator.writeObject(value.nested) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid FilterConfig") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val operator: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(operator, path, value, mutableMapOf()) - - /** - * The operator to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * The attribe name from profile whose value will be operated against the filter value - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun path(): String = path.getRequired("path") - - /** - * The value to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember0]. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var operator: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - operator = unionMember0.operator - path = unionMember0.path - value = unionMember0.value - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - /** The operator to use for filtering */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - /** - * The attribe name from profile whose value will be operated against the filter value - */ - fun path(path: String) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun path(path: JsonField) = apply { this.path = path } - - /** The value to use for filtering */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember0 = - UnionMember0( - checkRequired("operator", operator), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - operator().validate() - path() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (if (path.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** The operator to use for filtering */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ENDS_WITH = of("ENDS_WITH") - - @JvmField val EQ = of("EQ") - - @JvmField val EXISTS = of("EXISTS") - - @JvmField val GT = of("GT") - - @JvmField val GTE = of("GTE") - - @JvmField val INCLUDES = of("INCLUDES") - - @JvmField val IS_AFTER = of("IS_AFTER") - - @JvmField val IS_BEFORE = of("IS_BEFORE") - - @JvmField val LT = of("LT") - - @JvmField val LTE = of("LTE") - - @JvmField val NEQ = of("NEQ") - - @JvmField val OMIT = of("OMIT") - - @JvmField val STARTS_WITH = of("STARTS_WITH") - - @JvmField val AND = of("AND") - - @JvmField val OR = of("OR") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - ENDS_WITH, - EQ, - EXISTS, - GT, - GTE, - INCLUDES, - IS_AFTER, - IS_BEFORE, - LT, - LTE, - NEQ, - OMIT, - STARTS_WITH, - AND, - OR, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ENDS_WITH, - EQ, - EXISTS, - GT, - GTE, - INCLUDES, - IS_AFTER, - IS_BEFORE, - LT, - LTE, - NEQ, - OMIT, - STARTS_WITH, - AND, - OR, - /** - * An enum member indicating that [Operator] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ENDS_WITH -> Value.ENDS_WITH - EQ -> Value.EQ - EXISTS -> Value.EXISTS - GT -> Value.GT - GTE -> Value.GTE - INCLUDES -> Value.INCLUDES - IS_AFTER -> Value.IS_AFTER - IS_BEFORE -> Value.IS_BEFORE - LT -> Value.LT - LTE -> Value.LTE - NEQ -> Value.NEQ - OMIT -> Value.OMIT - STARTS_WITH -> Value.STARTS_WITH - AND -> Value.AND - OR -> Value.OR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ENDS_WITH -> Known.ENDS_WITH - EQ -> Known.EQ - EXISTS -> Known.EXISTS - GT -> Known.GT - GTE -> Known.GTE - INCLUDES -> Known.INCLUDES - IS_AFTER -> Known.IS_AFTER - IS_BEFORE -> Known.IS_BEFORE - LT -> Known.LT - LTE -> Known.LTE - NEQ -> Known.NEQ - OMIT -> Known.OMIT - STARTS_WITH -> Known.STARTS_WITH - AND -> Known.AND - OR -> Known.OR - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - operator == other.operator && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(operator, path, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt deleted file mode 100644 index 441d786d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/NestedFilterConfig.kt +++ /dev/null @@ -1,439 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class NestedFilterConfig -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val operator: JsonField, - private val rules: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("operator") @ExcludeMissing operator: JsonField = JsonMissing.of(), - @JsonProperty("rules") - @ExcludeMissing - rules: JsonField> = JsonMissing.of(), - ) : this(operator, rules, mutableMapOf()) - - /** - * The operator to use for filtering - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun rules(): List = rules.getRequired("rules") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("operator") @ExcludeMissing fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [rules]. - * - * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NestedFilterConfig]. - * - * The following fields are required: - * ```java - * .operator() - * .rules() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NestedFilterConfig]. */ - class Builder internal constructor() { - - private var operator: JsonField? = null - private var rules: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(nestedFilterConfig: NestedFilterConfig) = apply { - operator = nestedFilterConfig.operator - rules = nestedFilterConfig.rules.map { it.toMutableList() } - additionalProperties = nestedFilterConfig.additionalProperties.toMutableMap() - } - - /** The operator to use for filtering */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - fun rules(rules: List) = rules(JsonField.of(rules)) - - /** - * Sets [Builder.rules] to an arbitrary JSON value. - * - * You should usually call [Builder.rules] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun rules(rules: JsonField>) = apply { - this.rules = rules.map { it.toMutableList() } - } - - /** - * Adds a single [FilterConfig] to [rules]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRule(rule: FilterConfig) = apply { - rules = - (rules ?: JsonField.of(mutableListOf())).also { checkKnown("rules", it).add(rule) } - } - - /** Alias for calling [addRule] with `FilterConfig.ofUnionMember0(unionMember0)`. */ - fun addRule(unionMember0: FilterConfig.UnionMember0) = - addRule(FilterConfig.ofUnionMember0(unionMember0)) - - /** Alias for calling [addRule] with `FilterConfig.ofNested(nested)`. */ - fun addRule(nested: NestedFilterConfig) = addRule(FilterConfig.ofNested(nested)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NestedFilterConfig]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .rules() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NestedFilterConfig = - NestedFilterConfig( - checkRequired("operator", operator), - checkRequired("rules", rules).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NestedFilterConfig = apply { - if (validated) { - return@apply - } - - operator().validate() - rules().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** The operator to use for filtering */ - class Operator @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ENDS_WITH = of("ENDS_WITH") - - @JvmField val EQ = of("EQ") - - @JvmField val EXISTS = of("EXISTS") - - @JvmField val GT = of("GT") - - @JvmField val GTE = of("GTE") - - @JvmField val INCLUDES = of("INCLUDES") - - @JvmField val IS_AFTER = of("IS_AFTER") - - @JvmField val IS_BEFORE = of("IS_BEFORE") - - @JvmField val LT = of("LT") - - @JvmField val LTE = of("LTE") - - @JvmField val NEQ = of("NEQ") - - @JvmField val OMIT = of("OMIT") - - @JvmField val STARTS_WITH = of("STARTS_WITH") - - @JvmField val AND = of("AND") - - @JvmField val OR = of("OR") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - ENDS_WITH, - EQ, - EXISTS, - GT, - GTE, - INCLUDES, - IS_AFTER, - IS_BEFORE, - LT, - LTE, - NEQ, - OMIT, - STARTS_WITH, - AND, - OR, - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ENDS_WITH, - EQ, - EXISTS, - GT, - GTE, - INCLUDES, - IS_AFTER, - IS_BEFORE, - LT, - LTE, - NEQ, - OMIT, - STARTS_WITH, - AND, - OR, - /** An enum member indicating that [Operator] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ENDS_WITH -> Value.ENDS_WITH - EQ -> Value.EQ - EXISTS -> Value.EXISTS - GT -> Value.GT - GTE -> Value.GTE - INCLUDES -> Value.INCLUDES - IS_AFTER -> Value.IS_AFTER - IS_BEFORE -> Value.IS_BEFORE - LT -> Value.LT - LTE -> Value.LTE - NEQ -> Value.NEQ - OMIT -> Value.OMIT - STARTS_WITH -> Value.STARTS_WITH - AND -> Value.AND - OR -> Value.OR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ENDS_WITH -> Known.ENDS_WITH - EQ -> Known.EQ - EXISTS -> Known.EXISTS - GT -> Known.GT - GTE -> Known.GTE - INCLUDES -> Known.INCLUDES - IS_AFTER -> Known.IS_AFTER - IS_BEFORE -> Known.IS_BEFORE - LT -> Known.LT - LTE -> Known.LTE - NEQ -> Known.NEQ - OMIT -> Known.OMIT - STARTS_WITH -> Known.STARTS_WITH - AND -> Known.AND - OR -> Known.OR - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NestedFilterConfig && - operator == other.operator && - rules == other.rules && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(operator, rules, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NestedFilterConfig{operator=$operator, rules=$rules, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt deleted file mode 100644 index c4aa366b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/audiences/Paging.kt +++ /dev/null @@ -1,203 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class Paging -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val more: JsonField, - private val cursor: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("more") @ExcludeMissing more: JsonField = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), - ) : this(more, cursor, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun more(): Boolean = more.getRequired("more") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cursor(): Optional = cursor.getOptional("cursor") - - /** - * Returns the raw JSON value of [more]. - * - * Unlike [more], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("more") @ExcludeMissing fun _more(): JsonField = more - - /** - * Returns the raw JSON value of [cursor]. - * - * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Paging]. - * - * The following fields are required: - * ```java - * .more() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Paging]. */ - class Builder internal constructor() { - - private var more: JsonField? = null - private var cursor: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(paging: Paging) = apply { - more = paging.more - cursor = paging.cursor - additionalProperties = paging.additionalProperties.toMutableMap() - } - - fun more(more: Boolean) = more(JsonField.of(more)) - - /** - * Sets [Builder.more] to an arbitrary JSON value. - * - * You should usually call [Builder.more] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun more(more: JsonField) = apply { this.more = more } - - fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** - * Sets [Builder.cursor] to an arbitrary JSON value. - * - * You should usually call [Builder.cursor] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Paging]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .more() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Paging = - Paging(checkRequired("more", more), cursor, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Paging = apply { - if (validated) { - return@apply - } - - more() - cursor() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (more.asKnown().isPresent) 1 else 0) + (if (cursor.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Paging && - more == other.more && - cursor == other.cursor && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(more, cursor, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Paging{more=$more, cursor=$cursor, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt deleted file mode 100644 index 693e852b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEvent.kt +++ /dev/null @@ -1,703 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class AuditEvent -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val auditEventId: JsonField, - private val source: JsonField, - private val timestamp: JsonField, - private val type: JsonField, - private val actor: JsonField, - private val target: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("auditEventId") - @ExcludeMissing - auditEventId: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - @JsonProperty("timestamp") @ExcludeMissing timestamp: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("actor") @ExcludeMissing actor: JsonField = JsonMissing.of(), - @JsonProperty("target") @ExcludeMissing target: JsonField = JsonMissing.of(), - ) : this(auditEventId, source, timestamp, type, actor, target, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun auditEventId(): String = auditEventId.getRequired("auditEventId") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun source(): String = source.getRequired("source") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun timestamp(): String = timestamp.getRequired("timestamp") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): String = type.getRequired("type") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun actor(): Optional = actor.getOptional("actor") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun target(): Optional = target.getOptional("target") - - /** - * Returns the raw JSON value of [auditEventId]. - * - * Unlike [auditEventId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("auditEventId") - @ExcludeMissing - fun _auditEventId(): JsonField = auditEventId - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - /** - * Returns the raw JSON value of [timestamp]. - * - * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timestamp") @ExcludeMissing fun _timestamp(): JsonField = timestamp - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [actor]. - * - * Unlike [actor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("actor") @ExcludeMissing fun _actor(): JsonField = actor - - /** - * Returns the raw JSON value of [target]. - * - * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AuditEvent]. - * - * The following fields are required: - * ```java - * .auditEventId() - * .source() - * .timestamp() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AuditEvent]. */ - class Builder internal constructor() { - - private var auditEventId: JsonField? = null - private var source: JsonField? = null - private var timestamp: JsonField? = null - private var type: JsonField? = null - private var actor: JsonField = JsonMissing.of() - private var target: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(auditEvent: AuditEvent) = apply { - auditEventId = auditEvent.auditEventId - source = auditEvent.source - timestamp = auditEvent.timestamp - type = auditEvent.type - actor = auditEvent.actor - target = auditEvent.target - additionalProperties = auditEvent.additionalProperties.toMutableMap() - } - - fun auditEventId(auditEventId: String) = auditEventId(JsonField.of(auditEventId)) - - /** - * Sets [Builder.auditEventId] to an arbitrary JSON value. - * - * You should usually call [Builder.auditEventId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun auditEventId(auditEventId: JsonField) = apply { - this.auditEventId = auditEventId - } - - fun source(source: String) = source(JsonField.of(source)) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun timestamp(timestamp: String) = timestamp(JsonField.of(timestamp)) - - /** - * Sets [Builder.timestamp] to an arbitrary JSON value. - * - * You should usually call [Builder.timestamp] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun timestamp(timestamp: JsonField) = apply { this.timestamp = timestamp } - - fun type(type: String) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun actor(actor: Actor?) = actor(JsonField.ofNullable(actor)) - - /** Alias for calling [Builder.actor] with `actor.orElse(null)`. */ - fun actor(actor: Optional) = actor(actor.getOrNull()) - - /** - * Sets [Builder.actor] to an arbitrary JSON value. - * - * You should usually call [Builder.actor] with a well-typed [Actor] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun actor(actor: JsonField) = apply { this.actor = actor } - - fun target(target: Target?) = target(JsonField.ofNullable(target)) - - /** Alias for calling [Builder.target] with `target.orElse(null)`. */ - fun target(target: Optional) = target(target.getOrNull()) - - /** - * Sets [Builder.target] to an arbitrary JSON value. - * - * You should usually call [Builder.target] with a well-typed [Target] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun target(target: JsonField) = apply { this.target = target } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AuditEvent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .auditEventId() - * .source() - * .timestamp() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AuditEvent = - AuditEvent( - checkRequired("auditEventId", auditEventId), - checkRequired("source", source), - checkRequired("timestamp", timestamp), - checkRequired("type", type), - actor, - target, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AuditEvent = apply { - if (validated) { - return@apply - } - - auditEventId() - source() - timestamp() - type() - actor().ifPresent { it.validate() } - target().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (auditEventId.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (timestamp.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) + - (actor.asKnown().getOrNull()?.validity() ?: 0) + - (target.asKnown().getOrNull()?.validity() ?: 0) - - class Actor - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val email: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), - ) : this(id, email, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun email(): Optional = email.getOptional("email") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Actor]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Actor]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(actor: Actor) = apply { - id = actor.id - email = actor.email - additionalProperties = actor.additionalProperties.toMutableMap() - } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun email(email: String?) = email(JsonField.ofNullable(email)) - - /** Alias for calling [Builder.email] with `email.orElse(null)`. */ - fun email(email: Optional) = email(email.getOrNull()) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Actor]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Actor = Actor(id, email, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Actor = apply { - if (validated) { - return@apply - } - - id() - email() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (email.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Actor && - id == other.id && - email == other.email && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, email, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Actor{id=$id, email=$email, additionalProperties=$additionalProperties}" - } - - class Target - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val email: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), - ) : this(id, email, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun email(): Optional = email.getOptional("email") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Target]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Target]. */ - class Builder internal constructor() { - - private var id: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(target: Target) = apply { - id = target.id - email = target.email - additionalProperties = target.additionalProperties.toMutableMap() - } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun email(email: String?) = email(JsonField.ofNullable(email)) - - /** Alias for calling [Builder.email] with `email.orElse(null)`. */ - fun email(email: Optional) = email(email.getOrNull()) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Target]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Target = Target(id, email, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Target = apply { - if (validated) { - return@apply - } - - id() - email() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + (if (email.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Target && - id == other.id && - email == other.email && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, email, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Target{id=$id, email=$email, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AuditEvent && - auditEventId == other.auditEventId && - source == other.source && - timestamp == other.timestamp && - type == other.type && - actor == other.actor && - target == other.target && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(auditEventId, source, timestamp, type, actor, target, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AuditEvent{auditEventId=$auditEventId, source=$source, timestamp=$timestamp, type=$type, actor=$actor, target=$target, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt deleted file mode 100644 index 4ae23645..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListParams.kt +++ /dev/null @@ -1,191 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch the list of audit events */ -class AuditEventListParams -private constructor( - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** A unique identifier that allows for fetching the next set of audit events. */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AuditEventListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AuditEventListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AuditEventListParams]. */ - class Builder internal constructor() { - - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(auditEventListParams: AuditEventListParams) = apply { - cursor = auditEventListParams.cursor - additionalHeaders = auditEventListParams.additionalHeaders.toBuilder() - additionalQueryParams = auditEventListParams.additionalQueryParams.toBuilder() - } - - /** A unique identifier that allows for fetching the next set of audit events. */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AuditEventListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AuditEventListParams = - AuditEventListParams(cursor, additionalHeaders.build(), additionalQueryParams.build()) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AuditEventListParams && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AuditEventListParams{cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt deleted file mode 100644 index d5382159..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventListResponse.kt +++ /dev/null @@ -1,226 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class AuditEventListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val paging: JsonField, - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("results") - @ExcludeMissing - results: JsonField> = JsonMissing.of(), - ) : this(paging, results, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AuditEventListResponse]. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AuditEventListResponse]. */ - class Builder internal constructor() { - - private var paging: JsonField? = null - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(auditEventListResponse: AuditEventListResponse) = apply { - paging = auditEventListResponse.paging - results = auditEventListResponse.results.map { it.toMutableList() } - additionalProperties = auditEventListResponse.additionalProperties.toMutableMap() - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [AuditEvent] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: AuditEvent) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AuditEventListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AuditEventListResponse = - AuditEventListResponse( - checkRequired("paging", paging), - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AuditEventListResponse = apply { - if (validated) { - return@apply - } - - paging().validate() - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AuditEventListResponse && - paging == other.paging && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AuditEventListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt deleted file mode 100644 index cfe342b4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParams.kt +++ /dev/null @@ -1,194 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch a specific audit event by ID. */ -class AuditEventRetrieveParams -private constructor( - private val auditEventId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun auditEventId(): Optional = Optional.ofNullable(auditEventId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): AuditEventRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [AuditEventRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AuditEventRetrieveParams]. */ - class Builder internal constructor() { - - private var auditEventId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(auditEventRetrieveParams: AuditEventRetrieveParams) = apply { - auditEventId = auditEventRetrieveParams.auditEventId - additionalHeaders = auditEventRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = auditEventRetrieveParams.additionalQueryParams.toBuilder() - } - - fun auditEventId(auditEventId: String?) = apply { this.auditEventId = auditEventId } - - /** Alias for calling [Builder.auditEventId] with `auditEventId.orElse(null)`. */ - fun auditEventId(auditEventId: Optional) = auditEventId(auditEventId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AuditEventRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AuditEventRetrieveParams = - AuditEventRetrieveParams( - auditEventId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> auditEventId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AuditEventRetrieveParams && - auditEventId == other.auditEventId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(auditEventId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AuditEventRetrieveParams{auditEventId=$auditEventId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt deleted file mode 100644 index 62d595ac..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenParams.kt +++ /dev/null @@ -1,477 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auth - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -/** Returns a new access token. */ -class AuthIssueTokenParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun expiresIn(): String = body.expiresIn() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun scope(): String = body.scope() - - /** - * Returns the raw JSON value of [expiresIn]. - * - * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _expiresIn(): JsonField = body._expiresIn() - - /** - * Returns the raw JSON value of [scope]. - * - * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _scope(): JsonField = body._scope() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AuthIssueTokenParams]. - * - * The following fields are required: - * ```java - * .expiresIn() - * .scope() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AuthIssueTokenParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(authIssueTokenParams: AuthIssueTokenParams) = apply { - body = authIssueTokenParams.body.toBuilder() - additionalHeaders = authIssueTokenParams.additionalHeaders.toBuilder() - additionalQueryParams = authIssueTokenParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [expiresIn] - * - [scope] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun expiresIn(expiresIn: String) = apply { body.expiresIn(expiresIn) } - - /** - * Sets [Builder.expiresIn] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresIn] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun expiresIn(expiresIn: JsonField) = apply { body.expiresIn(expiresIn) } - - fun scope(scope: String) = apply { body.scope(scope) } - - /** - * Sets [Builder.scope] to an arbitrary JSON value. - * - * You should usually call [Builder.scope] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun scope(scope: JsonField) = apply { body.scope(scope) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [AuthIssueTokenParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .expiresIn() - * .scope() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AuthIssueTokenParams = - AuthIssueTokenParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val expiresIn: JsonField, - private val scope: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("expires_in") - @ExcludeMissing - expiresIn: JsonField = JsonMissing.of(), - @JsonProperty("scope") @ExcludeMissing scope: JsonField = JsonMissing.of(), - ) : this(expiresIn, scope, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun expiresIn(): String = expiresIn.getRequired("expires_in") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun scope(): String = scope.getRequired("scope") - - /** - * Returns the raw JSON value of [expiresIn]. - * - * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn - - /** - * Returns the raw JSON value of [scope]. - * - * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .expiresIn() - * .scope() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var expiresIn: JsonField? = null - private var scope: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - expiresIn = body.expiresIn - scope = body.scope - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun expiresIn(expiresIn: String) = expiresIn(JsonField.of(expiresIn)) - - /** - * Sets [Builder.expiresIn] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresIn] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } - - fun scope(scope: String) = scope(JsonField.of(scope)) - - /** - * Sets [Builder.scope] to an arbitrary JSON value. - * - * You should usually call [Builder.scope] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun scope(scope: JsonField) = apply { this.scope = scope } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .expiresIn() - * .scope() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("expiresIn", expiresIn), - checkRequired("scope", scope), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - expiresIn() - scope() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (expiresIn.asKnown().isPresent) 1 else 0) + - (if (scope.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - expiresIn == other.expiresIn && - scope == other.scope && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(expiresIn, scope, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{expiresIn=$expiresIn, scope=$scope, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AuthIssueTokenParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "AuthIssueTokenParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt deleted file mode 100644 index eed08cfb..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/auth/AuthIssueTokenResponse.kt +++ /dev/null @@ -1,157 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auth - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class AuthIssueTokenResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val token: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of() - ) : this(token, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun token(): Optional = token.getOptional("token") - - /** - * Returns the raw JSON value of [token]. - * - * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AuthIssueTokenResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AuthIssueTokenResponse]. */ - class Builder internal constructor() { - - private var token: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(authIssueTokenResponse: AuthIssueTokenResponse) = apply { - token = authIssueTokenResponse.token - additionalProperties = authIssueTokenResponse.additionalProperties.toMutableMap() - } - - fun token(token: String?) = token(JsonField.ofNullable(token)) - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AuthIssueTokenResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AuthIssueTokenResponse = - AuthIssueTokenResponse(token, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): AuthIssueTokenResponse = apply { - if (validated) { - return@apply - } - - token() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (token.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AuthIssueTokenResponse && - token == other.token && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(token, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AuthIssueTokenResponse{token=$token, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt deleted file mode 100644 index 99d31750..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParams.kt +++ /dev/null @@ -1,377 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class AutomationInvokeParams -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val brand: JsonField, - private val data: JsonField, - private val profile: JsonValue, - private val recipient: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), - @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), - @JsonProperty("template") @ExcludeMissing template: JsonField = JsonMissing.of(), - ) : this(brand, data, profile, recipient, template, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brand(): Optional = brand.getOptional("brand") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun template(): Optional = template.getOptional("template") - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AutomationInvokeParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationInvokeParams]. */ - class Builder internal constructor() { - - private var brand: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var profile: JsonValue = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var template: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationInvokeParams: AutomationInvokeParams) = apply { - brand = automationInvokeParams.brand - data = automationInvokeParams.data - profile = automationInvokeParams.profile - recipient = automationInvokeParams.recipient - template = automationInvokeParams.template - additionalProperties = automationInvokeParams.additionalProperties.toMutableMap() - } - - fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brand(brand: JsonField) = apply { this.brand = brand } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun profile(profile: JsonValue) = apply { this.profile = profile } - - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - fun template(template: String?) = template(JsonField.ofNullable(template)) - - /** Alias for calling [Builder.template] with `template.orElse(null)`. */ - fun template(template: Optional) = template(template.getOrNull()) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationInvokeParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AutomationInvokeParams = - AutomationInvokeParams( - brand, - data, - profile, - recipient, - template, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationInvokeParams = apply { - if (validated) { - return@apply - } - - brand() - data().ifPresent { it.validate() } - recipient() - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brand.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (if (template.asKnown().isPresent) 1 else 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationInvokeParams && - brand == other.brand && - data == other.data && - profile == other.profile && - recipient == other.recipient && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(brand, data, profile, recipient, template, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationInvokeParams{brand=$brand, data=$data, profile=$profile, recipient=$recipient, template=$template, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt deleted file mode 100644 index 716707c1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponse.kt +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class AutomationInvokeResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val runId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("runId") @ExcludeMissing runId: JsonField = JsonMissing.of() - ) : this(runId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun runId(): String = runId.getRequired("runId") - - /** - * Returns the raw JSON value of [runId]. - * - * Unlike [runId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("runId") @ExcludeMissing fun _runId(): JsonField = runId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AutomationInvokeResponse]. - * - * The following fields are required: - * ```java - * .runId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationInvokeResponse]. */ - class Builder internal constructor() { - - private var runId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationInvokeResponse: AutomationInvokeResponse) = apply { - runId = automationInvokeResponse.runId - additionalProperties = automationInvokeResponse.additionalProperties.toMutableMap() - } - - fun runId(runId: String) = runId(JsonField.of(runId)) - - /** - * Sets [Builder.runId] to an arbitrary JSON value. - * - * You should usually call [Builder.runId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun runId(runId: JsonField) = apply { this.runId = runId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationInvokeResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .runId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationInvokeResponse = - AutomationInvokeResponse( - checkRequired("runId", runId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationInvokeResponse = apply { - if (validated) { - return@apply - } - - runId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (runId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationInvokeResponse && - runId == other.runId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(runId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationInvokeResponse{runId=$runId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt deleted file mode 100644 index 40a0fce5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/AutomationStep.kt +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class AutomationStep -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(if_, ref, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [AutomationStep]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationStep: AutomationStep) = apply { - if_ = automationStep.if_ - ref = automationStep.ref - additionalProperties = automationStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AutomationStep = AutomationStep(if_, ref, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): AutomationStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + (if (ref.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationStep && - if_ == other.if_ && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(if_, ref, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationStep{if_=$if_, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt deleted file mode 100644 index b4128f1d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParams.kt +++ /dev/null @@ -1,9457 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.send.Message -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of automation - * steps. For information about what steps are available, checkout the ad hoc automation guide - * [here](https://www.courier.com/docs/automations/steps/). - */ -class InvokeInvokeAdHocParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brand(): Optional = body.brand() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = body.data() - - fun _profile(): JsonValue = body._profile() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = body.recipient() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun template(): Optional = body.template() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun automation(): Automation = body.automation() - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _brand(): JsonField = body._brand() - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _data(): JsonField = body._data() - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _recipient(): JsonField = body._recipient() - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _template(): JsonField = body._template() - - /** - * Returns the raw JSON value of [automation]. - * - * Unlike [automation], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _automation(): JsonField = body._automation() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [InvokeInvokeAdHocParams]. - * - * The following fields are required: - * ```java - * .automation() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvokeInvokeAdHocParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(invokeInvokeAdHocParams: InvokeInvokeAdHocParams) = apply { - body = invokeInvokeAdHocParams.body.toBuilder() - additionalHeaders = invokeInvokeAdHocParams.additionalHeaders.toBuilder() - additionalQueryParams = invokeInvokeAdHocParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [brand] - * - [data] - * - [profile] - * - [recipient] - * - [template] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun brand(brand: String?) = apply { body.brand(brand) } - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brand(brand: JsonField) = apply { body.brand(brand) } - - fun data(data: AutomationInvokeParams.Data?) = apply { body.data(data) } - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [AutomationInvokeParams.Data] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun data(data: JsonField) = apply { body.data(data) } - - fun profile(profile: JsonValue) = apply { body.profile(profile) } - - fun recipient(recipient: String?) = apply { body.recipient(recipient) } - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipient(recipient: JsonField) = apply { body.recipient(recipient) } - - fun template(template: String?) = apply { body.template(template) } - - /** Alias for calling [Builder.template] with `template.orElse(null)`. */ - fun template(template: Optional) = template(template.getOrNull()) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun template(template: JsonField) = apply { body.template(template) } - - fun automation(automation: Automation) = apply { body.automation(automation) } - - /** - * Sets [Builder.automation] to an arbitrary JSON value. - * - * You should usually call [Builder.automation] with a well-typed [Automation] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun automation(automation: JsonField) = apply { body.automation(automation) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [InvokeInvokeAdHocParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .automation() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InvokeInvokeAdHocParams = - InvokeInvokeAdHocParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val brand: JsonField, - private val data: JsonField, - private val profile: JsonValue, - private val recipient: JsonField, - private val template: JsonField, - private val automation: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), - @JsonProperty("data") - @ExcludeMissing - data: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), - @JsonProperty("recipient") - @ExcludeMissing - recipient: JsonField = JsonMissing.of(), - @JsonProperty("template") - @ExcludeMissing - template: JsonField = JsonMissing.of(), - @JsonProperty("automation") - @ExcludeMissing - automation: JsonField = JsonMissing.of(), - ) : this(brand, data, profile, recipient, template, automation, mutableMapOf()) - - fun toAutomationInvokeParams(): AutomationInvokeParams = - AutomationInvokeParams.builder() - .brand(brand) - .data(data) - .profile(profile) - .recipient(recipient) - .template(template) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brand(): Optional = brand.getOptional("brand") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun template(): Optional = template.getOptional("template") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun automation(): Automation = automation.getRequired("automation") - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") - @ExcludeMissing - fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template - - /** - * Returns the raw JSON value of [automation]. - * - * Unlike [automation], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("automation") - @ExcludeMissing - fun _automation(): JsonField = automation - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .automation() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var brand: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var profile: JsonValue = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var template: JsonField = JsonMissing.of() - private var automation: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - brand = body.brand - data = body.data - profile = body.profile - recipient = body.recipient - template = body.template - automation = body.automation - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun brand(brand: JsonField) = apply { this.brand = brand } - - fun data(data: AutomationInvokeParams.Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed - * [AutomationInvokeParams.Data] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun profile(profile: JsonValue) = apply { this.profile = profile } - - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - fun template(template: String?) = template(JsonField.ofNullable(template)) - - /** Alias for calling [Builder.template] with `template.orElse(null)`. */ - fun template(template: Optional) = template(template.getOrNull()) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun automation(automation: Automation) = automation(JsonField.of(automation)) - - /** - * Sets [Builder.automation] to an arbitrary JSON value. - * - * You should usually call [Builder.automation] with a well-typed [Automation] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun automation(automation: JsonField) = apply { - this.automation = automation - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .automation() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - brand, - data, - profile, - recipient, - template, - checkRequired("automation", automation), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - brand() - data().ifPresent { it.validate() } - recipient() - template() - automation().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brand.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (if (template.asKnown().isPresent) 1 else 0) + - (automation.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - brand == other.brand && - data == other.data && - profile == other.profile && - recipient == other.recipient && - template == other.template && - automation == other.automation && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - brand, - data, - profile, - recipient, - template, - automation, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{brand=$brand, data=$data, profile=$profile, recipient=$recipient, template=$template, automation=$automation, additionalProperties=$additionalProperties}" - } - - class Automation - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val steps: JsonField>, - private val cancelationToken: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("steps") @ExcludeMissing steps: JsonField> = JsonMissing.of(), - @JsonProperty("cancelation_token") - @ExcludeMissing - cancelationToken: JsonField = JsonMissing.of(), - ) : this(steps, cancelationToken, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun steps(): List = steps.getRequired("steps") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cancelationToken(): Optional = cancelationToken.getOptional("cancelation_token") - - /** - * Returns the raw JSON value of [steps]. - * - * Unlike [steps], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("steps") @ExcludeMissing fun _steps(): JsonField> = steps - - /** - * Returns the raw JSON value of [cancelationToken]. - * - * Unlike [cancelationToken], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("cancelation_token") - @ExcludeMissing - fun _cancelationToken(): JsonField = cancelationToken - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Automation]. - * - * The following fields are required: - * ```java - * .steps() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Automation]. */ - class Builder internal constructor() { - - private var steps: JsonField>? = null - private var cancelationToken: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automation: Automation) = apply { - steps = automation.steps.map { it.toMutableList() } - cancelationToken = automation.cancelationToken - additionalProperties = automation.additionalProperties.toMutableMap() - } - - fun steps(steps: List) = steps(JsonField.of(steps)) - - /** - * Sets [Builder.steps] to an arbitrary JSON value. - * - * You should usually call [Builder.steps] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun steps(steps: JsonField>) = apply { - this.steps = steps.map { it.toMutableList() } - } - - /** - * Adds a single [Step] to [steps]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStep(step: Step) = apply { - steps = - (steps ?: JsonField.of(mutableListOf())).also { - checkKnown("steps", it).add(step) - } - } - - /** - * Alias for calling [addStep] with - * `Step.ofAutomationAddToDigest(automationAddToDigest)`. - */ - fun addStep(automationAddToDigest: Step.AutomationAddToDigestStep) = - addStep(Step.ofAutomationAddToDigest(automationAddToDigest)) - - /** - * Alias for calling [addStep] with `Step.ofAutomationAddToBatch(automationAddToBatch)`. - */ - fun addStep(automationAddToBatch: Step.AutomationAddToBatchStep) = - addStep(Step.ofAutomationAddToBatch(automationAddToBatch)) - - /** Alias for calling [addStep] with `Step.ofAutomationThrottle(automationThrottle)`. */ - fun addStep(automationThrottle: Step.AutomationThrottleStep) = - addStep(Step.ofAutomationThrottle(automationThrottle)) - - /** Alias for calling [addStep] with `Step.ofAutomationCancel(automationCancel)`. */ - fun addStep(automationCancel: Step.AutomationCancelStep) = - addStep(Step.ofAutomationCancel(automationCancel)) - - /** Alias for calling [addStep] with `Step.ofAutomationDelay(automationDelay)`. */ - fun addStep(automationDelay: Step.AutomationDelayStep) = - addStep(Step.ofAutomationDelay(automationDelay)) - - /** - * Alias for calling [addStep] with `Step.ofAutomationFetchData(automationFetchData)`. - */ - fun addStep(automationFetchData: Step.AutomationFetchDataStep) = - addStep(Step.ofAutomationFetchData(automationFetchData)) - - /** Alias for calling [addStep] with `Step.ofAutomationInvoke(automationInvoke)`. */ - fun addStep(automationInvoke: Step.AutomationInvokeStep) = - addStep(Step.ofAutomationInvoke(automationInvoke)) - - /** Alias for calling [addStep] with `Step.ofAutomationSend(automationSend)`. */ - fun addStep(automationSend: Step.AutomationSendStep) = - addStep(Step.ofAutomationSend(automationSend)) - - /** Alias for calling [addStep] with `Step.ofAutomationV2Send(automationV2Send)`. */ - fun addStep(automationV2Send: Step.AutomationV2SendStep) = - addStep(Step.ofAutomationV2Send(automationV2Send)) - - /** Alias for calling [addStep] with `Step.ofAutomationSendList(automationSendList)`. */ - fun addStep(automationSendList: Step.AutomationSendListStep) = - addStep(Step.ofAutomationSendList(automationSendList)) - - /** - * Alias for calling [addStep] with - * `Step.ofAutomationUpdateProfile(automationUpdateProfile)`. - */ - fun addStep(automationUpdateProfile: Step.AutomationUpdateProfileStep) = - addStep(Step.ofAutomationUpdateProfile(automationUpdateProfile)) - - fun cancelationToken(cancelationToken: String?) = - cancelationToken(JsonField.ofNullable(cancelationToken)) - - /** - * Alias for calling [Builder.cancelationToken] with `cancelationToken.orElse(null)`. - */ - fun cancelationToken(cancelationToken: Optional) = - cancelationToken(cancelationToken.getOrNull()) - - /** - * Sets [Builder.cancelationToken] to an arbitrary JSON value. - * - * You should usually call [Builder.cancelationToken] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cancelationToken(cancelationToken: JsonField) = apply { - this.cancelationToken = cancelationToken - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Automation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .steps() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Automation = - Automation( - checkRequired("steps", steps).map { it.toImmutable() }, - cancelationToken, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Automation = apply { - if (validated) { - return@apply - } - - steps().forEach { it.validate() } - cancelationToken() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (steps.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (cancelationToken.asKnown().isPresent) 1 else 0) - - @JsonDeserialize(using = Step.Deserializer::class) - @JsonSerialize(using = Step.Serializer::class) - class Step - private constructor( - private val automationAddToDigest: AutomationAddToDigestStep? = null, - private val automationAddToBatch: AutomationAddToBatchStep? = null, - private val automationThrottle: AutomationThrottleStep? = null, - private val automationCancel: AutomationCancelStep? = null, - private val automationDelay: AutomationDelayStep? = null, - private val automationFetchData: AutomationFetchDataStep? = null, - private val automationInvoke: AutomationInvokeStep? = null, - private val automationSend: AutomationSendStep? = null, - private val automationV2Send: AutomationV2SendStep? = null, - private val automationSendList: AutomationSendListStep? = null, - private val automationUpdateProfile: AutomationUpdateProfileStep? = null, - private val _json: JsonValue? = null, - ) { - - fun automationAddToDigest(): Optional = - Optional.ofNullable(automationAddToDigest) - - fun automationAddToBatch(): Optional = - Optional.ofNullable(automationAddToBatch) - - fun automationThrottle(): Optional = - Optional.ofNullable(automationThrottle) - - fun automationCancel(): Optional = - Optional.ofNullable(automationCancel) - - fun automationDelay(): Optional = - Optional.ofNullable(automationDelay) - - fun automationFetchData(): Optional = - Optional.ofNullable(automationFetchData) - - fun automationInvoke(): Optional = - Optional.ofNullable(automationInvoke) - - fun automationSend(): Optional = Optional.ofNullable(automationSend) - - fun automationV2Send(): Optional = - Optional.ofNullable(automationV2Send) - - fun automationSendList(): Optional = - Optional.ofNullable(automationSendList) - - fun automationUpdateProfile(): Optional = - Optional.ofNullable(automationUpdateProfile) - - fun isAutomationAddToDigest(): Boolean = automationAddToDigest != null - - fun isAutomationAddToBatch(): Boolean = automationAddToBatch != null - - fun isAutomationThrottle(): Boolean = automationThrottle != null - - fun isAutomationCancel(): Boolean = automationCancel != null - - fun isAutomationDelay(): Boolean = automationDelay != null - - fun isAutomationFetchData(): Boolean = automationFetchData != null - - fun isAutomationInvoke(): Boolean = automationInvoke != null - - fun isAutomationSend(): Boolean = automationSend != null - - fun isAutomationV2Send(): Boolean = automationV2Send != null - - fun isAutomationSendList(): Boolean = automationSendList != null - - fun isAutomationUpdateProfile(): Boolean = automationUpdateProfile != null - - fun asAutomationAddToDigest(): AutomationAddToDigestStep = - automationAddToDigest.getOrThrow("automationAddToDigest") - - fun asAutomationAddToBatch(): AutomationAddToBatchStep = - automationAddToBatch.getOrThrow("automationAddToBatch") - - fun asAutomationThrottle(): AutomationThrottleStep = - automationThrottle.getOrThrow("automationThrottle") - - fun asAutomationCancel(): AutomationCancelStep = - automationCancel.getOrThrow("automationCancel") - - fun asAutomationDelay(): AutomationDelayStep = - automationDelay.getOrThrow("automationDelay") - - fun asAutomationFetchData(): AutomationFetchDataStep = - automationFetchData.getOrThrow("automationFetchData") - - fun asAutomationInvoke(): AutomationInvokeStep = - automationInvoke.getOrThrow("automationInvoke") - - fun asAutomationSend(): AutomationSendStep = automationSend.getOrThrow("automationSend") - - fun asAutomationV2Send(): AutomationV2SendStep = - automationV2Send.getOrThrow("automationV2Send") - - fun asAutomationSendList(): AutomationSendListStep = - automationSendList.getOrThrow("automationSendList") - - fun asAutomationUpdateProfile(): AutomationUpdateProfileStep = - automationUpdateProfile.getOrThrow("automationUpdateProfile") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - automationAddToDigest != null -> - visitor.visitAutomationAddToDigest(automationAddToDigest) - automationAddToBatch != null -> - visitor.visitAutomationAddToBatch(automationAddToBatch) - automationThrottle != null -> - visitor.visitAutomationThrottle(automationThrottle) - automationCancel != null -> visitor.visitAutomationCancel(automationCancel) - automationDelay != null -> visitor.visitAutomationDelay(automationDelay) - automationFetchData != null -> - visitor.visitAutomationFetchData(automationFetchData) - automationInvoke != null -> visitor.visitAutomationInvoke(automationInvoke) - automationSend != null -> visitor.visitAutomationSend(automationSend) - automationV2Send != null -> visitor.visitAutomationV2Send(automationV2Send) - automationSendList != null -> - visitor.visitAutomationSendList(automationSendList) - automationUpdateProfile != null -> - visitor.visitAutomationUpdateProfile(automationUpdateProfile) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Step = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAutomationAddToDigest( - automationAddToDigest: AutomationAddToDigestStep - ) { - automationAddToDigest.validate() - } - - override fun visitAutomationAddToBatch( - automationAddToBatch: AutomationAddToBatchStep - ) { - automationAddToBatch.validate() - } - - override fun visitAutomationThrottle( - automationThrottle: AutomationThrottleStep - ) { - automationThrottle.validate() - } - - override fun visitAutomationCancel(automationCancel: AutomationCancelStep) { - automationCancel.validate() - } - - override fun visitAutomationDelay(automationDelay: AutomationDelayStep) { - automationDelay.validate() - } - - override fun visitAutomationFetchData( - automationFetchData: AutomationFetchDataStep - ) { - automationFetchData.validate() - } - - override fun visitAutomationInvoke(automationInvoke: AutomationInvokeStep) { - automationInvoke.validate() - } - - override fun visitAutomationSend(automationSend: AutomationSendStep) { - automationSend.validate() - } - - override fun visitAutomationV2Send(automationV2Send: AutomationV2SendStep) { - automationV2Send.validate() - } - - override fun visitAutomationSendList( - automationSendList: AutomationSendListStep - ) { - automationSendList.validate() - } - - override fun visitAutomationUpdateProfile( - automationUpdateProfile: AutomationUpdateProfileStep - ) { - automationUpdateProfile.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitAutomationAddToDigest( - automationAddToDigest: AutomationAddToDigestStep - ) = automationAddToDigest.validity() - - override fun visitAutomationAddToBatch( - automationAddToBatch: AutomationAddToBatchStep - ) = automationAddToBatch.validity() - - override fun visitAutomationThrottle( - automationThrottle: AutomationThrottleStep - ) = automationThrottle.validity() - - override fun visitAutomationCancel(automationCancel: AutomationCancelStep) = - automationCancel.validity() - - override fun visitAutomationDelay(automationDelay: AutomationDelayStep) = - automationDelay.validity() - - override fun visitAutomationFetchData( - automationFetchData: AutomationFetchDataStep - ) = automationFetchData.validity() - - override fun visitAutomationInvoke(automationInvoke: AutomationInvokeStep) = - automationInvoke.validity() - - override fun visitAutomationSend(automationSend: AutomationSendStep) = - automationSend.validity() - - override fun visitAutomationV2Send(automationV2Send: AutomationV2SendStep) = - automationV2Send.validity() - - override fun visitAutomationSendList( - automationSendList: AutomationSendListStep - ) = automationSendList.validity() - - override fun visitAutomationUpdateProfile( - automationUpdateProfile: AutomationUpdateProfileStep - ) = automationUpdateProfile.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Step && - automationAddToDigest == other.automationAddToDigest && - automationAddToBatch == other.automationAddToBatch && - automationThrottle == other.automationThrottle && - automationCancel == other.automationCancel && - automationDelay == other.automationDelay && - automationFetchData == other.automationFetchData && - automationInvoke == other.automationInvoke && - automationSend == other.automationSend && - automationV2Send == other.automationV2Send && - automationSendList == other.automationSendList && - automationUpdateProfile == other.automationUpdateProfile - } - - override fun hashCode(): Int = - Objects.hash( - automationAddToDigest, - automationAddToBatch, - automationThrottle, - automationCancel, - automationDelay, - automationFetchData, - automationInvoke, - automationSend, - automationV2Send, - automationSendList, - automationUpdateProfile, - ) - - override fun toString(): String = - when { - automationAddToDigest != null -> - "Step{automationAddToDigest=$automationAddToDigest}" - automationAddToBatch != null -> - "Step{automationAddToBatch=$automationAddToBatch}" - automationThrottle != null -> "Step{automationThrottle=$automationThrottle}" - automationCancel != null -> "Step{automationCancel=$automationCancel}" - automationDelay != null -> "Step{automationDelay=$automationDelay}" - automationFetchData != null -> "Step{automationFetchData=$automationFetchData}" - automationInvoke != null -> "Step{automationInvoke=$automationInvoke}" - automationSend != null -> "Step{automationSend=$automationSend}" - automationV2Send != null -> "Step{automationV2Send=$automationV2Send}" - automationSendList != null -> "Step{automationSendList=$automationSendList}" - automationUpdateProfile != null -> - "Step{automationUpdateProfile=$automationUpdateProfile}" - _json != null -> "Step{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Step") - } - - companion object { - - @JvmStatic - fun ofAutomationAddToDigest(automationAddToDigest: AutomationAddToDigestStep) = - Step(automationAddToDigest = automationAddToDigest) - - @JvmStatic - fun ofAutomationAddToBatch(automationAddToBatch: AutomationAddToBatchStep) = - Step(automationAddToBatch = automationAddToBatch) - - @JvmStatic - fun ofAutomationThrottle(automationThrottle: AutomationThrottleStep) = - Step(automationThrottle = automationThrottle) - - @JvmStatic - fun ofAutomationCancel(automationCancel: AutomationCancelStep) = - Step(automationCancel = automationCancel) - - @JvmStatic - fun ofAutomationDelay(automationDelay: AutomationDelayStep) = - Step(automationDelay = automationDelay) - - @JvmStatic - fun ofAutomationFetchData(automationFetchData: AutomationFetchDataStep) = - Step(automationFetchData = automationFetchData) - - @JvmStatic - fun ofAutomationInvoke(automationInvoke: AutomationInvokeStep) = - Step(automationInvoke = automationInvoke) - - @JvmStatic - fun ofAutomationSend(automationSend: AutomationSendStep) = - Step(automationSend = automationSend) - - @JvmStatic - fun ofAutomationV2Send(automationV2Send: AutomationV2SendStep) = - Step(automationV2Send = automationV2Send) - - @JvmStatic - fun ofAutomationSendList(automationSendList: AutomationSendListStep) = - Step(automationSendList = automationSendList) - - @JvmStatic - fun ofAutomationUpdateProfile( - automationUpdateProfile: AutomationUpdateProfileStep - ) = Step(automationUpdateProfile = automationUpdateProfile) - } - - /** - * An interface that defines how to map each variant of [Step] to a value of type [T]. - */ - interface Visitor { - - fun visitAutomationAddToDigest(automationAddToDigest: AutomationAddToDigestStep): T - - fun visitAutomationAddToBatch(automationAddToBatch: AutomationAddToBatchStep): T - - fun visitAutomationThrottle(automationThrottle: AutomationThrottleStep): T - - fun visitAutomationCancel(automationCancel: AutomationCancelStep): T - - fun visitAutomationDelay(automationDelay: AutomationDelayStep): T - - fun visitAutomationFetchData(automationFetchData: AutomationFetchDataStep): T - - fun visitAutomationInvoke(automationInvoke: AutomationInvokeStep): T - - fun visitAutomationSend(automationSend: AutomationSendStep): T - - fun visitAutomationV2Send(automationV2Send: AutomationV2SendStep): T - - fun visitAutomationSendList(automationSendList: AutomationSendListStep): T - - fun visitAutomationUpdateProfile( - automationUpdateProfile: AutomationUpdateProfileStep - ): T - - /** - * Maps an unknown variant of [Step] to a value of type [T]. - * - * An instance of [Step] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Step: $json") - } - } - - internal class Deserializer : BaseDeserializer(Step::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Step { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Step(automationAddToDigest = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Step(automationAddToBatch = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Step(automationThrottle = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Step(automationCancel = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Step(automationDelay = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Step(automationFetchData = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Step(automationInvoke = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Step(automationSend = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Step(automationV2Send = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Step(automationSendList = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { Step(automationUpdateProfile = it, _json = json) }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Step(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Step::class) { - - override fun serialize( - value: Step, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.automationAddToDigest != null -> - generator.writeObject(value.automationAddToDigest) - value.automationAddToBatch != null -> - generator.writeObject(value.automationAddToBatch) - value.automationThrottle != null -> - generator.writeObject(value.automationThrottle) - value.automationCancel != null -> - generator.writeObject(value.automationCancel) - value.automationDelay != null -> - generator.writeObject(value.automationDelay) - value.automationFetchData != null -> - generator.writeObject(value.automationFetchData) - value.automationInvoke != null -> - generator.writeObject(value.automationInvoke) - value.automationSend != null -> generator.writeObject(value.automationSend) - value.automationV2Send != null -> - generator.writeObject(value.automationV2Send) - value.automationSendList != null -> - generator.writeObject(value.automationSendList) - value.automationUpdateProfile != null -> - generator.writeObject(value.automationUpdateProfile) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Step") - } - } - } - - class AutomationAddToDigestStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val subscriptionTopicId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("subscription_topic_id") - @ExcludeMissing - subscriptionTopicId: JsonField = JsonMissing.of(), - ) : this(if_, ref, action, subscriptionTopicId, mutableMapOf()) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * The subscription topic that has digests enabled - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun subscriptionTopicId(): String = - subscriptionTopicId.getRequired("subscription_topic_id") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [subscriptionTopicId]. - * - * Unlike [subscriptionTopicId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_topic_id") - @ExcludeMissing - fun _subscriptionTopicId(): JsonField = subscriptionTopicId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationAddToDigestStep]. - * - * The following fields are required: - * ```java - * .action() - * .subscriptionTopicId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationAddToDigestStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var subscriptionTopicId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationAddToDigestStep: AutomationAddToDigestStep) = - apply { - if_ = automationAddToDigestStep.if_ - ref = automationAddToDigestStep.ref - action = automationAddToDigestStep.action - subscriptionTopicId = automationAddToDigestStep.subscriptionTopicId - additionalProperties = - automationAddToDigestStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - /** The subscription topic that has digests enabled */ - fun subscriptionTopicId(subscriptionTopicId: String) = - subscriptionTopicId(JsonField.of(subscriptionTopicId)) - - /** - * Sets [Builder.subscriptionTopicId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionTopicId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun subscriptionTopicId(subscriptionTopicId: JsonField) = apply { - this.subscriptionTopicId = subscriptionTopicId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationAddToDigestStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .subscriptionTopicId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationAddToDigestStep = - AutomationAddToDigestStep( - if_, - ref, - checkRequired("action", action), - checkRequired("subscriptionTopicId", subscriptionTopicId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationAddToDigestStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - subscriptionTopicId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (subscriptionTopicId.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ADD_TO_DIGEST = of("add-to-digest") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - ADD_TO_DIGEST - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADD_TO_DIGEST, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADD_TO_DIGEST -> Value.ADD_TO_DIGEST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ADD_TO_DIGEST -> Known.ADD_TO_DIGEST - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationAddToDigestStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - subscriptionTopicId == other.subscriptionTopicId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(if_, ref, action, subscriptionTopicId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationAddToDigestStep{if_=$if_, ref=$ref, action=$action, subscriptionTopicId=$subscriptionTopicId, additionalProperties=$additionalProperties}" - } - - class AutomationAddToBatchStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val maxWaitPeriod: JsonField, - private val retain: JsonField, - private val waitPeriod: JsonField, - private val batchId: JsonField, - private val batchKey: JsonField, - private val categoryKey: JsonField, - private val maxItems: JsonField, - private val scope: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("max_wait_period") - @ExcludeMissing - maxWaitPeriod: JsonField = JsonMissing.of(), - @JsonProperty("retain") - @ExcludeMissing - retain: JsonField = JsonMissing.of(), - @JsonProperty("wait_period") - @ExcludeMissing - waitPeriod: JsonField = JsonMissing.of(), - @JsonProperty("batch_id") - @ExcludeMissing - batchId: JsonField = JsonMissing.of(), - @JsonProperty("batch_key") - @ExcludeMissing - batchKey: JsonField = JsonMissing.of(), - @JsonProperty("category_key") - @ExcludeMissing - categoryKey: JsonField = JsonMissing.of(), - @JsonProperty("max_items") - @ExcludeMissing - maxItems: JsonField = JsonMissing.of(), - @JsonProperty("scope") - @ExcludeMissing - scope: JsonField = JsonMissing.of(), - ) : this( - if_, - ref, - action, - maxWaitPeriod, - retain, - waitPeriod, - batchId, - batchKey, - categoryKey, - maxItems, - scope, - mutableMapOf(), - ) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * Defines the maximum wait time before the batch should be released. Must be less - * than wait period. Maximum of 60 days. Specified as an - * [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxWaitPeriod(): String = maxWaitPeriod.getRequired("max_wait_period") - - /** - * Defines what items should be retained and passed along to the next steps when the - * batch is released - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun retain(): Retain = retain.getRequired("retain") - - /** - * Defines the period of inactivity before the batch is released. Specified as an - * [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun waitPeriod(): String = waitPeriod.getRequired("wait_period") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun batchId(): Optional = batchId.getOptional("batch_id") - - /** - * If using scope=dynamic, provide the key or a reference (e.g., - * refs.data.batch_key) - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun batchKey(): Optional = batchKey.getOptional("batch_key") - - /** - * Defines the field of the data object the batch is set to when complete. Defaults - * to `batch` - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun categoryKey(): Optional = categoryKey.getOptional("category_key") - - /** - * If specified, the batch will release as soon as this number is reached - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxItems(): Optional = maxItems.getOptional("max_items") - - /** - * Determine the scope of the batching. If user, chosen in this order: recipient, - * profile.user_id, data.user_id, data.userId. If dynamic, then specify where the - * batch_key or a reference to the batch_key - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun scope(): Optional = scope.getOptional("scope") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [maxWaitPeriod]. - * - * Unlike [maxWaitPeriod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_wait_period") - @ExcludeMissing - fun _maxWaitPeriod(): JsonField = maxWaitPeriod - - /** - * Returns the raw JSON value of [retain]. - * - * Unlike [retain], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("retain") @ExcludeMissing fun _retain(): JsonField = retain - - /** - * Returns the raw JSON value of [waitPeriod]. - * - * Unlike [waitPeriod], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("wait_period") - @ExcludeMissing - fun _waitPeriod(): JsonField = waitPeriod - - /** - * Returns the raw JSON value of [batchId]. - * - * Unlike [batchId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("batch_id") - @ExcludeMissing - fun _batchId(): JsonField = batchId - - /** - * Returns the raw JSON value of [batchKey]. - * - * Unlike [batchKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("batch_key") - @ExcludeMissing - fun _batchKey(): JsonField = batchKey - - /** - * Returns the raw JSON value of [categoryKey]. - * - * Unlike [categoryKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("category_key") - @ExcludeMissing - fun _categoryKey(): JsonField = categoryKey - - /** - * Returns the raw JSON value of [maxItems]. - * - * Unlike [maxItems], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("max_items") - @ExcludeMissing - fun _maxItems(): JsonField = maxItems - - /** - * Returns the raw JSON value of [scope]. - * - * Unlike [scope], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationAddToBatchStep]. - * - * The following fields are required: - * ```java - * .action() - * .maxWaitPeriod() - * .retain() - * .waitPeriod() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationAddToBatchStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var maxWaitPeriod: JsonField? = null - private var retain: JsonField? = null - private var waitPeriod: JsonField? = null - private var batchId: JsonField = JsonMissing.of() - private var batchKey: JsonField = JsonMissing.of() - private var categoryKey: JsonField = JsonMissing.of() - private var maxItems: JsonField = JsonMissing.of() - private var scope: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationAddToBatchStep: AutomationAddToBatchStep) = apply { - if_ = automationAddToBatchStep.if_ - ref = automationAddToBatchStep.ref - action = automationAddToBatchStep.action - maxWaitPeriod = automationAddToBatchStep.maxWaitPeriod - retain = automationAddToBatchStep.retain - waitPeriod = automationAddToBatchStep.waitPeriod - batchId = automationAddToBatchStep.batchId - batchKey = automationAddToBatchStep.batchKey - categoryKey = automationAddToBatchStep.categoryKey - maxItems = automationAddToBatchStep.maxItems - scope = automationAddToBatchStep.scope - additionalProperties = - automationAddToBatchStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - /** - * Defines the maximum wait time before the batch should be released. Must be - * less than wait period. Maximum of 60 days. Specified as an - * [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) - */ - fun maxWaitPeriod(maxWaitPeriod: String) = - maxWaitPeriod(JsonField.of(maxWaitPeriod)) - - /** - * Sets [Builder.maxWaitPeriod] to an arbitrary JSON value. - * - * You should usually call [Builder.maxWaitPeriod] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxWaitPeriod(maxWaitPeriod: JsonField) = apply { - this.maxWaitPeriod = maxWaitPeriod - } - - /** - * Defines what items should be retained and passed along to the next steps when - * the batch is released - */ - fun retain(retain: Retain) = retain(JsonField.of(retain)) - - /** - * Sets [Builder.retain] to an arbitrary JSON value. - * - * You should usually call [Builder.retain] with a well-typed [Retain] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun retain(retain: JsonField) = apply { this.retain = retain } - - /** - * Defines the period of inactivity before the batch is released. Specified as - * an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) - */ - fun waitPeriod(waitPeriod: String) = waitPeriod(JsonField.of(waitPeriod)) - - /** - * Sets [Builder.waitPeriod] to an arbitrary JSON value. - * - * You should usually call [Builder.waitPeriod] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun waitPeriod(waitPeriod: JsonField) = apply { - this.waitPeriod = waitPeriod - } - - fun batchId(batchId: String?) = batchId(JsonField.ofNullable(batchId)) - - /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ - fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) - - /** - * Sets [Builder.batchId] to an arbitrary JSON value. - * - * You should usually call [Builder.batchId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun batchId(batchId: JsonField) = apply { this.batchId = batchId } - - /** - * If using scope=dynamic, provide the key or a reference (e.g., - * refs.data.batch_key) - */ - fun batchKey(batchKey: String?) = batchKey(JsonField.ofNullable(batchKey)) - - /** Alias for calling [Builder.batchKey] with `batchKey.orElse(null)`. */ - fun batchKey(batchKey: Optional) = batchKey(batchKey.getOrNull()) - - /** - * Sets [Builder.batchKey] to an arbitrary JSON value. - * - * You should usually call [Builder.batchKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun batchKey(batchKey: JsonField) = apply { this.batchKey = batchKey } - - /** - * Defines the field of the data object the batch is set to when complete. - * Defaults to `batch` - */ - fun categoryKey(categoryKey: String?) = - categoryKey(JsonField.ofNullable(categoryKey)) - - /** Alias for calling [Builder.categoryKey] with `categoryKey.orElse(null)`. */ - fun categoryKey(categoryKey: Optional) = - categoryKey(categoryKey.getOrNull()) - - /** - * Sets [Builder.categoryKey] to an arbitrary JSON value. - * - * You should usually call [Builder.categoryKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun categoryKey(categoryKey: JsonField) = apply { - this.categoryKey = categoryKey - } - - /** If specified, the batch will release as soon as this number is reached */ - fun maxItems(maxItems: MaxItems?) = maxItems(JsonField.ofNullable(maxItems)) - - /** Alias for calling [Builder.maxItems] with `maxItems.orElse(null)`. */ - fun maxItems(maxItems: Optional) = maxItems(maxItems.getOrNull()) - - /** - * Sets [Builder.maxItems] to an arbitrary JSON value. - * - * You should usually call [Builder.maxItems] with a well-typed [MaxItems] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun maxItems(maxItems: JsonField) = apply { this.maxItems = maxItems } - - /** Alias for calling [maxItems] with `MaxItems.ofString(string)`. */ - fun maxItems(string: String) = maxItems(MaxItems.ofString(string)) - - /** Alias for calling [maxItems] with `MaxItems.ofInteger(integer)`. */ - fun maxItems(integer: Long) = maxItems(MaxItems.ofInteger(integer)) - - /** - * Determine the scope of the batching. If user, chosen in this order: - * recipient, profile.user_id, data.user_id, data.userId. If dynamic, then - * specify where the batch_key or a reference to the batch_key - */ - fun scope(scope: Scope?) = scope(JsonField.ofNullable(scope)) - - /** Alias for calling [Builder.scope] with `scope.orElse(null)`. */ - fun scope(scope: Optional) = scope(scope.getOrNull()) - - /** - * Sets [Builder.scope] to an arbitrary JSON value. - * - * You should usually call [Builder.scope] with a well-typed [Scope] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun scope(scope: JsonField) = apply { this.scope = scope } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationAddToBatchStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .maxWaitPeriod() - * .retain() - * .waitPeriod() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationAddToBatchStep = - AutomationAddToBatchStep( - if_, - ref, - checkRequired("action", action), - checkRequired("maxWaitPeriod", maxWaitPeriod), - checkRequired("retain", retain), - checkRequired("waitPeriod", waitPeriod), - batchId, - batchKey, - categoryKey, - maxItems, - scope, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationAddToBatchStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - maxWaitPeriod() - retain().validate() - waitPeriod() - batchId() - batchKey() - categoryKey() - maxItems().ifPresent { it.validate() } - scope().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (maxWaitPeriod.asKnown().isPresent) 1 else 0) + - (retain.asKnown().getOrNull()?.validity() ?: 0) + - (if (waitPeriod.asKnown().isPresent) 1 else 0) + - (if (batchId.asKnown().isPresent) 1 else 0) + - (if (batchKey.asKnown().isPresent) 1 else 0) + - (if (categoryKey.asKnown().isPresent) 1 else 0) + - (maxItems.asKnown().getOrNull()?.validity() ?: 0) + - (scope.asKnown().getOrNull()?.validity() ?: 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ADD_TO_BATCH = of("add-to-batch") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - ADD_TO_BATCH - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ADD_TO_BATCH, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ADD_TO_BATCH -> Value.ADD_TO_BATCH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ADD_TO_BATCH -> Known.ADD_TO_BATCH - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Defines what items should be retained and passed along to the next steps when the - * batch is released - */ - class Retain - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val count: JsonField, - private val type: JsonField, - private val sortKey: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("count") - @ExcludeMissing - count: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("sort_key") - @ExcludeMissing - sortKey: JsonField = JsonMissing.of(), - ) : this(count, type, sortKey, mutableMapOf()) - - /** - * The number of records to keep in batch. Default is 10 and only configurable - * by requesting from support. When configurable minimum is 2 and maximum - * is 100. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun count(): Long = count.getRequired("count") - - /** - * Keep N number of notifications based on the type. First/Last N based on - * notification received. highest/lowest based on a scoring key providing in the - * data accessed by sort_key - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * Defines the data value data[sort_key] that is used to sort the stored items. - * Required when type is set to highest or lowest. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun sortKey(): Optional = sortKey.getOptional("sort_key") - - /** - * Returns the raw JSON value of [count]. - * - * Unlike [count], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [sortKey]. - * - * Unlike [sortKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("sort_key") - @ExcludeMissing - fun _sortKey(): JsonField = sortKey - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Retain]. - * - * The following fields are required: - * ```java - * .count() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Retain]. */ - class Builder internal constructor() { - - private var count: JsonField? = null - private var type: JsonField? = null - private var sortKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(retain: Retain) = apply { - count = retain.count - type = retain.type - sortKey = retain.sortKey - additionalProperties = retain.additionalProperties.toMutableMap() - } - - /** - * The number of records to keep in batch. Default is 10 and only - * configurable by requesting from support. When configurable minimum is 2 - * and maximum is 100. - */ - fun count(count: Long) = count(JsonField.of(count)) - - /** - * Sets [Builder.count] to an arbitrary JSON value. - * - * You should usually call [Builder.count] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun count(count: JsonField) = apply { this.count = count } - - /** - * Keep N number of notifications based on the type. First/Last N based on - * notification received. highest/lowest based on a scoring key providing in - * the data accessed by sort_key - */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** - * Defines the data value data[sort_key] that is used to sort the stored - * items. Required when type is set to highest or lowest. - */ - fun sortKey(sortKey: String?) = sortKey(JsonField.ofNullable(sortKey)) - - /** Alias for calling [Builder.sortKey] with `sortKey.orElse(null)`. */ - fun sortKey(sortKey: Optional) = sortKey(sortKey.getOrNull()) - - /** - * Sets [Builder.sortKey] to an arbitrary JSON value. - * - * You should usually call [Builder.sortKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun sortKey(sortKey: JsonField) = apply { this.sortKey = sortKey } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Retain]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .count() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Retain = - Retain( - checkRequired("count", count), - checkRequired("type", type), - sortKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Retain = apply { - if (validated) { - return@apply - } - - count() - type().validate() - sortKey() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (count.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (sortKey.asKnown().isPresent) 1 else 0) - - /** - * Keep N number of notifications based on the type. First/Last N based on - * notification received. highest/lowest based on a scoring key providing in the - * data accessed by sort_key - */ - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val FIRST = of("first") - - @JvmField val LAST = of("last") - - @JvmField val HIGHEST = of("highest") - - @JvmField val LOWEST = of("lowest") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - FIRST, - LAST, - HIGHEST, - LOWEST, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FIRST, - LAST, - HIGHEST, - LOWEST, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FIRST -> Value.FIRST - LAST -> Value.LAST - HIGHEST -> Value.HIGHEST - LOWEST -> Value.LOWEST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - FIRST -> Known.FIRST - LAST -> Known.LAST - HIGHEST -> Known.HIGHEST - LOWEST -> Known.LOWEST - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Retain && - count == other.count && - type == other.type && - sortKey == other.sortKey && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(count, type, sortKey, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Retain{count=$count, type=$type, sortKey=$sortKey, additionalProperties=$additionalProperties}" - } - - /** If specified, the batch will release as soon as this number is reached */ - @JsonDeserialize(using = MaxItems.Deserializer::class) - @JsonSerialize(using = MaxItems.Serializer::class) - class MaxItems - private constructor( - private val string: String? = null, - private val integer: Long? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun integer(): Optional = Optional.ofNullable(integer) - - fun isString(): Boolean = string != null - - fun isInteger(): Boolean = integer != null - - fun asString(): String = string.getOrThrow("string") - - fun asInteger(): Long = integer.getOrThrow("integer") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - integer != null -> visitor.visitInteger(integer) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): MaxItems = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitInteger(integer: Long) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitInteger(integer: Long) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MaxItems && - string == other.string && - integer == other.integer - } - - override fun hashCode(): Int = Objects.hash(string, integer) - - override fun toString(): String = - when { - string != null -> "MaxItems{string=$string}" - integer != null -> "MaxItems{integer=$integer}" - _json != null -> "MaxItems{_unknown=$_json}" - else -> throw IllegalStateException("Invalid MaxItems") - } - - companion object { - - @JvmStatic fun ofString(string: String) = MaxItems(string = string) - - @JvmStatic fun ofInteger(integer: Long) = MaxItems(integer = integer) - } - - /** - * An interface that defines how to map each variant of [MaxItems] to a value of - * type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitInteger(integer: Long): T - - /** - * Maps an unknown variant of [MaxItems] to a value of type [T]. - * - * An instance of [MaxItems] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, - * if the SDK is on an older version than the API, then the API may respond - * with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown MaxItems: $json") - } - } - - internal class Deserializer : BaseDeserializer(MaxItems::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): MaxItems { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MaxItems(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - MaxItems(integer = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing - // from object). - 0 -> MaxItems(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then - // use the first completely valid match, or simply the first match - // if none are completely valid. - else -> - bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(MaxItems::class) { - - override fun serialize( - value: MaxItems, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.integer != null -> generator.writeObject(value.integer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid MaxItems") - } - } - } - } - - /** - * Determine the scope of the batching. If user, chosen in this order: recipient, - * profile.user_id, data.user_id, data.userId. If dynamic, then specify where the - * batch_key or a reference to the batch_key - */ - class Scope @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USER = of("user") - - @JvmField val GLOBAL = of("global") - - @JvmField val DYNAMIC = of("dynamic") - - @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) - } - - /** An enum containing [Scope]'s known values. */ - enum class Known { - USER, - GLOBAL, - DYNAMIC, - } - - /** - * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Scope] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USER, - GLOBAL, - DYNAMIC, - /** - * An enum member indicating that [Scope] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USER -> Value.USER - GLOBAL -> Value.GLOBAL - DYNAMIC -> Value.DYNAMIC - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USER -> Known.USER - GLOBAL -> Known.GLOBAL - DYNAMIC -> Known.DYNAMIC - else -> throw CourierInvalidDataException("Unknown Scope: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Scope = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scope && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationAddToBatchStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - maxWaitPeriod == other.maxWaitPeriod && - retain == other.retain && - waitPeriod == other.waitPeriod && - batchId == other.batchId && - batchKey == other.batchKey && - categoryKey == other.categoryKey && - maxItems == other.maxItems && - scope == other.scope && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - if_, - ref, - action, - maxWaitPeriod, - retain, - waitPeriod, - batchId, - batchKey, - categoryKey, - maxItems, - scope, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationAddToBatchStep{if_=$if_, ref=$ref, action=$action, maxWaitPeriod=$maxWaitPeriod, retain=$retain, waitPeriod=$waitPeriod, batchId=$batchId, batchKey=$batchKey, categoryKey=$categoryKey, maxItems=$maxItems, scope=$scope, additionalProperties=$additionalProperties}" - } - - class AutomationThrottleStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val maxAllowed: JsonField, - private val onThrottle: JsonField, - private val period: JsonField, - private val scope: JsonField, - private val shouldAlert: JsonField, - private val throttleKey: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("max_allowed") - @ExcludeMissing - maxAllowed: JsonField = JsonMissing.of(), - @JsonProperty("on_throttle") - @ExcludeMissing - onThrottle: JsonField = JsonMissing.of(), - @JsonProperty("period") - @ExcludeMissing - period: JsonField = JsonMissing.of(), - @JsonProperty("scope") - @ExcludeMissing - scope: JsonField = JsonMissing.of(), - @JsonProperty("should_alert") - @ExcludeMissing - shouldAlert: JsonField = JsonMissing.of(), - @JsonProperty("throttle_key") - @ExcludeMissing - throttleKey: JsonField = JsonMissing.of(), - ) : this( - if_, - ref, - action, - maxAllowed, - onThrottle, - period, - scope, - shouldAlert, - throttleKey, - mutableMapOf(), - ) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * Maximum number of allowed notifications in that timeframe - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun maxAllowed(): Long = maxAllowed.getRequired("max_allowed") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun onThrottle(): OnThrottle = onThrottle.getRequired("on_throttle") - - /** - * Defines the throttle period which corresponds to the max_allowed. Specified as an - * ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun period(): String = period.getRequired("period") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun scope(): Scope = scope.getRequired("scope") - - /** - * Value must be true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun shouldAlert(): Boolean = shouldAlert.getRequired("should_alert") - - /** - * If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) to - * the how the throttle should be identified - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun throttleKey(): Optional = throttleKey.getOptional("throttle_key") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [maxAllowed]. - * - * Unlike [maxAllowed], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_allowed") - @ExcludeMissing - fun _maxAllowed(): JsonField = maxAllowed - - /** - * Returns the raw JSON value of [onThrottle]. - * - * Unlike [onThrottle], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("on_throttle") - @ExcludeMissing - fun _onThrottle(): JsonField = onThrottle - - /** - * Returns the raw JSON value of [period]. - * - * Unlike [period], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("period") @ExcludeMissing fun _period(): JsonField = period - - /** - * Returns the raw JSON value of [scope]. - * - * Unlike [scope], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope - - /** - * Returns the raw JSON value of [shouldAlert]. - * - * Unlike [shouldAlert], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("should_alert") - @ExcludeMissing - fun _shouldAlert(): JsonField = shouldAlert - - /** - * Returns the raw JSON value of [throttleKey]. - * - * Unlike [throttleKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("throttle_key") - @ExcludeMissing - fun _throttleKey(): JsonField = throttleKey - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationThrottleStep]. - * - * The following fields are required: - * ```java - * .action() - * .maxAllowed() - * .onThrottle() - * .period() - * .scope() - * .shouldAlert() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationThrottleStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var maxAllowed: JsonField? = null - private var onThrottle: JsonField? = null - private var period: JsonField? = null - private var scope: JsonField? = null - private var shouldAlert: JsonField? = null - private var throttleKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationThrottleStep: AutomationThrottleStep) = apply { - if_ = automationThrottleStep.if_ - ref = automationThrottleStep.ref - action = automationThrottleStep.action - maxAllowed = automationThrottleStep.maxAllowed - onThrottle = automationThrottleStep.onThrottle - period = automationThrottleStep.period - scope = automationThrottleStep.scope - shouldAlert = automationThrottleStep.shouldAlert - throttleKey = automationThrottleStep.throttleKey - additionalProperties = - automationThrottleStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - /** Maximum number of allowed notifications in that timeframe */ - fun maxAllowed(maxAllowed: Long) = maxAllowed(JsonField.of(maxAllowed)) - - /** - * Sets [Builder.maxAllowed] to an arbitrary JSON value. - * - * You should usually call [Builder.maxAllowed] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun maxAllowed(maxAllowed: JsonField) = apply { - this.maxAllowed = maxAllowed - } - - fun onThrottle(onThrottle: OnThrottle) = onThrottle(JsonField.of(onThrottle)) - - /** - * Sets [Builder.onThrottle] to an arbitrary JSON value. - * - * You should usually call [Builder.onThrottle] with a well-typed [OnThrottle] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun onThrottle(onThrottle: JsonField) = apply { - this.onThrottle = onThrottle - } - - /** - * Defines the throttle period which corresponds to the max_allowed. Specified - * as an ISO 8601 duration, https://en.wikipedia.org/wiki/ISO_8601#Durations - */ - fun period(period: String) = period(JsonField.of(period)) - - /** - * Sets [Builder.period] to an arbitrary JSON value. - * - * You should usually call [Builder.period] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun period(period: JsonField) = apply { this.period = period } - - fun scope(scope: Scope) = scope(JsonField.of(scope)) - - /** - * Sets [Builder.scope] to an arbitrary JSON value. - * - * You should usually call [Builder.scope] with a well-typed [Scope] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun scope(scope: JsonField) = apply { this.scope = scope } - - /** Value must be true */ - fun shouldAlert(shouldAlert: Boolean) = shouldAlert(JsonField.of(shouldAlert)) - - /** - * Sets [Builder.shouldAlert] to an arbitrary JSON value. - * - * You should usually call [Builder.shouldAlert] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun shouldAlert(shouldAlert: JsonField) = apply { - this.shouldAlert = shouldAlert - } - - /** - * If using scope=dynamic, provide the reference (e.g., refs.data.throttle_key) - * to the how the throttle should be identified - */ - fun throttleKey(throttleKey: String?) = - throttleKey(JsonField.ofNullable(throttleKey)) - - /** Alias for calling [Builder.throttleKey] with `throttleKey.orElse(null)`. */ - fun throttleKey(throttleKey: Optional) = - throttleKey(throttleKey.getOrNull()) - - /** - * Sets [Builder.throttleKey] to an arbitrary JSON value. - * - * You should usually call [Builder.throttleKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun throttleKey(throttleKey: JsonField) = apply { - this.throttleKey = throttleKey - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationThrottleStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .maxAllowed() - * .onThrottle() - * .period() - * .scope() - * .shouldAlert() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationThrottleStep = - AutomationThrottleStep( - if_, - ref, - checkRequired("action", action), - checkRequired("maxAllowed", maxAllowed), - checkRequired("onThrottle", onThrottle), - checkRequired("period", period), - checkRequired("scope", scope), - checkRequired("shouldAlert", shouldAlert), - throttleKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationThrottleStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - maxAllowed() - onThrottle().validate() - period() - scope().validate() - shouldAlert() - throttleKey() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (maxAllowed.asKnown().isPresent) 1 else 0) + - (onThrottle.asKnown().getOrNull()?.validity() ?: 0) + - (if (period.asKnown().isPresent) 1 else 0) + - (scope.asKnown().getOrNull()?.validity() ?: 0) + - (if (shouldAlert.asKnown().isPresent) 1 else 0) + - (if (throttleKey.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val THROTTLE = of("throttle") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - THROTTLE - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THROTTLE, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THROTTLE -> Value.THROTTLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - THROTTLE -> Known.THROTTLE - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class OnThrottle - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val nodeId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("\$node_id") - @ExcludeMissing - nodeId: JsonField = JsonMissing.of() - ) : this(nodeId, mutableMapOf()) - - /** - * The node to go to if the request is throttled - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun nodeId(): String = nodeId.getRequired("\$node_id") - - /** - * Returns the raw JSON value of [nodeId]. - * - * Unlike [nodeId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("\$node_id") - @ExcludeMissing - fun _nodeId(): JsonField = nodeId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [OnThrottle]. - * - * The following fields are required: - * ```java - * .nodeId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OnThrottle]. */ - class Builder internal constructor() { - - private var nodeId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(onThrottle: OnThrottle) = apply { - nodeId = onThrottle.nodeId - additionalProperties = onThrottle.additionalProperties.toMutableMap() - } - - /** The node to go to if the request is throttled */ - fun nodeId(nodeId: String) = nodeId(JsonField.of(nodeId)) - - /** - * Sets [Builder.nodeId] to an arbitrary JSON value. - * - * You should usually call [Builder.nodeId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun nodeId(nodeId: JsonField) = apply { this.nodeId = nodeId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OnThrottle]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .nodeId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): OnThrottle = - OnThrottle( - checkRequired("nodeId", nodeId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): OnThrottle = apply { - if (validated) { - return@apply - } - - nodeId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (nodeId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is OnThrottle && - nodeId == other.nodeId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(nodeId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "OnThrottle{nodeId=$nodeId, additionalProperties=$additionalProperties}" - } - - class Scope @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val USER = of("user") - - @JvmField val GLOBAL = of("global") - - @JvmField val DYNAMIC = of("dynamic") - - @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) - } - - /** An enum containing [Scope]'s known values. */ - enum class Known { - USER, - GLOBAL, - DYNAMIC, - } - - /** - * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Scope] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USER, - GLOBAL, - DYNAMIC, - /** - * An enum member indicating that [Scope] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USER -> Value.USER - GLOBAL -> Value.GLOBAL - DYNAMIC -> Value.DYNAMIC - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - USER -> Known.USER - GLOBAL -> Known.GLOBAL - DYNAMIC -> Known.DYNAMIC - else -> throw CourierInvalidDataException("Unknown Scope: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Scope = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Scope && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationThrottleStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - maxAllowed == other.maxAllowed && - onThrottle == other.onThrottle && - period == other.period && - scope == other.scope && - shouldAlert == other.shouldAlert && - throttleKey == other.throttleKey && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - if_, - ref, - action, - maxAllowed, - onThrottle, - period, - scope, - shouldAlert, - throttleKey, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationThrottleStep{if_=$if_, ref=$ref, action=$action, maxAllowed=$maxAllowed, onThrottle=$onThrottle, period=$period, scope=$scope, shouldAlert=$shouldAlert, throttleKey=$throttleKey, additionalProperties=$additionalProperties}" - } - - class AutomationCancelStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val cancelationToken: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("cancelation_token") - @ExcludeMissing - cancelationToken: JsonField = JsonMissing.of(), - ) : this(if_, ref, action, cancelationToken, mutableMapOf()) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun cancelationToken(): Optional = - cancelationToken.getOptional("cancelation_token") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [cancelationToken]. - * - * Unlike [cancelationToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("cancelation_token") - @ExcludeMissing - fun _cancelationToken(): JsonField = cancelationToken - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationCancelStep]. - * - * The following fields are required: - * ```java - * .action() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationCancelStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var cancelationToken: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationCancelStep: AutomationCancelStep) = apply { - if_ = automationCancelStep.if_ - ref = automationCancelStep.ref - action = automationCancelStep.action - cancelationToken = automationCancelStep.cancelationToken - additionalProperties = - automationCancelStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - fun cancelationToken(cancelationToken: String?) = - cancelationToken(JsonField.ofNullable(cancelationToken)) - - /** - * Alias for calling [Builder.cancelationToken] with - * `cancelationToken.orElse(null)`. - */ - fun cancelationToken(cancelationToken: Optional) = - cancelationToken(cancelationToken.getOrNull()) - - /** - * Sets [Builder.cancelationToken] to an arbitrary JSON value. - * - * You should usually call [Builder.cancelationToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun cancelationToken(cancelationToken: JsonField) = apply { - this.cancelationToken = cancelationToken - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationCancelStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationCancelStep = - AutomationCancelStep( - if_, - ref, - checkRequired("action", action), - cancelationToken, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationCancelStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - cancelationToken() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (cancelationToken.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val CANCEL = of("cancel") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - CANCEL - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCEL, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCEL -> Value.CANCEL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - CANCEL -> Known.CANCEL - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationCancelStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - cancelationToken == other.cancelationToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(if_, ref, action, cancelationToken, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationCancelStep{if_=$if_, ref=$ref, action=$action, cancelationToken=$cancelationToken, additionalProperties=$additionalProperties}" - } - - class AutomationDelayStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val duration: JsonField, - private val until: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("duration") - @ExcludeMissing - duration: JsonField = JsonMissing.of(), - @JsonProperty("until") - @ExcludeMissing - until: JsonField = JsonMissing.of(), - ) : this(if_, ref, action, duration, until, mutableMapOf()) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string - * for how long to delay for - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") - - /** - * The ISO 8601 timestamp for when the delay should end - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun until(): Optional = until.getOptional("until") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("duration") - @ExcludeMissing - fun _duration(): JsonField = duration - - /** - * Returns the raw JSON value of [until]. - * - * Unlike [until], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationDelayStep]. - * - * The following fields are required: - * ```java - * .action() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationDelayStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var duration: JsonField = JsonMissing.of() - private var until: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationDelayStep: AutomationDelayStep) = apply { - if_ = automationDelayStep.if_ - ref = automationDelayStep.ref - action = automationDelayStep.action - duration = automationDelayStep.duration - until = automationDelayStep.until - additionalProperties = - automationDelayStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - /** - * The [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) - * string for how long to delay for - */ - fun duration(duration: String?) = duration(JsonField.ofNullable(duration)) - - /** Alias for calling [Builder.duration] with `duration.orElse(null)`. */ - fun duration(duration: Optional) = duration(duration.getOrNull()) - - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** The ISO 8601 timestamp for when the delay should end */ - fun until(until: String?) = until(JsonField.ofNullable(until)) - - /** Alias for calling [Builder.until] with `until.orElse(null)`. */ - fun until(until: Optional) = until(until.getOrNull()) - - /** - * Sets [Builder.until] to an arbitrary JSON value. - * - * You should usually call [Builder.until] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun until(until: JsonField) = apply { this.until = until } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationDelayStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationDelayStep = - AutomationDelayStep( - if_, - ref, - checkRequired("action", action), - duration, - until, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationDelayStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - duration() - until() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (duration.asKnown().isPresent) 1 else 0) + - (if (until.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val DELAY = of("delay") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - DELAY - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DELAY, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DELAY -> Value.DELAY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - DELAY -> Known.DELAY - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationDelayStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - duration == other.duration && - until == other.until && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(if_, ref, action, duration, until, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationDelayStep{if_=$if_, ref=$ref, action=$action, duration=$duration, until=$until, additionalProperties=$additionalProperties}" - } - - class AutomationFetchDataStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val mergeStrategy: JsonField, - private val webhook: JsonField, - private val idempotencyExpiry: JsonField, - private val idempotencyKey: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("merge_strategy") - @ExcludeMissing - mergeStrategy: JsonField = JsonMissing.of(), - @JsonProperty("webhook") - @ExcludeMissing - webhook: JsonField = JsonMissing.of(), - @JsonProperty("idempotency_expiry") - @ExcludeMissing - idempotencyExpiry: JsonField = JsonMissing.of(), - @JsonProperty("idempotency_key") - @ExcludeMissing - idempotencyKey: JsonField = JsonMissing.of(), - ) : this( - if_, - ref, - action, - mergeStrategy, - webhook, - idempotencyExpiry, - idempotencyKey, - mutableMapOf(), - ) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun mergeStrategy(): MergeAlgorithm = mergeStrategy.getRequired("merge_strategy") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun webhook(): Webhook = webhook.getRequired("webhook") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun idempotencyExpiry(): Optional = - idempotencyExpiry.getOptional("idempotency_expiry") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun idempotencyKey(): Optional = - idempotencyKey.getOptional("idempotency_key") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [mergeStrategy]. - * - * Unlike [mergeStrategy], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("merge_strategy") - @ExcludeMissing - fun _mergeStrategy(): JsonField = mergeStrategy - - /** - * Returns the raw JSON value of [webhook]. - * - * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("webhook") - @ExcludeMissing - fun _webhook(): JsonField = webhook - - /** - * Returns the raw JSON value of [idempotencyExpiry]. - * - * Unlike [idempotencyExpiry], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("idempotency_expiry") - @ExcludeMissing - fun _idempotencyExpiry(): JsonField = idempotencyExpiry - - /** - * Returns the raw JSON value of [idempotencyKey]. - * - * Unlike [idempotencyKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("idempotency_key") - @ExcludeMissing - fun _idempotencyKey(): JsonField = idempotencyKey - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationFetchDataStep]. - * - * The following fields are required: - * ```java - * .action() - * .mergeStrategy() - * .webhook() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationFetchDataStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var mergeStrategy: JsonField? = null - private var webhook: JsonField? = null - private var idempotencyExpiry: JsonField = JsonMissing.of() - private var idempotencyKey: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationFetchDataStep: AutomationFetchDataStep) = apply { - if_ = automationFetchDataStep.if_ - ref = automationFetchDataStep.ref - action = automationFetchDataStep.action - mergeStrategy = automationFetchDataStep.mergeStrategy - webhook = automationFetchDataStep.webhook - idempotencyExpiry = automationFetchDataStep.idempotencyExpiry - idempotencyKey = automationFetchDataStep.idempotencyKey - additionalProperties = - automationFetchDataStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - fun mergeStrategy(mergeStrategy: MergeAlgorithm) = - mergeStrategy(JsonField.of(mergeStrategy)) - - /** - * Sets [Builder.mergeStrategy] to an arbitrary JSON value. - * - * You should usually call [Builder.mergeStrategy] with a well-typed - * [MergeAlgorithm] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun mergeStrategy(mergeStrategy: JsonField) = apply { - this.mergeStrategy = mergeStrategy - } - - fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) - - /** - * Sets [Builder.webhook] to an arbitrary JSON value. - * - * You should usually call [Builder.webhook] with a well-typed [Webhook] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun webhook(webhook: JsonField) = apply { this.webhook = webhook } - - fun idempotencyExpiry(idempotencyExpiry: String?) = - idempotencyExpiry(JsonField.ofNullable(idempotencyExpiry)) - - /** - * Alias for calling [Builder.idempotencyExpiry] with - * `idempotencyExpiry.orElse(null)`. - */ - fun idempotencyExpiry(idempotencyExpiry: Optional) = - idempotencyExpiry(idempotencyExpiry.getOrNull()) - - /** - * Sets [Builder.idempotencyExpiry] to an arbitrary JSON value. - * - * You should usually call [Builder.idempotencyExpiry] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun idempotencyExpiry(idempotencyExpiry: JsonField) = apply { - this.idempotencyExpiry = idempotencyExpiry - } - - fun idempotencyKey(idempotencyKey: String?) = - idempotencyKey(JsonField.ofNullable(idempotencyKey)) - - /** - * Alias for calling [Builder.idempotencyKey] with - * `idempotencyKey.orElse(null)`. - */ - fun idempotencyKey(idempotencyKey: Optional) = - idempotencyKey(idempotencyKey.getOrNull()) - - /** - * Sets [Builder.idempotencyKey] to an arbitrary JSON value. - * - * You should usually call [Builder.idempotencyKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun idempotencyKey(idempotencyKey: JsonField) = apply { - this.idempotencyKey = idempotencyKey - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationFetchDataStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .mergeStrategy() - * .webhook() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationFetchDataStep = - AutomationFetchDataStep( - if_, - ref, - checkRequired("action", action), - checkRequired("mergeStrategy", mergeStrategy), - checkRequired("webhook", webhook), - idempotencyExpiry, - idempotencyKey, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationFetchDataStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - mergeStrategy().validate() - webhook().validate() - idempotencyExpiry() - idempotencyKey() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (mergeStrategy.asKnown().getOrNull()?.validity() ?: 0) + - (webhook.asKnown().getOrNull()?.validity() ?: 0) + - (if (idempotencyExpiry.asKnown().isPresent) 1 else 0) + - (if (idempotencyKey.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val FETCH_DATA = of("fetch-data") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - FETCH_DATA - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FETCH_DATA, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FETCH_DATA -> Value.FETCH_DATA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - FETCH_DATA -> Known.FETCH_DATA - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Webhook - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val method: JsonField, - private val url: JsonField, - private val body: JsonField, - private val headers: JsonField, - private val params: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("method") - @ExcludeMissing - method: JsonField = JsonMissing.of(), - @JsonProperty("url") - @ExcludeMissing - url: JsonField = JsonMissing.of(), - @JsonProperty("body") - @ExcludeMissing - body: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("params") - @ExcludeMissing - params: JsonField = JsonMissing.of(), - ) : this(method, url, body, headers, params, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun method(): Method = method.getRequired("method") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun url(): String = url.getRequired("url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun body(): Optional = body.getOptional("body") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun params(): Optional = params.getOptional("params") - - /** - * Returns the raw JSON value of [method]. - * - * Unlike [method], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("method") - @ExcludeMissing - fun _method(): JsonField = method - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [body]. - * - * Unlike [body], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("headers") - @ExcludeMissing - fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [params]. - * - * Unlike [params], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("params") - @ExcludeMissing - fun _params(): JsonField = params - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Webhook]. - * - * The following fields are required: - * ```java - * .method() - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Webhook]. */ - class Builder internal constructor() { - - private var method: JsonField? = null - private var url: JsonField? = null - private var body: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var params: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(webhook: Webhook) = apply { - method = webhook.method - url = webhook.url - body = webhook.body - headers = webhook.headers - params = webhook.params - additionalProperties = webhook.additionalProperties.toMutableMap() - } - - fun method(method: Method) = method(JsonField.of(method)) - - /** - * Sets [Builder.method] to an arbitrary JSON value. - * - * You should usually call [Builder.method] with a well-typed [Method] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun method(method: JsonField) = apply { this.method = method } - - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - fun body(body: Body?) = body(JsonField.ofNullable(body)) - - /** Alias for calling [Builder.body] with `body.orElse(null)`. */ - fun body(body: Optional) = body(body.getOrNull()) - - /** - * Sets [Builder.body] to an arbitrary JSON value. - * - * You should usually call [Builder.body] with a well-typed [Body] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun body(body: JsonField) = apply { this.body = body } - - fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) - - /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ - fun headers(headers: Optional) = headers(headers.getOrNull()) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - fun params(params: Params?) = params(JsonField.ofNullable(params)) - - /** Alias for calling [Builder.params] with `params.orElse(null)`. */ - fun params(params: Optional) = params(params.getOrNull()) - - /** - * Sets [Builder.params] to an arbitrary JSON value. - * - * You should usually call [Builder.params] with a well-typed [Params] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun params(params: JsonField) = apply { this.params = params } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Webhook]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .method() - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Webhook = - Webhook( - checkRequired("method", method), - checkRequired("url", url), - body, - headers, - params, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Webhook = apply { - if (validated) { - return@apply - } - - method().validate() - url() - body().ifPresent { it.validate() } - headers().ifPresent { it.validate() } - params().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (method.asKnown().getOrNull()?.validity() ?: 0) + - (if (url.asKnown().isPresent) 1 else 0) + - (body.asKnown().getOrNull()?.validity() ?: 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (params.asKnown().getOrNull()?.validity() ?: 0) - - class Method - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val GET = of("GET") - - @JvmField val POST = of("POST") - - @JvmStatic fun of(value: String) = Method(JsonField.of(value)) - } - - /** An enum containing [Method]'s known values. */ - enum class Known { - GET, - POST, - } - - /** - * An enum containing [Method]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Method] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GET, - POST, - /** - * An enum member indicating that [Method] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GET -> Value.GET - POST -> Value.POST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - GET -> Known.GET - POST -> Known.POST - else -> throw CourierInvalidDataException("Unknown Method: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Method = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Method && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Body - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Body = Body(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{additionalProperties=$additionalProperties}" - } - - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Headers]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Headers{additionalProperties=$additionalProperties}" - } - - class Params - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Params]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Params]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(params: Params) = apply { - additionalProperties = params.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Params]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): Params = Params(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Params = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Params && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Params{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Webhook && - method == other.method && - url == other.url && - body == other.body && - headers == other.headers && - params == other.params && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(method, url, body, headers, params, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Webhook{method=$method, url=$url, body=$body, headers=$headers, params=$params, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationFetchDataStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - mergeStrategy == other.mergeStrategy && - webhook == other.webhook && - idempotencyExpiry == other.idempotencyExpiry && - idempotencyKey == other.idempotencyKey && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - if_, - ref, - action, - mergeStrategy, - webhook, - idempotencyExpiry, - idempotencyKey, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationFetchDataStep{if_=$if_, ref=$ref, action=$action, mergeStrategy=$mergeStrategy, webhook=$webhook, idempotencyExpiry=$idempotencyExpiry, idempotencyKey=$idempotencyKey, additionalProperties=$additionalProperties}" - } - - class AutomationInvokeStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("template") - @ExcludeMissing - template: JsonField = JsonMissing.of(), - ) : this(if_, ref, action, template, mutableMapOf()) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun template(): String = template.getRequired("template") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("template") - @ExcludeMissing - fun _template(): JsonField = template - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationInvokeStep]. - * - * The following fields are required: - * ```java - * .action() - * .template() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationInvokeStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var template: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationInvokeStep: AutomationInvokeStep) = apply { - if_ = automationInvokeStep.if_ - ref = automationInvokeStep.ref - action = automationInvokeStep.action - template = automationInvokeStep.template - additionalProperties = - automationInvokeStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - fun template(template: String) = template(JsonField.of(template)) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationInvokeStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .template() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationInvokeStep = - AutomationInvokeStep( - if_, - ref, - checkRequired("action", action), - checkRequired("template", template), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationInvokeStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (template.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val INVOKE = of("invoke") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - INVOKE - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INVOKE, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INVOKE -> Value.INVOKE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - INVOKE -> Known.INVOKE - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationInvokeStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(if_, ref, action, template, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationInvokeStep{if_=$if_, ref=$ref, action=$action, template=$template, additionalProperties=$additionalProperties}" - } - - class AutomationSendStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val brand: JsonField, - private val data: JsonField, - private val override: JsonField, - private val profile: JsonValue, - private val recipient: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("brand") - @ExcludeMissing - brand: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("override") - @ExcludeMissing - override: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), - @JsonProperty("recipient") - @ExcludeMissing - recipient: JsonField = JsonMissing.of(), - @JsonProperty("template") - @ExcludeMissing - template: JsonField = JsonMissing.of(), - ) : this( - if_, - ref, - action, - brand, - data, - override, - profile, - recipient, - template, - mutableMapOf(), - ) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun brand(): Optional = brand.getOptional("brand") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun override(): Optional = override.getOptional("override") - - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun template(): Optional = template.getOptional("template") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [override]. - * - * Unlike [override], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("override") - @ExcludeMissing - fun _override(): JsonField = override - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("recipient") - @ExcludeMissing - fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("template") - @ExcludeMissing - fun _template(): JsonField = template - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationSendStep]. - * - * The following fields are required: - * ```java - * .action() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationSendStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var brand: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var override: JsonField = JsonMissing.of() - private var profile: JsonValue = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var template: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationSendStep: AutomationSendStep) = apply { - if_ = automationSendStep.if_ - ref = automationSendStep.ref - action = automationSendStep.action - brand = automationSendStep.brand - data = automationSendStep.data - override = automationSendStep.override - profile = automationSendStep.profile - recipient = automationSendStep.recipient - template = automationSendStep.template - additionalProperties = - automationSendStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun brand(brand: JsonField) = apply { this.brand = brand } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun override(override: Override?) = override(JsonField.ofNullable(override)) - - /** Alias for calling [Builder.override] with `override.orElse(null)`. */ - fun override(override: Optional) = override(override.getOrNull()) - - /** - * Sets [Builder.override] to an arbitrary JSON value. - * - * You should usually call [Builder.override] with a well-typed [Override] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun override(override: JsonField) = apply { this.override = override } - - fun profile(profile: JsonValue) = apply { this.profile = profile } - - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun recipient(recipient: JsonField) = apply { - this.recipient = recipient - } - - fun template(template: String?) = template(JsonField.ofNullable(template)) - - /** Alias for calling [Builder.template] with `template.orElse(null)`. */ - fun template(template: Optional) = template(template.getOrNull()) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationSendStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationSendStep = - AutomationSendStep( - if_, - ref, - checkRequired("action", action), - brand, - data, - override, - profile, - recipient, - template, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationSendStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - brand() - data().ifPresent { it.validate() } - override().ifPresent { it.validate() } - recipient() - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (brand.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (override.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (if (template.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val SEND = of("send") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - SEND - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEND, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEND -> Value.SEND - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SEND -> Known.SEND - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Override - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Override]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Override]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(override: Override) = apply { - additionalProperties = override.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Override]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Override = Override(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Override = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Override && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Override{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationSendStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - brand == other.brand && - data == other.data && - override == other.override && - profile == other.profile && - recipient == other.recipient && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - if_, - ref, - action, - brand, - data, - override, - profile, - recipient, - template, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationSendStep{if_=$if_, ref=$ref, action=$action, brand=$brand, data=$data, override=$override, profile=$profile, recipient=$recipient, template=$template, additionalProperties=$additionalProperties}" - } - - class AutomationV2SendStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val message: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("message") - @ExcludeMissing - message: JsonField = JsonMissing.of(), - ) : this(if_, ref, action, message, mutableMapOf()) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * Describes the content of the message in a way that will work for email, push, - * chat, or any channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun message(): Message = message.getRequired("message") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("message") - @ExcludeMissing - fun _message(): JsonField = message - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationV2SendStep]. - * - * The following fields are required: - * ```java - * .action() - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationV2SendStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var message: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationV2SendStep: AutomationV2SendStep) = apply { - if_ = automationV2SendStep.if_ - ref = automationV2SendStep.ref - action = automationV2SendStep.action - message = automationV2SendStep.message - additionalProperties = - automationV2SendStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - /** - * Describes the content of the message in a way that will work for email, push, - * chat, or any channel. - */ - fun message(message: Message) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [Message] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - /** Alias for calling [message] with `Message.ofContent(content)`. */ - fun message(content: Message.ContentMessage) = - message(Message.ofContent(content)) - - /** Alias for calling [message] with `Message.ofTemplate(template)`. */ - fun message(template: Message.TemplateMessage) = - message(Message.ofTemplate(template)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationV2SendStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationV2SendStep = - AutomationV2SendStep( - if_, - ref, - checkRequired("action", action), - checkRequired("message", message), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationV2SendStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - message().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (message.asKnown().getOrNull()?.validity() ?: 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val SEND = of("send") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - SEND - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEND, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEND -> Value.SEND - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SEND -> Known.SEND - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationV2SendStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - message == other.message && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(if_, ref, action, message, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationV2SendStep{if_=$if_, ref=$ref, action=$action, message=$message, additionalProperties=$additionalProperties}" - } - - class AutomationSendListStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val if_: JsonField, - private val ref: JsonField, - private val action: JsonField, - private val list: JsonField, - private val brand: JsonField, - private val data: JsonField, - private val override: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("list") - @ExcludeMissing - list: JsonField = JsonMissing.of(), - @JsonProperty("brand") - @ExcludeMissing - brand: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("override") - @ExcludeMissing - override: JsonField = JsonMissing.of(), - @JsonProperty("template") - @ExcludeMissing - template: JsonField = JsonMissing.of(), - ) : this(if_, ref, action, list, brand, data, override, template, mutableMapOf()) - - fun toAutomationStep(): AutomationStep = - AutomationStep.builder().if_(if_).ref(ref).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun list(): String = list.getRequired("list") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun brand(): Optional = brand.getOptional("brand") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun override(): Optional = override.getOptional("override") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun template(): Optional = template.getOptional("template") - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [list]. - * - * Unlike [list], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("list") @ExcludeMissing fun _list(): JsonField = list - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [override]. - * - * Unlike [override], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("override") - @ExcludeMissing - fun _override(): JsonField = override - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("template") - @ExcludeMissing - fun _template(): JsonField = template - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationSendListStep]. - * - * The following fields are required: - * ```java - * .action() - * .list() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationSendListStep]. */ - class Builder internal constructor() { - - private var if_: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var action: JsonField? = null - private var list: JsonField? = null - private var brand: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var override: JsonField = JsonMissing.of() - private var template: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationSendListStep: AutomationSendListStep) = apply { - if_ = automationSendListStep.if_ - ref = automationSendListStep.ref - action = automationSendListStep.action - list = automationSendListStep.list - brand = automationSendListStep.brand - data = automationSendListStep.data - override = automationSendListStep.override - template = automationSendListStep.template - additionalProperties = - automationSendListStep.additionalProperties.toMutableMap() - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - fun list(list: String) = list(JsonField.of(list)) - - /** - * Sets [Builder.list] to an arbitrary JSON value. - * - * You should usually call [Builder.list] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun list(list: JsonField) = apply { this.list = list } - - fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun brand(brand: JsonField) = apply { this.brand = brand } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun override(override: Override?) = override(JsonField.ofNullable(override)) - - /** Alias for calling [Builder.override] with `override.orElse(null)`. */ - fun override(override: Optional) = override(override.getOrNull()) - - /** - * Sets [Builder.override] to an arbitrary JSON value. - * - * You should usually call [Builder.override] with a well-typed [Override] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun override(override: JsonField) = apply { this.override = override } - - fun template(template: String?) = template(JsonField.ofNullable(template)) - - /** Alias for calling [Builder.template] with `template.orElse(null)`. */ - fun template(template: Optional) = template(template.getOrNull()) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationSendListStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .list() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationSendListStep = - AutomationSendListStep( - if_, - ref, - checkRequired("action", action), - checkRequired("list", list), - brand, - data, - override, - template, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationSendListStep = apply { - if (validated) { - return@apply - } - - if_() - ref() - action().validate() - list() - brand() - data().ifPresent { it.validate() } - override().ifPresent { it.validate() } - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (if_.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (action.asKnown().getOrNull()?.validity() ?: 0) + - (if (list.asKnown().isPresent) 1 else 0) + - (if (brand.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (override.asKnown().getOrNull()?.validity() ?: 0) + - (if (template.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val SEND_LIST = of("send-list") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - SEND_LIST - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SEND_LIST, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SEND_LIST -> Value.SEND_LIST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SEND_LIST -> Known.SEND_LIST - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Override - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Override]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Override]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(override: Override) = apply { - additionalProperties = override.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Override]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Override = Override(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Override = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Override && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Override{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationSendListStep && - if_ == other.if_ && - ref == other.ref && - action == other.action && - list == other.list && - brand == other.brand && - data == other.data && - override == other.override && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - if_, - ref, - action, - list, - brand, - data, - override, - template, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationSendListStep{if_=$if_, ref=$ref, action=$action, list=$list, brand=$brand, data=$data, override=$override, template=$template, additionalProperties=$additionalProperties}" - } - - class AutomationUpdateProfileStep - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val action: JsonField, - private val merge: JsonField, - private val profile: JsonValue, - private val recipientId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("action") - @ExcludeMissing - action: JsonField = JsonMissing.of(), - @JsonProperty("merge") - @ExcludeMissing - merge: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), - @JsonProperty("recipient_id") - @ExcludeMissing - recipientId: JsonField = JsonMissing.of(), - ) : this(action, merge, profile, recipientId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun action(): Action = action.getRequired("action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun merge(): MergeAlgorithm = merge.getRequired("merge") - - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun recipientId(): String = recipientId.getRequired("recipient_id") - - /** - * Returns the raw JSON value of [action]. - * - * Unlike [action], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action - - /** - * Returns the raw JSON value of [merge]. - * - * Unlike [merge], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("merge") - @ExcludeMissing - fun _merge(): JsonField = merge - - /** - * Returns the raw JSON value of [recipientId]. - * - * Unlike [recipientId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("recipient_id") - @ExcludeMissing - fun _recipientId(): JsonField = recipientId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AutomationUpdateProfileStep]. - * - * The following fields are required: - * ```java - * .action() - * .merge() - * .profile() - * .recipientId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AutomationUpdateProfileStep]. */ - class Builder internal constructor() { - - private var action: JsonField? = null - private var merge: JsonField? = null - private var profile: JsonValue? = null - private var recipientId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(automationUpdateProfileStep: AutomationUpdateProfileStep) = - apply { - action = automationUpdateProfileStep.action - merge = automationUpdateProfileStep.merge - profile = automationUpdateProfileStep.profile - recipientId = automationUpdateProfileStep.recipientId - additionalProperties = - automationUpdateProfileStep.additionalProperties.toMutableMap() - } - - fun action(action: Action) = action(JsonField.of(action)) - - /** - * Sets [Builder.action] to an arbitrary JSON value. - * - * You should usually call [Builder.action] with a well-typed [Action] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun action(action: JsonField) = apply { this.action = action } - - fun merge(merge: MergeAlgorithm) = merge(JsonField.of(merge)) - - /** - * Sets [Builder.merge] to an arbitrary JSON value. - * - * You should usually call [Builder.merge] with a well-typed [MergeAlgorithm] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun merge(merge: JsonField) = apply { this.merge = merge } - - fun profile(profile: JsonValue) = apply { this.profile = profile } - - fun recipientId(recipientId: String) = recipientId(JsonField.of(recipientId)) - - /** - * Sets [Builder.recipientId] to an arbitrary JSON value. - * - * You should usually call [Builder.recipientId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun recipientId(recipientId: JsonField) = apply { - this.recipientId = recipientId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AutomationUpdateProfileStep]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .action() - * .merge() - * .profile() - * .recipientId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AutomationUpdateProfileStep = - AutomationUpdateProfileStep( - checkRequired("action", action), - checkRequired("merge", merge), - checkRequired("profile", profile), - checkRequired("recipientId", recipientId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AutomationUpdateProfileStep = apply { - if (validated) { - return@apply - } - - action().validate() - merge().validate() - recipientId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (action.asKnown().getOrNull()?.validity() ?: 0) + - (merge.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipientId.asKnown().isPresent) 1 else 0) - - class Action - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val UPDATE_PROFILE = of("update-profile") - - @JvmStatic fun of(value: String) = Action(JsonField.of(value)) - } - - /** An enum containing [Action]'s known values. */ - enum class Known { - UPDATE_PROFILE - } - - /** - * An enum containing [Action]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Action] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - UPDATE_PROFILE, - /** - * An enum member indicating that [Action] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - UPDATE_PROFILE -> Value.UPDATE_PROFILE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - UPDATE_PROFILE -> Known.UPDATE_PROFILE - else -> throw CourierInvalidDataException("Unknown Action: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Action = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Action && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AutomationUpdateProfileStep && - action == other.action && - merge == other.merge && - profile == other.profile && - recipientId == other.recipientId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(action, merge, profile, recipientId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AutomationUpdateProfileStep{action=$action, merge=$merge, profile=$profile, recipientId=$recipientId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Automation && - steps == other.steps && - cancelationToken == other.cancelationToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(steps, cancelationToken, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Automation{steps=$steps, cancelationToken=$cancelationToken, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InvokeInvokeAdHocParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "InvokeInvokeAdHocParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt deleted file mode 100644 index 88e652c3..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParams.kt +++ /dev/null @@ -1,224 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Invoke an automation run from an automation template. */ -class InvokeInvokeByTemplateParams -private constructor( - private val templateId: String?, - private val automationInvokeParams: AutomationInvokeParams, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun templateId(): Optional = Optional.ofNullable(templateId) - - fun automationInvokeParams(): AutomationInvokeParams = automationInvokeParams - - fun _additionalBodyProperties(): Map = - automationInvokeParams._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [InvokeInvokeByTemplateParams]. - * - * The following fields are required: - * ```java - * .automationInvokeParams() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InvokeInvokeByTemplateParams]. */ - class Builder internal constructor() { - - private var templateId: String? = null - private var automationInvokeParams: AutomationInvokeParams? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(invokeInvokeByTemplateParams: InvokeInvokeByTemplateParams) = apply { - templateId = invokeInvokeByTemplateParams.templateId - automationInvokeParams = invokeInvokeByTemplateParams.automationInvokeParams - additionalHeaders = invokeInvokeByTemplateParams.additionalHeaders.toBuilder() - additionalQueryParams = invokeInvokeByTemplateParams.additionalQueryParams.toBuilder() - } - - fun templateId(templateId: String?) = apply { this.templateId = templateId } - - /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ - fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) - - fun automationInvokeParams(automationInvokeParams: AutomationInvokeParams) = apply { - this.automationInvokeParams = automationInvokeParams - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [InvokeInvokeByTemplateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .automationInvokeParams() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InvokeInvokeByTemplateParams = - InvokeInvokeByTemplateParams( - templateId, - checkRequired("automationInvokeParams", automationInvokeParams), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): AutomationInvokeParams = automationInvokeParams - - fun _pathParam(index: Int): String = - when (index) { - 0 -> templateId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InvokeInvokeByTemplateParams && - templateId == other.templateId && - automationInvokeParams == other.automationInvokeParams && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(templateId, automationInvokeParams, additionalHeaders, additionalQueryParams) - - override fun toString() = - "InvokeInvokeByTemplateParams{templateId=$templateId, automationInvokeParams=$automationInvokeParams, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt deleted file mode 100644 index b6dce81e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/automations/invoke/MergeAlgorithm.kt +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.Enum -import com.courier.api.core.JsonField -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class MergeAlgorithm @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't match - * any known member, and you want to know that value. For example, if the SDK is on an older - * version than the API, then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val REPLACE = of("replace") - - @JvmField val NONE = of("none") - - @JvmField val OVERWRITE = of("overwrite") - - @JvmField val SOFT_MERGE = of("soft-merge") - - @JvmStatic fun of(value: String) = MergeAlgorithm(JsonField.of(value)) - } - - /** An enum containing [MergeAlgorithm]'s known values. */ - enum class Known { - REPLACE, - NONE, - OVERWRITE, - SOFT_MERGE, - } - - /** - * An enum containing [MergeAlgorithm]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [MergeAlgorithm] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the SDK - * is on an older version than the API, then the API may respond with new members that the SDK - * is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - REPLACE, - NONE, - OVERWRITE, - SOFT_MERGE, - /** - * An enum member indicating that [MergeAlgorithm] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if - * the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want to - * throw for the unknown case. - */ - fun value(): Value = - when (this) { - REPLACE -> Value.REPLACE - NONE -> Value.NONE - OVERWRITE -> Value.OVERWRITE - SOFT_MERGE -> Value.SOFT_MERGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't want - * to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - REPLACE -> Known.REPLACE - NONE -> Known.NONE - OVERWRITE -> Known.OVERWRITE - SOFT_MERGE -> Known.SOFT_MERGE - else -> throw CourierInvalidDataException("Unknown MergeAlgorithm: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging and - * generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): MergeAlgorithm = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MergeAlgorithm && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt deleted file mode 100644 index 5bfec748..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Brand.kt +++ /dev/null @@ -1,452 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class Brand -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val created: JsonField, - private val name: JsonField, - private val published: JsonField, - private val settings: JsonField, - private val updated: JsonField, - private val version: JsonField, - private val id: JsonField, - private val snippets: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("published") @ExcludeMissing published: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - settings: JsonField = JsonMissing.of(), - @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("snippets") - @ExcludeMissing - snippets: JsonField = JsonMissing.of(), - ) : this(created, name, published, settings, updated, version, id, snippets, mutableMapOf()) - - /** - * The date/time of when the brand was created. Represented in milliseconds since Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun created(): Long = created.getRequired("created") - - /** - * Brand name - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The date/time of when the brand was published. Represented in milliseconds since Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun published(): Long = published.getRequired("published") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun settings(): BrandSettings = settings.getRequired("settings") - - /** - * The date/time of when the brand was updated. Represented in milliseconds since Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updated(): Long = updated.getRequired("updated") - - /** - * The version identifier for the brand - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - /** - * Brand Identifier - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun snippets(): Optional = snippets.getOptional("snippets") - - /** - * Returns the raw JSON value of [created]. - * - * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [published]. - * - * Unlike [published], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("published") @ExcludeMissing fun _published(): JsonField = published - - /** - * Returns the raw JSON value of [settings]. - * - * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("settings") @ExcludeMissing fun _settings(): JsonField = settings - - /** - * Returns the raw JSON value of [updated]. - * - * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [snippets]. - * - * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("snippets") @ExcludeMissing fun _snippets(): JsonField = snippets - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Brand]. - * - * The following fields are required: - * ```java - * .created() - * .name() - * .published() - * .settings() - * .updated() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Brand]. */ - class Builder internal constructor() { - - private var created: JsonField? = null - private var name: JsonField? = null - private var published: JsonField? = null - private var settings: JsonField? = null - private var updated: JsonField? = null - private var version: JsonField? = null - private var id: JsonField = JsonMissing.of() - private var snippets: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brand: Brand) = apply { - created = brand.created - name = brand.name - published = brand.published - settings = brand.settings - updated = brand.updated - version = brand.version - id = brand.id - snippets = brand.snippets - additionalProperties = brand.additionalProperties.toMutableMap() - } - - /** - * The date/time of when the brand was created. Represented in milliseconds since Unix - * epoch. - */ - fun created(created: Long) = created(JsonField.of(created)) - - /** - * Sets [Builder.created] to an arbitrary JSON value. - * - * You should usually call [Builder.created] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun created(created: JsonField) = apply { this.created = created } - - /** Brand name */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The date/time of when the brand was published. Represented in milliseconds since Unix - * epoch. - */ - fun published(published: Long) = published(JsonField.of(published)) - - /** - * Sets [Builder.published] to an arbitrary JSON value. - * - * You should usually call [Builder.published] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun published(published: JsonField) = apply { this.published = published } - - fun settings(settings: BrandSettings) = settings(JsonField.of(settings)) - - /** - * Sets [Builder.settings] to an arbitrary JSON value. - * - * You should usually call [Builder.settings] with a well-typed [BrandSettings] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settings(settings: JsonField) = apply { this.settings = settings } - - /** - * The date/time of when the brand was updated. Represented in milliseconds since Unix - * epoch. - */ - fun updated(updated: Long) = updated(JsonField.of(updated)) - - /** - * Sets [Builder.updated] to an arbitrary JSON value. - * - * You should usually call [Builder.updated] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - /** The version identifier for the brand */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - /** Brand Identifier */ - fun id(id: String?) = id(JsonField.ofNullable(id)) - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun snippets(snippets: BrandSnippets?) = snippets(JsonField.ofNullable(snippets)) - - /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ - fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) - - /** - * Sets [Builder.snippets] to an arbitrary JSON value. - * - * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun snippets(snippets: JsonField) = apply { this.snippets = snippets } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Brand]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .created() - * .name() - * .published() - * .settings() - * .updated() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Brand = - Brand( - checkRequired("created", created), - checkRequired("name", name), - checkRequired("published", published), - checkRequired("settings", settings), - checkRequired("updated", updated), - checkRequired("version", version), - id, - snippets, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Brand = apply { - if (validated) { - return@apply - } - - created() - name() - published() - settings().validate() - updated() - version() - id() - snippets().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (created.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (published.asKnown().isPresent) 1 else 0) + - (settings.asKnown().getOrNull()?.validity() ?: 0) + - (if (updated.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) + - (if (id.asKnown().isPresent) 1 else 0) + - (snippets.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Brand && - created == other.created && - name == other.name && - published == other.published && - settings == other.settings && - updated == other.updated && - version == other.version && - id == other.id && - snippets == other.snippets && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - created, - name, - published, - settings, - updated, - version, - id, - snippets, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Brand{created=$created, name=$name, published=$published, settings=$settings, updated=$updated, version=$version, id=$id, snippets=$snippets, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt deleted file mode 100644 index f64eafd3..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandColors.kt +++ /dev/null @@ -1,228 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BrandColors -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val primary: JsonField, - private val secondary: JsonField, - private val tertiary: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("primary") @ExcludeMissing primary: JsonField = JsonMissing.of(), - @JsonProperty("secondary") @ExcludeMissing secondary: JsonField = JsonMissing.of(), - @JsonProperty("tertiary") @ExcludeMissing tertiary: JsonField = JsonMissing.of(), - ) : this(primary, secondary, tertiary, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun primary(): Optional = primary.getOptional("primary") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun secondary(): Optional = secondary.getOptional("secondary") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tertiary(): Optional = tertiary.getOptional("tertiary") - - /** - * Returns the raw JSON value of [primary]. - * - * Unlike [primary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("primary") @ExcludeMissing fun _primary(): JsonField = primary - - /** - * Returns the raw JSON value of [secondary]. - * - * Unlike [secondary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("secondary") @ExcludeMissing fun _secondary(): JsonField = secondary - - /** - * Returns the raw JSON value of [tertiary]. - * - * Unlike [tertiary], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tertiary") @ExcludeMissing fun _tertiary(): JsonField = tertiary - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BrandColors]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandColors]. */ - class Builder internal constructor() { - - private var primary: JsonField = JsonMissing.of() - private var secondary: JsonField = JsonMissing.of() - private var tertiary: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandColors: BrandColors) = apply { - primary = brandColors.primary - secondary = brandColors.secondary - tertiary = brandColors.tertiary - additionalProperties = brandColors.additionalProperties.toMutableMap() - } - - fun primary(primary: String?) = primary(JsonField.ofNullable(primary)) - - /** Alias for calling [Builder.primary] with `primary.orElse(null)`. */ - fun primary(primary: Optional) = primary(primary.getOrNull()) - - /** - * Sets [Builder.primary] to an arbitrary JSON value. - * - * You should usually call [Builder.primary] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun primary(primary: JsonField) = apply { this.primary = primary } - - fun secondary(secondary: String?) = secondary(JsonField.ofNullable(secondary)) - - /** Alias for calling [Builder.secondary] with `secondary.orElse(null)`. */ - fun secondary(secondary: Optional) = secondary(secondary.getOrNull()) - - /** - * Sets [Builder.secondary] to an arbitrary JSON value. - * - * You should usually call [Builder.secondary] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun secondary(secondary: JsonField) = apply { this.secondary = secondary } - - fun tertiary(tertiary: String?) = tertiary(JsonField.ofNullable(tertiary)) - - /** Alias for calling [Builder.tertiary] with `tertiary.orElse(null)`. */ - fun tertiary(tertiary: Optional) = tertiary(tertiary.getOrNull()) - - /** - * Sets [Builder.tertiary] to an arbitrary JSON value. - * - * You should usually call [Builder.tertiary] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tertiary(tertiary: JsonField) = apply { this.tertiary = tertiary } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BrandColors]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BrandColors = - BrandColors(primary, secondary, tertiary, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): BrandColors = apply { - if (validated) { - return@apply - } - - primary() - secondary() - tertiary() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (primary.asKnown().isPresent) 1 else 0) + - (if (secondary.asKnown().isPresent) 1 else 0) + - (if (tertiary.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandColors && - primary == other.primary && - secondary == other.secondary && - tertiary == other.tertiary && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(primary, secondary, tertiary, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BrandColors{primary=$primary, secondary=$secondary, tertiary=$tertiary, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt deleted file mode 100644 index 0590a1d8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandCreateParams.kt +++ /dev/null @@ -1,618 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Create a new brand */ -class BrandCreateParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * The name of the brand. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = body.name() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun settings(): BrandSettings = body.settings() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = body.id() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun snippets(): Optional = body.snippets() - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _name(): JsonField = body._name() - - /** - * Returns the raw JSON value of [settings]. - * - * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _settings(): JsonField = body._settings() - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _id(): JsonField = body._id() - - /** - * Returns the raw JSON value of [snippets]. - * - * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _snippets(): JsonField = body._snippets() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BrandCreateParams]. - * - * The following fields are required: - * ```java - * .name() - * .settings() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandCreateParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(brandCreateParams: BrandCreateParams) = apply { - body = brandCreateParams.body.toBuilder() - additionalHeaders = brandCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = brandCreateParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [name] - * - [settings] - * - [id] - * - [snippets] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** The name of the brand. */ - fun name(name: String) = apply { body.name(name) } - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { body.name(name) } - - fun settings(settings: BrandSettings) = apply { body.settings(settings) } - - /** - * Sets [Builder.settings] to an arbitrary JSON value. - * - * You should usually call [Builder.settings] with a well-typed [BrandSettings] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settings(settings: JsonField) = apply { body.settings(settings) } - - fun id(id: String?) = apply { body.id(id) } - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { body.id(id) } - - fun snippets(snippets: BrandSnippets?) = apply { body.snippets(snippets) } - - /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ - fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) - - /** - * Sets [Builder.snippets] to an arbitrary JSON value. - * - * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun snippets(snippets: JsonField) = apply { body.snippets(snippets) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BrandCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * .settings() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BrandCreateParams = - BrandCreateParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val settings: JsonField, - private val id: JsonField, - private val snippets: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - settings: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("snippets") - @ExcludeMissing - snippets: JsonField = JsonMissing.of(), - ) : this(name, settings, id, snippets, mutableMapOf()) - - /** - * The name of the brand. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun settings(): BrandSettings = settings.getRequired("settings") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun id(): Optional = id.getOptional("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun snippets(): Optional = snippets.getOptional("snippets") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [settings]. - * - * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("settings") - @ExcludeMissing - fun _settings(): JsonField = settings - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [snippets]. - * - * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("snippets") - @ExcludeMissing - fun _snippets(): JsonField = snippets - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .name() - * .settings() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var settings: JsonField? = null - private var id: JsonField = JsonMissing.of() - private var snippets: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - settings = body.settings - id = body.id - snippets = body.snippets - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** The name of the brand. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun settings(settings: BrandSettings) = settings(JsonField.of(settings)) - - /** - * Sets [Builder.settings] to an arbitrary JSON value. - * - * You should usually call [Builder.settings] with a well-typed [BrandSettings] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settings(settings: JsonField) = apply { this.settings = settings } - - fun id(id: String?) = id(JsonField.ofNullable(id)) - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun snippets(snippets: BrandSnippets?) = snippets(JsonField.ofNullable(snippets)) - - /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ - fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) - - /** - * Sets [Builder.snippets] to an arbitrary JSON value. - * - * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun snippets(snippets: JsonField) = apply { this.snippets = snippets } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * .settings() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("name", name), - checkRequired("settings", settings), - id, - snippets, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - name() - settings().validate() - id() - snippets().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (settings.asKnown().getOrNull()?.validity() ?: 0) + - (if (id.asKnown().isPresent) 1 else 0) + - (snippets.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - name == other.name && - settings == other.settings && - id == other.id && - snippets == other.snippets && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, settings, id, snippets, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{name=$name, settings=$settings, id=$id, snippets=$snippets, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandCreateParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BrandCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt deleted file mode 100644 index bc296c46..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete a brand by brand ID. */ -class BrandDeleteParams -private constructor( - private val brandId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun brandId(): Optional = Optional.ofNullable(brandId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BrandDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BrandDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandDeleteParams]. */ - class Builder internal constructor() { - - private var brandId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandDeleteParams: BrandDeleteParams) = apply { - brandId = brandDeleteParams.brandId - additionalHeaders = brandDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = brandDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = brandDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun brandId(brandId: String?) = apply { this.brandId = brandId } - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [BrandDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BrandDeleteParams = - BrandDeleteParams( - brandId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> brandId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandDeleteParams && - brandId == other.brandId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(brandId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "BrandDeleteParams{brandId=$brandId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt deleted file mode 100644 index 6146a079..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListParams.kt +++ /dev/null @@ -1,191 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get the list of brands. */ -class BrandListParams -private constructor( - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** A unique identifier that allows for fetching the next set of brands. */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BrandListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BrandListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandListParams]. */ - class Builder internal constructor() { - - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(brandListParams: BrandListParams) = apply { - cursor = brandListParams.cursor - additionalHeaders = brandListParams.additionalHeaders.toBuilder() - additionalQueryParams = brandListParams.additionalQueryParams.toBuilder() - } - - /** A unique identifier that allows for fetching the next set of brands. */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BrandListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BrandListParams = - BrandListParams(cursor, additionalHeaders.build(), additionalQueryParams.build()) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandListParams && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BrandListParams{cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt deleted file mode 100644 index 05cb87ae..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandListResponse.kt +++ /dev/null @@ -1,224 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class BrandListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val paging: JsonField, - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of(), - ) : this(paging, results, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BrandListResponse]. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandListResponse]. */ - class Builder internal constructor() { - - private var paging: JsonField? = null - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandListResponse: BrandListResponse) = apply { - paging = brandListResponse.paging - results = brandListResponse.results.map { it.toMutableList() } - additionalProperties = brandListResponse.additionalProperties.toMutableMap() - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Brand] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Brand) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BrandListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BrandListResponse = - BrandListResponse( - checkRequired("paging", paging), - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BrandListResponse = apply { - if (validated) { - return@apply - } - - paging().validate() - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandListResponse && - paging == other.paging && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BrandListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt deleted file mode 100644 index 22323e2b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch a specific brand by brand ID. */ -class BrandRetrieveParams -private constructor( - private val brandId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun brandId(): Optional = Optional.ofNullable(brandId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BrandRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BrandRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandRetrieveParams]. */ - class Builder internal constructor() { - - private var brandId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(brandRetrieveParams: BrandRetrieveParams) = apply { - brandId = brandRetrieveParams.brandId - additionalHeaders = brandRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = brandRetrieveParams.additionalQueryParams.toBuilder() - } - - fun brandId(brandId: String?) = apply { this.brandId = brandId } - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BrandRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BrandRetrieveParams = - BrandRetrieveParams(brandId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> brandId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandRetrieveParams && - brandId == other.brandId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(brandId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BrandRetrieveParams{brandId=$brandId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt deleted file mode 100644 index 32fbe06d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSettings.kt +++ /dev/null @@ -1,202 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BrandSettings -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val colors: JsonField, - private val email: JsonField, - private val inapp: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("colors") @ExcludeMissing colors: JsonField = JsonMissing.of(), - @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), - @JsonProperty("inapp") @ExcludeMissing inapp: JsonValue = JsonMissing.of(), - ) : this(colors, email, inapp, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun colors(): Optional = colors.getOptional("colors") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun email(): Optional = email.getOptional("email") - - @JsonProperty("inapp") @ExcludeMissing fun _inapp(): JsonValue = inapp - - /** - * Returns the raw JSON value of [colors]. - * - * Unlike [colors], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("colors") @ExcludeMissing fun _colors(): JsonField = colors - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BrandSettings]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandSettings]. */ - class Builder internal constructor() { - - private var colors: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var inapp: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandSettings: BrandSettings) = apply { - colors = brandSettings.colors - email = brandSettings.email - inapp = brandSettings.inapp - additionalProperties = brandSettings.additionalProperties.toMutableMap() - } - - fun colors(colors: BrandColors?) = colors(JsonField.ofNullable(colors)) - - /** Alias for calling [Builder.colors] with `colors.orElse(null)`. */ - fun colors(colors: Optional) = colors(colors.getOrNull()) - - /** - * Sets [Builder.colors] to an arbitrary JSON value. - * - * You should usually call [Builder.colors] with a well-typed [BrandColors] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun colors(colors: JsonField) = apply { this.colors = colors } - - fun email(email: Email?) = email(JsonField.ofNullable(email)) - - /** Alias for calling [Builder.email] with `email.orElse(null)`. */ - fun email(email: Optional) = email(email.getOrNull()) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [Email] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun inapp(inapp: JsonValue) = apply { this.inapp = inapp } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BrandSettings]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BrandSettings = - BrandSettings(colors, email, inapp, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): BrandSettings = apply { - if (validated) { - return@apply - } - - colors().ifPresent { it.validate() } - email().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (colors.asKnown().getOrNull()?.validity() ?: 0) + - (email.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandSettings && - colors == other.colors && - email == other.email && - inapp == other.inapp && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(colors, email, inapp, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BrandSettings{colors=$colors, email=$email, inapp=$inapp, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt deleted file mode 100644 index 84b7564e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippet.kt +++ /dev/null @@ -1,359 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class BrandSnippet -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val format: JsonField, - private val name: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("format") @ExcludeMissing format: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(format, name, value, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun format(): Format = format.getRequired("format") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [format]. - * - * Unlike [format], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("format") @ExcludeMissing fun _format(): JsonField = format - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BrandSnippet]. - * - * The following fields are required: - * ```java - * .format() - * .name() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandSnippet]. */ - class Builder internal constructor() { - - private var format: JsonField? = null - private var name: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandSnippet: BrandSnippet) = apply { - format = brandSnippet.format - name = brandSnippet.name - value = brandSnippet.value - additionalProperties = brandSnippet.additionalProperties.toMutableMap() - } - - fun format(format: Format) = format(JsonField.of(format)) - - /** - * Sets [Builder.format] to an arbitrary JSON value. - * - * You should usually call [Builder.format] with a well-typed [Format] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun format(format: JsonField) = apply { this.format = format } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BrandSnippet]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .format() - * .name() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BrandSnippet = - BrandSnippet( - checkRequired("format", format), - checkRequired("name", name), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BrandSnippet = apply { - if (validated) { - return@apply - } - - format().validate() - name() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (format.asKnown().getOrNull()?.validity() ?: 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - class Format @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val HANDLEBARS = of("handlebars") - - @JvmStatic fun of(value: String) = Format(JsonField.of(value)) - } - - /** An enum containing [Format]'s known values. */ - enum class Known { - HANDLEBARS - } - - /** - * An enum containing [Format]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Format] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - HANDLEBARS, - /** An enum member indicating that [Format] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - HANDLEBARS -> Value.HANDLEBARS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - HANDLEBARS -> Known.HANDLEBARS - else -> throw CourierInvalidDataException("Unknown Format: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Format = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Format && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandSnippet && - format == other.format && - name == other.name && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(format, name, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BrandSnippet{format=$format, name=$name, value=$value, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt deleted file mode 100644 index 848944dc..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandSnippets.kt +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class BrandSnippets -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") - @ExcludeMissing - items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BrandSnippets]. - * - * The following fields are required: - * ```java - * .items() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandSnippets]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(brandSnippets: BrandSnippets) = apply { - items = brandSnippets.items.map { it.toMutableList() } - additionalProperties = brandSnippets.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [BrandSnippet] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: BrandSnippet) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BrandSnippets]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BrandSnippets = - BrandSnippets( - checkRequired("items", items).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BrandSnippets = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandSnippets && - items == other.items && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BrandSnippets{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt deleted file mode 100644 index 491dbdd5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/BrandUpdateParams.kt +++ /dev/null @@ -1,577 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Replace an existing brand with the supplied values. */ -class BrandUpdateParams -private constructor( - private val brandId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun brandId(): Optional = Optional.ofNullable(brandId) - - /** - * The name of the brand. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = body.name() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun settings(): Optional = body.settings() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun snippets(): Optional = body.snippets() - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _name(): JsonField = body._name() - - /** - * Returns the raw JSON value of [settings]. - * - * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _settings(): JsonField = body._settings() - - /** - * Returns the raw JSON value of [snippets]. - * - * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _snippets(): JsonField = body._snippets() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BrandUpdateParams]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BrandUpdateParams]. */ - class Builder internal constructor() { - - private var brandId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(brandUpdateParams: BrandUpdateParams) = apply { - brandId = brandUpdateParams.brandId - body = brandUpdateParams.body.toBuilder() - additionalHeaders = brandUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = brandUpdateParams.additionalQueryParams.toBuilder() - } - - fun brandId(brandId: String?) = apply { this.brandId = brandId } - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [name] - * - [settings] - * - [snippets] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** The name of the brand. */ - fun name(name: String) = apply { body.name(name) } - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { body.name(name) } - - fun settings(settings: BrandSettings?) = apply { body.settings(settings) } - - /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ - fun settings(settings: Optional) = settings(settings.getOrNull()) - - /** - * Sets [Builder.settings] to an arbitrary JSON value. - * - * You should usually call [Builder.settings] with a well-typed [BrandSettings] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settings(settings: JsonField) = apply { body.settings(settings) } - - fun snippets(snippets: BrandSnippets?) = apply { body.snippets(snippets) } - - /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ - fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) - - /** - * Sets [Builder.snippets] to an arbitrary JSON value. - * - * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun snippets(snippets: JsonField) = apply { body.snippets(snippets) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BrandUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BrandUpdateParams = - BrandUpdateParams( - brandId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> brandId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val settings: JsonField, - private val snippets: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("settings") - @ExcludeMissing - settings: JsonField = JsonMissing.of(), - @JsonProperty("snippets") - @ExcludeMissing - snippets: JsonField = JsonMissing.of(), - ) : this(name, settings, snippets, mutableMapOf()) - - /** - * The name of the brand. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun settings(): Optional = settings.getOptional("settings") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun snippets(): Optional = snippets.getOptional("snippets") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [settings]. - * - * Unlike [settings], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("settings") - @ExcludeMissing - fun _settings(): JsonField = settings - - /** - * Returns the raw JSON value of [snippets]. - * - * Unlike [snippets], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("snippets") - @ExcludeMissing - fun _snippets(): JsonField = snippets - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var settings: JsonField = JsonMissing.of() - private var snippets: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - settings = body.settings - snippets = body.snippets - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** The name of the brand. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun settings(settings: BrandSettings?) = settings(JsonField.ofNullable(settings)) - - /** Alias for calling [Builder.settings] with `settings.orElse(null)`. */ - fun settings(settings: Optional) = settings(settings.getOrNull()) - - /** - * Sets [Builder.settings] to an arbitrary JSON value. - * - * You should usually call [Builder.settings] with a well-typed [BrandSettings] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun settings(settings: JsonField) = apply { this.settings = settings } - - fun snippets(snippets: BrandSnippets?) = snippets(JsonField.ofNullable(snippets)) - - /** Alias for calling [Builder.snippets] with `snippets.orElse(null)`. */ - fun snippets(snippets: Optional) = snippets(snippets.getOrNull()) - - /** - * Sets [Builder.snippets] to an arbitrary JSON value. - * - * You should usually call [Builder.snippets] with a well-typed [BrandSnippets] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun snippets(snippets: JsonField) = apply { this.snippets = snippets } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("name", name), - settings, - snippets, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - name() - settings().ifPresent { it.validate() } - snippets().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (settings.asKnown().getOrNull()?.validity() ?: 0) + - (snippets.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - name == other.name && - settings == other.settings && - snippets == other.snippets && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(name, settings, snippets, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{name=$name, settings=$settings, snippets=$snippets, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BrandUpdateParams && - brandId == other.brandId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(brandId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BrandUpdateParams{brandId=$brandId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt deleted file mode 100644 index 50153ae2..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/brands/Email.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class Email -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val footer: JsonValue, - private val header: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("footer") @ExcludeMissing footer: JsonValue = JsonMissing.of(), - @JsonProperty("header") @ExcludeMissing header: JsonValue = JsonMissing.of(), - ) : this(footer, header, mutableMapOf()) - - @JsonProperty("footer") @ExcludeMissing fun _footer(): JsonValue = footer - - @JsonProperty("header") @ExcludeMissing fun _header(): JsonValue = header - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Email]. - * - * The following fields are required: - * ```java - * .footer() - * .header() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Email]. */ - class Builder internal constructor() { - - private var footer: JsonValue? = null - private var header: JsonValue? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(email: Email) = apply { - footer = email.footer - header = email.header - additionalProperties = email.additionalProperties.toMutableMap() - } - - fun footer(footer: JsonValue) = apply { this.footer = footer } - - fun header(header: JsonValue) = apply { this.header = header } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Email]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .footer() - * .header() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Email = - Email( - checkRequired("footer", footer), - checkRequired("header", header), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Email = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = 0 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Email && - footer == other.footer && - header == other.header && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(footer, header, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Email{footer=$footer, header=$header, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt deleted file mode 100644 index 8dcca0d7..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkAddUsersParams.kt +++ /dev/null @@ -1,462 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Ingest user data into a Bulk Job */ -class BulkAddUsersParams -private constructor( - private val jobId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun users(): List = body.users() - - /** - * Returns the raw JSON value of [users]. - * - * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _users(): JsonField> = body._users() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkAddUsersParams]. - * - * The following fields are required: - * ```java - * .users() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkAddUsersParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(bulkAddUsersParams: BulkAddUsersParams) = apply { - jobId = bulkAddUsersParams.jobId - body = bulkAddUsersParams.body.toBuilder() - additionalHeaders = bulkAddUsersParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkAddUsersParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [users] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun users(users: List) = apply { body.users(users) } - - /** - * Sets [Builder.users] to an arbitrary JSON value. - * - * You should usually call [Builder.users] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun users(users: JsonField>) = apply { body.users(users) } - - /** - * Adds a single [InboundBulkMessageUser] to [users]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addUser(user: InboundBulkMessageUser) = apply { body.addUser(user) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BulkAddUsersParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .users() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkAddUsersParams = - BulkAddUsersParams( - jobId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val users: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("users") - @ExcludeMissing - users: JsonField> = JsonMissing.of() - ) : this(users, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun users(): List = users.getRequired("users") - - /** - * Returns the raw JSON value of [users]. - * - * Unlike [users], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("users") - @ExcludeMissing - fun _users(): JsonField> = users - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .users() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var users: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - users = body.users.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun users(users: List) = users(JsonField.of(users)) - - /** - * Sets [Builder.users] to an arbitrary JSON value. - * - * You should usually call [Builder.users] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun users(users: JsonField>) = apply { - this.users = users.map { it.toMutableList() } - } - - /** - * Adds a single [InboundBulkMessageUser] to [users]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addUser(user: InboundBulkMessageUser) = apply { - users = - (users ?: JsonField.of(mutableListOf())).also { - checkKnown("users", it).add(user) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .users() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("users", users).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - users().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (users.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - users == other.users && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(users, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{users=$users, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkAddUsersParams && - jobId == other.jobId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(jobId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkAddUsersParams{jobId=$jobId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt deleted file mode 100644 index e859ea4a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobParams.kt +++ /dev/null @@ -1,416 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -/** Create a bulk job */ -class BulkCreateJobParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): InboundBulkMessage = body.message() - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _message(): JsonField = body._message() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkCreateJobParams]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkCreateJobParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(bulkCreateJobParams: BulkCreateJobParams) = apply { - body = bulkCreateJobParams.body.toBuilder() - additionalHeaders = bulkCreateJobParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkCreateJobParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [message] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun message(message: InboundBulkMessage) = apply { body.message(message) } - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [InboundBulkMessage] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun message(message: JsonField) = apply { body.message(message) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BulkCreateJobParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkCreateJobParams = - BulkCreateJobParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val message: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("message") - @ExcludeMissing - message: JsonField = JsonMissing.of() - ) : this(message, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): InboundBulkMessage = message.getRequired("message") - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") - @ExcludeMissing - fun _message(): JsonField = message - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var message: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - message = body.message - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun message(message: InboundBulkMessage) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [InboundBulkMessage] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("message", message), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - message().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (message.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - message == other.message && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{message=$message, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkCreateJobParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkCreateJobParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt deleted file mode 100644 index d3535854..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkCreateJobResponse.kt +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class BulkCreateJobResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val jobId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("jobId") @ExcludeMissing jobId: JsonField = JsonMissing.of() - ) : this(jobId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun jobId(): String = jobId.getRequired("jobId") - - /** - * Returns the raw JSON value of [jobId]. - * - * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("jobId") @ExcludeMissing fun _jobId(): JsonField = jobId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkCreateJobResponse]. - * - * The following fields are required: - * ```java - * .jobId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkCreateJobResponse]. */ - class Builder internal constructor() { - - private var jobId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkCreateJobResponse: BulkCreateJobResponse) = apply { - jobId = bulkCreateJobResponse.jobId - additionalProperties = bulkCreateJobResponse.additionalProperties.toMutableMap() - } - - fun jobId(jobId: String) = jobId(JsonField.of(jobId)) - - /** - * Sets [Builder.jobId] to an arbitrary JSON value. - * - * You should usually call [Builder.jobId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun jobId(jobId: JsonField) = apply { this.jobId = jobId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkCreateJobResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .jobId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkCreateJobResponse = - BulkCreateJobResponse( - checkRequired("jobId", jobId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BulkCreateJobResponse = apply { - if (validated) { - return@apply - } - - jobId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (jobId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkCreateJobResponse && - jobId == other.jobId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkCreateJobResponse{jobId=$jobId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt deleted file mode 100644 index dbfe2ab0..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersParams.kt +++ /dev/null @@ -1,216 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get Bulk Job Users */ -class BulkListUsersParams -private constructor( - private val jobId: String?, - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** A unique identifier that allows for fetching the next set of users added to the bulk job */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BulkListUsersParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BulkListUsersParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkListUsersParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(bulkListUsersParams: BulkListUsersParams) = apply { - jobId = bulkListUsersParams.jobId - cursor = bulkListUsersParams.cursor - additionalHeaders = bulkListUsersParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkListUsersParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - /** - * A unique identifier that allows for fetching the next set of users added to the bulk job - */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BulkListUsersParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkListUsersParams = - BulkListUsersParams( - jobId, - cursor, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkListUsersParams && - jobId == other.jobId && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(jobId, cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkListUsersParams{jobId=$jobId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt deleted file mode 100644 index 7647e244..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkListUsersResponse.kt +++ /dev/null @@ -1,710 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BulkListUsersResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkListUsersResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkListUsersResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkListUsersResponse: BulkListUsersResponse) = apply { - items = bulkListUsersResponse.items.map { it.toMutableList() } - paging = bulkListUsersResponse.paging - additionalProperties = bulkListUsersResponse.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Item] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Item) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkListUsersResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkListUsersResponse = - BulkListUsersResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BulkListUsersResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonValue, - private val preferences: JsonField, - private val profile: JsonValue, - private val recipient: JsonField, - private val to: JsonField, - private val status: JsonField, - private val messageId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), - @JsonProperty("recipient") - @ExcludeMissing - recipient: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("messageId") - @ExcludeMissing - messageId: JsonField = JsonMissing.of(), - ) : this(data, preferences, profile, recipient, to, status, messageId, mutableMapOf()) - - fun toInboundBulkMessageUser(): InboundBulkMessageUser = - InboundBulkMessageUser.builder() - .data(data) - .preferences(preferences) - .profile(profile) - .recipient(recipient) - .to(to) - .build() - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun messageId(): Optional = messageId.getOptional("messageId") - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [messageId]. - * - * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Item]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var data: JsonValue = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var profile: JsonValue = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var status: JsonField? = null - private var messageId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - data = item.data - preferences = item.preferences - profile = item.profile - recipient = item.recipient - to = item.to - status = item.status - messageId = item.messageId - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun data(data: JsonValue) = apply { this.data = data } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun profile(profile: JsonValue) = apply { this.profile = profile } - - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - fun to(to: UserRecipient?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [UserRecipient] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun to(to: JsonField) = apply { this.to = to } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun messageId(messageId: String?) = messageId(JsonField.ofNullable(messageId)) - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - /** - * Sets [Builder.messageId] to an arbitrary JSON value. - * - * You should usually call [Builder.messageId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageId(messageId: JsonField) = apply { this.messageId = messageId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - data, - preferences, - profile, - recipient, - to, - checkRequired("status", status), - messageId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - preferences().ifPresent { it.validate() } - recipient() - to().ifPresent { it.validate() } - status().validate() - messageId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (to.asKnown().getOrNull()?.validity() ?: 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (messageId.asKnown().isPresent) 1 else 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PENDING = of("PENDING") - - @JvmField val ENQUEUED = of("ENQUEUED") - - @JvmField val ERROR = of("ERROR") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - PENDING, - ENQUEUED, - ERROR, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PENDING, - ENQUEUED, - ERROR, - /** - * An enum member indicating that [Status] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PENDING -> Value.PENDING - ENQUEUED -> Value.ENQUEUED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - PENDING -> Known.PENDING - ENQUEUED -> Known.ENQUEUED - ERROR -> Known.ERROR - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - data == other.data && - preferences == other.preferences && - profile == other.profile && - recipient == other.recipient && - to == other.to && - status == other.status && - messageId == other.messageId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - data, - preferences, - profile, - recipient, - to, - status, - messageId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{data=$data, preferences=$preferences, profile=$profile, recipient=$recipient, to=$to, status=$status, messageId=$messageId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkListUsersResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkListUsersResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt deleted file mode 100644 index f828a7c6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get a bulk job */ -class BulkRetrieveJobParams -private constructor( - private val jobId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BulkRetrieveJobParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BulkRetrieveJobParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkRetrieveJobParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(bulkRetrieveJobParams: BulkRetrieveJobParams) = apply { - jobId = bulkRetrieveJobParams.jobId - additionalHeaders = bulkRetrieveJobParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkRetrieveJobParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BulkRetrieveJobParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkRetrieveJobParams = - BulkRetrieveJobParams(jobId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkRetrieveJobParams && - jobId == other.jobId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(jobId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BulkRetrieveJobParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt deleted file mode 100644 index 977d30b0..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponse.kt +++ /dev/null @@ -1,612 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class BulkRetrieveJobResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val job: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() - ) : this(job, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun job(): Job = job.getRequired("job") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BulkRetrieveJobResponse]. - * - * The following fields are required: - * ```java - * .job() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkRetrieveJobResponse]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkRetrieveJobResponse: BulkRetrieveJobResponse) = apply { - job = bulkRetrieveJobResponse.job - additionalProperties = bulkRetrieveJobResponse.additionalProperties.toMutableMap() - } - - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. - */ - fun job(job: JsonField) = apply { this.job = job } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BulkRetrieveJobResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .job() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BulkRetrieveJobResponse = - BulkRetrieveJobResponse(checkRequired("job", job), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): BulkRetrieveJobResponse = apply { - if (validated) { - return@apply - } - - job().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (job.asKnown().getOrNull()?.validity() ?: 0) - - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val definition: JsonField, - private val enqueued: JsonField, - private val failures: JsonField, - private val received: JsonField, - private val status: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("definition") - @ExcludeMissing - definition: JsonField = JsonMissing.of(), - @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), - @JsonProperty("failures") @ExcludeMissing failures: JsonField = JsonMissing.of(), - @JsonProperty("received") @ExcludeMissing received: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(definition, enqueued, failures, received, status, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun definition(): InboundBulkMessage = definition.getRequired("definition") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun enqueued(): Long = enqueued.getRequired("enqueued") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun failures(): Long = failures.getRequired("failures") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun received(): Long = received.getRequired("received") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [definition]. - * - * Unlike [definition], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("definition") - @ExcludeMissing - fun _definition(): JsonField = definition - - /** - * Returns the raw JSON value of [enqueued]. - * - * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued - - /** - * Returns the raw JSON value of [failures]. - * - * Unlike [failures], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("failures") @ExcludeMissing fun _failures(): JsonField = failures - - /** - * Returns the raw JSON value of [received]. - * - * Unlike [received], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("received") @ExcludeMissing fun _received(): JsonField = received - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Job]. - * - * The following fields are required: - * ```java - * .definition() - * .enqueued() - * .failures() - * .received() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var definition: JsonField? = null - private var enqueued: JsonField? = null - private var failures: JsonField? = null - private var received: JsonField? = null - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - definition = job.definition - enqueued = job.enqueued - failures = job.failures - received = job.received - status = job.status - additionalProperties = job.additionalProperties.toMutableMap() - } - - fun definition(definition: InboundBulkMessage) = definition(JsonField.of(definition)) - - /** - * Sets [Builder.definition] to an arbitrary JSON value. - * - * You should usually call [Builder.definition] with a well-typed [InboundBulkMessage] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun definition(definition: JsonField) = apply { - this.definition = definition - } - - fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) - - /** - * Sets [Builder.enqueued] to an arbitrary JSON value. - * - * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } - - fun failures(failures: Long) = failures(JsonField.of(failures)) - - /** - * Sets [Builder.failures] to an arbitrary JSON value. - * - * You should usually call [Builder.failures] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun failures(failures: JsonField) = apply { this.failures = failures } - - fun received(received: Long) = received(JsonField.of(received)) - - /** - * Sets [Builder.received] to an arbitrary JSON value. - * - * You should usually call [Builder.received] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun received(received: JsonField) = apply { this.received = received } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .definition() - * .enqueued() - * .failures() - * .received() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("definition", definition), - checkRequired("enqueued", enqueued), - checkRequired("failures", failures), - checkRequired("received", received), - checkRequired("status", status), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Job = apply { - if (validated) { - return@apply - } - - definition().validate() - enqueued() - failures() - received() - status().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (definition.asKnown().getOrNull()?.validity() ?: 0) + - (if (enqueued.asKnown().isPresent) 1 else 0) + - (if (failures.asKnown().isPresent) 1 else 0) + - (if (received.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CREATED = of("CREATED") - - @JvmField val PROCESSING = of("PROCESSING") - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val ERROR = of("ERROR") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CREATED, - PROCESSING, - COMPLETED, - ERROR, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CREATED, - PROCESSING, - COMPLETED, - ERROR, - /** - * An enum member indicating that [Status] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CREATED -> Value.CREATED - PROCESSING -> Value.PROCESSING - COMPLETED -> Value.COMPLETED - ERROR -> Value.ERROR - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CREATED -> Known.CREATED - PROCESSING -> Known.PROCESSING - COMPLETED -> Known.COMPLETED - ERROR -> Known.ERROR - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Job && - definition == other.definition && - enqueued == other.enqueued && - failures == other.failures && - received == other.received && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(definition, enqueued, failures, received, status, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{definition=$definition, enqueued=$enqueued, failures=$failures, received=$received, status=$status, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkRetrieveJobResponse && - job == other.job && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BulkRetrieveJobResponse{job=$job, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt deleted file mode 100644 index 4c90666c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/BulkRunJobParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Run a bulk job */ -class BulkRunJobParams -private constructor( - private val jobId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BulkRunJobParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BulkRunJobParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BulkRunJobParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(bulkRunJobParams: BulkRunJobParams) = apply { - jobId = bulkRunJobParams.jobId - additionalHeaders = bulkRunJobParams.additionalHeaders.toBuilder() - additionalQueryParams = bulkRunJobParams.additionalQueryParams.toBuilder() - additionalBodyProperties = bulkRunJobParams.additionalBodyProperties.toMutableMap() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [BulkRunJobParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BulkRunJobParams = - BulkRunJobParams( - jobId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BulkRunJobParams && - jobId == other.jobId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(jobId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "BulkRunJobParams{jobId=$jobId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt deleted file mode 100644 index 67d16aa5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessage.kt +++ /dev/null @@ -1,2294 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.Content -import com.courier.api.models.send.MessageContext -import com.courier.api.models.tenants.templates.ElementalContent -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class InboundBulkMessage -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val brand: JsonField, - private val data: JsonField, - private val event: JsonField, - private val locale: JsonField, - private val message: JsonField, - private val override: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("brand") @ExcludeMissing brand: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("locale") @ExcludeMissing locale: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("override") @ExcludeMissing override: JsonValue = JsonMissing.of(), - ) : this(brand, data, event, locale, message, override, mutableMapOf()) - - /** - * A unique identifier that represents the brand that should be used for rendering the - * notification. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brand(): Optional = brand.getOptional("brand") - - /** - * JSON that includes any data you want to pass to a message template. The data will populate - * the corresponding template variables. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun event(): Optional = event.getOptional("event") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun locale(): Optional = locale.getOptional("locale") - - /** - * Describes the content of the message in a way that will work for email, push, chat, or any - * channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun message(): Optional = message.getOptional("message") - - /** - * JSON that is merged into the request sent by Courier to the provider to override properties - * or to gain access to features in the provider API that are not natively supported by Courier. - */ - @JsonProperty("override") @ExcludeMissing fun _override(): JsonValue = override - - /** - * Returns the raw JSON value of [brand]. - * - * Unlike [brand], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonField = brand - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - - /** - * Returns the raw JSON value of [locale]. - * - * Unlike [locale], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [InboundBulkMessage]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundBulkMessage]. */ - class Builder internal constructor() { - - private var brand: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var event: JsonField = JsonMissing.of() - private var locale: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var override: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundBulkMessage: InboundBulkMessage) = apply { - brand = inboundBulkMessage.brand - data = inboundBulkMessage.data - event = inboundBulkMessage.event - locale = inboundBulkMessage.locale - message = inboundBulkMessage.message - override = inboundBulkMessage.override - additionalProperties = inboundBulkMessage.additionalProperties.toMutableMap() - } - - /** - * A unique identifier that represents the brand that should be used for rendering the - * notification. - */ - fun brand(brand: String?) = brand(JsonField.ofNullable(brand)) - - /** Alias for calling [Builder.brand] with `brand.orElse(null)`. */ - fun brand(brand: Optional) = brand(brand.getOrNull()) - - /** - * Sets [Builder.brand] to an arbitrary JSON value. - * - * You should usually call [Builder.brand] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brand(brand: JsonField) = apply { this.brand = brand } - - /** - * JSON that includes any data you want to pass to a message template. The data will - * populate the corresponding template variables. - */ - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun event(event: String?) = event(JsonField.ofNullable(event)) - - /** Alias for calling [Builder.event] with `event.orElse(null)`. */ - fun event(event: Optional) = event(event.getOrNull()) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - fun locale(locale: Locale?) = locale(JsonField.ofNullable(locale)) - - /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ - fun locale(locale: Optional) = locale(locale.getOrNull()) - - /** - * Sets [Builder.locale] to an arbitrary JSON value. - * - * You should usually call [Builder.locale] with a well-typed [Locale] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun locale(locale: JsonField) = apply { this.locale = locale } - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. - */ - fun message(message: Message?) = message(JsonField.ofNullable(message)) - - /** Alias for calling [Builder.message] with `message.orElse(null)`. */ - fun message(message: Optional) = message(message.getOrNull()) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [Message] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - /** - * Alias for calling [message] with `Message.ofInboundBulkTemplate(inboundBulkTemplate)`. - */ - fun message(inboundBulkTemplate: Message.InboundBulkTemplateMessage) = - message(Message.ofInboundBulkTemplate(inboundBulkTemplate)) - - /** Alias for calling [message] with `Message.ofInboundBulkContent(inboundBulkContent)`. */ - fun message(inboundBulkContent: Message.InboundBulkContentMessage) = - message(Message.ofInboundBulkContent(inboundBulkContent)) - - /** - * JSON that is merged into the request sent by Courier to the provider to override - * properties or to gain access to features in the provider API that are not natively - * supported by Courier. - */ - fun override(override: JsonValue) = apply { this.override = override } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InboundBulkMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InboundBulkMessage = - InboundBulkMessage( - brand, - data, - event, - locale, - message, - override, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InboundBulkMessage = apply { - if (validated) { - return@apply - } - - brand() - data().ifPresent { it.validate() } - event() - locale().ifPresent { it.validate() } - message().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brand.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (event.asKnown().isPresent) 1 else 0) + - (locale.asKnown().getOrNull()?.validity() ?: 0) + - (message.asKnown().getOrNull()?.validity() ?: 0) - - /** - * JSON that includes any data you want to pass to a message template. The data will populate - * the corresponding template variables. - */ - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Locale - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Locale]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Locale]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(locale: Locale) = apply { - additionalProperties = locale.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Locale]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Locale = Locale(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Locale = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Locale && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Locale{additionalProperties=$additionalProperties}" - } - - /** - * Describes the content of the message in a way that will work for email, push, chat, or any - * channel. - */ - @JsonDeserialize(using = Message.Deserializer::class) - @JsonSerialize(using = Message.Serializer::class) - class Message - private constructor( - private val inboundBulkTemplate: InboundBulkTemplateMessage? = null, - private val inboundBulkContent: InboundBulkContentMessage? = null, - private val _json: JsonValue? = null, - ) { - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. - */ - fun inboundBulkTemplate(): Optional = - Optional.ofNullable(inboundBulkTemplate) - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - fun inboundBulkContent(): Optional = - Optional.ofNullable(inboundBulkContent) - - fun isInboundBulkTemplate(): Boolean = inboundBulkTemplate != null - - fun isInboundBulkContent(): Boolean = inboundBulkContent != null - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. - */ - fun asInboundBulkTemplate(): InboundBulkTemplateMessage = - inboundBulkTemplate.getOrThrow("inboundBulkTemplate") - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - fun asInboundBulkContent(): InboundBulkContentMessage = - inboundBulkContent.getOrThrow("inboundBulkContent") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - inboundBulkTemplate != null -> visitor.visitInboundBulkTemplate(inboundBulkTemplate) - inboundBulkContent != null -> visitor.visitInboundBulkContent(inboundBulkContent) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Message = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitInboundBulkTemplate( - inboundBulkTemplate: InboundBulkTemplateMessage - ) { - inboundBulkTemplate.validate() - } - - override fun visitInboundBulkContent( - inboundBulkContent: InboundBulkContentMessage - ) { - inboundBulkContent.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitInboundBulkTemplate( - inboundBulkTemplate: InboundBulkTemplateMessage - ) = inboundBulkTemplate.validity() - - override fun visitInboundBulkContent( - inboundBulkContent: InboundBulkContentMessage - ) = inboundBulkContent.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && - inboundBulkTemplate == other.inboundBulkTemplate && - inboundBulkContent == other.inboundBulkContent - } - - override fun hashCode(): Int = Objects.hash(inboundBulkTemplate, inboundBulkContent) - - override fun toString(): String = - when { - inboundBulkTemplate != null -> "Message{inboundBulkTemplate=$inboundBulkTemplate}" - inboundBulkContent != null -> "Message{inboundBulkContent=$inboundBulkContent}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - - companion object { - - /** - * Describes the content of the message in a way that will work for email, push, chat, - * or any channel. - */ - @JvmStatic - fun ofInboundBulkTemplate(inboundBulkTemplate: InboundBulkTemplateMessage) = - Message(inboundBulkTemplate = inboundBulkTemplate) - - /** - * A template for a type of message that can be sent more than once. For example, you - * might create an "Appointment Reminder" Notification or “Reset Password” - * Notifications. - */ - @JvmStatic - fun ofInboundBulkContent(inboundBulkContent: InboundBulkContentMessage) = - Message(inboundBulkContent = inboundBulkContent) - } - - /** - * An interface that defines how to map each variant of [Message] to a value of type [T]. - */ - interface Visitor { - - /** - * Describes the content of the message in a way that will work for email, push, chat, - * or any channel. - */ - fun visitInboundBulkTemplate(inboundBulkTemplate: InboundBulkTemplateMessage): T - - /** - * A template for a type of message that can be sent more than once. For example, you - * might create an "Appointment Reminder" Notification or “Reset Password” - * Notifications. - */ - fun visitInboundBulkContent(inboundBulkContent: InboundBulkContentMessage): T - - /** - * Maps an unknown variant of [Message] to a value of type [T]. - * - * An instance of [Message] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Message: $json") - } - } - - internal class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Message(inboundBulkTemplate = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Message(inboundBulkContent = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> Message(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.inboundBulkTemplate != null -> - generator.writeObject(value.inboundBulkTemplate) - value.inboundBulkContent != null -> - generator.writeObject(value.inboundBulkContent) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. - */ - class InboundBulkTemplateMessage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val brandId: JsonField, - private val channels: JsonField, - private val context: JsonField, - private val data: JsonField, - private val delay: JsonField, - private val expiry: JsonField, - private val metadata: JsonField, - private val preferences: JsonField, - private val providers: JsonField, - private val routing: JsonField, - private val timeout: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("brand_id") - @ExcludeMissing - brandId: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - context: JsonField = JsonMissing.of(), - @JsonProperty("data") - @ExcludeMissing - data: JsonField = JsonMissing.of(), - @JsonProperty("delay") - @ExcludeMissing - delay: JsonField = JsonMissing.of(), - @JsonProperty("expiry") - @ExcludeMissing - expiry: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField = JsonMissing.of(), - @JsonProperty("routing") - @ExcludeMissing - routing: JsonField = JsonMissing.of(), - @JsonProperty("timeout") - @ExcludeMissing - timeout: JsonField = JsonMissing.of(), - @JsonProperty("template") - @ExcludeMissing - template: JsonField = JsonMissing.of(), - ) : this( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - template, - mutableMapOf(), - ) - - fun toBaseMessage(): BaseMessage = - BaseMessage.builder() - .brandId(brandId) - .channels(channels) - .context(context) - .data(data) - .delay(delay) - .expiry(expiry) - .metadata(metadata) - .preferences(preferences) - .providers(providers) - .routing(routing) - .timeout(timeout) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * "Define run-time configuration for one or more channels. If you don't specify - * channels, the default configuration for each channel will be used. Valid ChannelId's - * are: email, sms, push, inbox, direct_message, banner, and webhook." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun channels(): Optional = channels.getOptional("channels") - - /** - * Context to load with this recipient. Will override any context set on - * message.context. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * An arbitrary object that includes any data you want to pass to the message. The data - * will populate the corresponding template or elements variables. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an - * ISO 8601 timestamp that specifies when it should be delivered. Until with an - * OpenStreetMap opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun delay(): Optional = delay.getOptional("delay") - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun expiry(): Optional = expiry.getOptional("expiry") - - /** - * Metadata such as utm tracking attached with the notification through this channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun preferences(): Optional = - preferences.getOptional("preferences") - - /** - * An object whose keys are valid provider identifiers which map to an object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun providers(): Optional = providers.getOptional("providers") - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the - * message. If no routing key is specified, Courier will use the default routing - * configuration or routing defined by the template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun routing(): Optional = routing.getOptional("routing") - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun timeout(): Optional = timeout.getOptional("timeout") - - /** - * The id of the notification template to be rendered and sent to the recipient(s). This - * field or the content field must be supplied. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun template(): String = template.getRequired("template") - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField = channels - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") - @ExcludeMissing - fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [delay]. - * - * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delay") - @ExcludeMissing - fun _delay(): JsonField = delay - - /** - * Returns the raw JSON value of [expiry]. - * - * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry") - @ExcludeMissing - fun _expiry(): JsonField = expiry - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("providers") - @ExcludeMissing - fun _providers(): JsonField = providers - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") - @ExcludeMissing - fun _routing(): JsonField = routing - - /** - * Returns the raw JSON value of [timeout]. - * - * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timeout") - @ExcludeMissing - fun _timeout(): JsonField = timeout - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InboundBulkTemplateMessage]. - * - * The following fields are required: - * ```java - * .template() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundBulkTemplateMessage]. */ - class Builder internal constructor() { - - private var brandId: JsonField = JsonMissing.of() - private var channels: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var delay: JsonField = JsonMissing.of() - private var expiry: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var providers: JsonField = JsonMissing.of() - private var routing: JsonField = JsonMissing.of() - private var timeout: JsonField = JsonMissing.of() - private var template: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundBulkTemplateMessage: InboundBulkTemplateMessage) = apply { - brandId = inboundBulkTemplateMessage.brandId - channels = inboundBulkTemplateMessage.channels - context = inboundBulkTemplateMessage.context - data = inboundBulkTemplateMessage.data - delay = inboundBulkTemplateMessage.delay - expiry = inboundBulkTemplateMessage.expiry - metadata = inboundBulkTemplateMessage.metadata - preferences = inboundBulkTemplateMessage.preferences - providers = inboundBulkTemplateMessage.providers - routing = inboundBulkTemplateMessage.routing - timeout = inboundBulkTemplateMessage.timeout - template = inboundBulkTemplateMessage.template - additionalProperties = - inboundBulkTemplateMessage.additionalProperties.toMutableMap() - } - - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * "Define run-time configuration for one or more channels. If you don't specify - * channels, the default configuration for each channel will be used. Valid - * ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - fun channels(channels: BaseMessage.Channels?) = - channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional) = - channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed - * [BaseMessage.Channels] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun channels(channels: JsonField) = apply { - this.channels = channels - } - - /** - * Context to load with this recipient. Will override any context set on - * message.context. - */ - fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [MessageContext] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - /** - * An arbitrary object that includes any data you want to pass to the message. The - * data will populate the corresponding template or elements variables. - */ - fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - /** - * Defines the time to wait before delivering the message. You can specify one of - * the following options. Duration with the number of milliseconds to delay. Until - * with an ISO 8601 timestamp that specifies when it should be delivered. Until with - * an OpenStreetMap opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) - - /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ - fun delay(delay: Optional) = delay(delay.getOrNull()) - - /** - * Sets [Builder.delay] to an arbitrary JSON value. - * - * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun delay(delay: JsonField) = apply { this.delay = delay } - - /** - * "Expiry allows you to set an absolute or relative time in which a message - * expires. Note: This is only valid for the Courier Inbox channel as of - * 12-08-2022." - */ - fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) - - /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ - fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) - - /** - * Sets [Builder.expiry] to an arbitrary JSON value. - * - * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun expiry(expiry: JsonField) = apply { this.expiry = expiry } - - /** - * Metadata such as utm tracking attached with the notification through this - * channel. - */ - fun metadata(metadata: BaseMessage.Metadata?) = - metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = - metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [BaseMessage.Metadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun preferences(preferences: BaseMessage.Preferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [BaseMessage.Preferences] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** An object whose keys are valid provider identifiers which map to an object. */ - fun providers(providers: BaseMessage.Providers?) = - providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional) = - providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed - * [BaseMessage.Providers] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun providers(providers: JsonField) = apply { - this.providers = providers - } - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the - * message. If no routing key is specified, Courier will use the default routing - * configuration or routing defined by the template. - */ - fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) - - /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ - fun routing(routing: Optional) = routing(routing.getOrNull()) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun routing(routing: JsonField) = apply { - this.routing = routing - } - - /** - * Time in ms to attempt the channel before failing over to the next available - * channel. - */ - fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) - - /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ - fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) - - /** - * Sets [Builder.timeout] to an arbitrary JSON value. - * - * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun timeout(timeout: JsonField) = apply { - this.timeout = timeout - } - - /** - * The id of the notification template to be rendered and sent to the recipient(s). - * This field or the content field must be supplied. - */ - fun template(template: String) = template(JsonField.of(template)) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InboundBulkTemplateMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .template() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InboundBulkTemplateMessage = - InboundBulkTemplateMessage( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - checkRequired("template", template), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InboundBulkTemplateMessage = apply { - if (validated) { - return@apply - } - - brandId() - channels().ifPresent { it.validate() } - context().ifPresent { it.validate() } - data().ifPresent { it.validate() } - delay().ifPresent { it.validate() } - expiry().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - preferences().ifPresent { it.validate() } - providers().ifPresent { it.validate() } - routing().ifPresent { it.validate() } - timeout().ifPresent { it.validate() } - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brandId.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.validity() ?: 0) + - (context.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (delay.asKnown().getOrNull()?.validity() ?: 0) + - (expiry.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.validity() ?: 0) + - (routing.asKnown().getOrNull()?.validity() ?: 0) + - (timeout.asKnown().getOrNull()?.validity() ?: 0) + - (if (template.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundBulkTemplateMessage && - brandId == other.brandId && - channels == other.channels && - context == other.context && - data == other.data && - delay == other.delay && - expiry == other.expiry && - metadata == other.metadata && - preferences == other.preferences && - providers == other.providers && - routing == other.routing && - timeout == other.timeout && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - template, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundBulkTemplateMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, template=$template, additionalProperties=$additionalProperties}" - } - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - class InboundBulkContentMessage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val brandId: JsonField, - private val channels: JsonField, - private val context: JsonField, - private val data: JsonField, - private val delay: JsonField, - private val expiry: JsonField, - private val metadata: JsonField, - private val preferences: JsonField, - private val providers: JsonField, - private val routing: JsonField, - private val timeout: JsonField, - private val content: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("brand_id") - @ExcludeMissing - brandId: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - context: JsonField = JsonMissing.of(), - @JsonProperty("data") - @ExcludeMissing - data: JsonField = JsonMissing.of(), - @JsonProperty("delay") - @ExcludeMissing - delay: JsonField = JsonMissing.of(), - @JsonProperty("expiry") - @ExcludeMissing - expiry: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField = JsonMissing.of(), - @JsonProperty("routing") - @ExcludeMissing - routing: JsonField = JsonMissing.of(), - @JsonProperty("timeout") - @ExcludeMissing - timeout: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - content: JsonField = JsonMissing.of(), - ) : this( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - content, - mutableMapOf(), - ) - - fun toBaseMessage(): BaseMessage = - BaseMessage.builder() - .brandId(brandId) - .channels(channels) - .context(context) - .data(data) - .delay(delay) - .expiry(expiry) - .metadata(metadata) - .preferences(preferences) - .providers(providers) - .routing(routing) - .timeout(timeout) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * "Define run-time configuration for one or more channels. If you don't specify - * channels, the default configuration for each channel will be used. Valid ChannelId's - * are: email, sms, push, inbox, direct_message, banner, and webhook." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun channels(): Optional = channels.getOptional("channels") - - /** - * Context to load with this recipient. Will override any context set on - * message.context. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * An arbitrary object that includes any data you want to pass to the message. The data - * will populate the corresponding template or elements variables. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an - * ISO 8601 timestamp that specifies when it should be delivered. Until with an - * OpenStreetMap opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun delay(): Optional = delay.getOptional("delay") - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun expiry(): Optional = expiry.getOptional("expiry") - - /** - * Metadata such as utm tracking attached with the notification through this channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun preferences(): Optional = - preferences.getOptional("preferences") - - /** - * An object whose keys are valid provider identifiers which map to an object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun providers(): Optional = providers.getOptional("providers") - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the - * message. If no routing key is specified, Courier will use the default routing - * configuration or routing defined by the template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun routing(): Optional = routing.getOptional("routing") - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun timeout(): Optional = timeout.getOptional("timeout") - - /** - * Describes the content of the message in a way that will work for email, push, chat, - * or any channel. Either this or template must be specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun content(): Content = content.getRequired("content") - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField = channels - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") - @ExcludeMissing - fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [delay]. - * - * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delay") - @ExcludeMissing - fun _delay(): JsonField = delay - - /** - * Returns the raw JSON value of [expiry]. - * - * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry") - @ExcludeMissing - fun _expiry(): JsonField = expiry - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("providers") - @ExcludeMissing - fun _providers(): JsonField = providers - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") - @ExcludeMissing - fun _routing(): JsonField = routing - - /** - * Returns the raw JSON value of [timeout]. - * - * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timeout") - @ExcludeMissing - fun _timeout(): JsonField = timeout - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InboundBulkContentMessage]. - * - * The following fields are required: - * ```java - * .content() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundBulkContentMessage]. */ - class Builder internal constructor() { - - private var brandId: JsonField = JsonMissing.of() - private var channels: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var delay: JsonField = JsonMissing.of() - private var expiry: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var providers: JsonField = JsonMissing.of() - private var routing: JsonField = JsonMissing.of() - private var timeout: JsonField = JsonMissing.of() - private var content: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundBulkContentMessage: InboundBulkContentMessage) = apply { - brandId = inboundBulkContentMessage.brandId - channels = inboundBulkContentMessage.channels - context = inboundBulkContentMessage.context - data = inboundBulkContentMessage.data - delay = inboundBulkContentMessage.delay - expiry = inboundBulkContentMessage.expiry - metadata = inboundBulkContentMessage.metadata - preferences = inboundBulkContentMessage.preferences - providers = inboundBulkContentMessage.providers - routing = inboundBulkContentMessage.routing - timeout = inboundBulkContentMessage.timeout - content = inboundBulkContentMessage.content - additionalProperties = - inboundBulkContentMessage.additionalProperties.toMutableMap() - } - - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * "Define run-time configuration for one or more channels. If you don't specify - * channels, the default configuration for each channel will be used. Valid - * ChannelId's are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - fun channels(channels: BaseMessage.Channels?) = - channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional) = - channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed - * [BaseMessage.Channels] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun channels(channels: JsonField) = apply { - this.channels = channels - } - - /** - * Context to load with this recipient. Will override any context set on - * message.context. - */ - fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [MessageContext] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - /** - * An arbitrary object that includes any data you want to pass to the message. The - * data will populate the corresponding template or elements variables. - */ - fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - /** - * Defines the time to wait before delivering the message. You can specify one of - * the following options. Duration with the number of milliseconds to delay. Until - * with an ISO 8601 timestamp that specifies when it should be delivered. Until with - * an OpenStreetMap opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) - - /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ - fun delay(delay: Optional) = delay(delay.getOrNull()) - - /** - * Sets [Builder.delay] to an arbitrary JSON value. - * - * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun delay(delay: JsonField) = apply { this.delay = delay } - - /** - * "Expiry allows you to set an absolute or relative time in which a message - * expires. Note: This is only valid for the Courier Inbox channel as of - * 12-08-2022." - */ - fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) - - /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ - fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) - - /** - * Sets [Builder.expiry] to an arbitrary JSON value. - * - * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun expiry(expiry: JsonField) = apply { this.expiry = expiry } - - /** - * Metadata such as utm tracking attached with the notification through this - * channel. - */ - fun metadata(metadata: BaseMessage.Metadata?) = - metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = - metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [BaseMessage.Metadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun preferences(preferences: BaseMessage.Preferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [BaseMessage.Preferences] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** An object whose keys are valid provider identifiers which map to an object. */ - fun providers(providers: BaseMessage.Providers?) = - providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional) = - providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed - * [BaseMessage.Providers] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun providers(providers: JsonField) = apply { - this.providers = providers - } - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the - * message. If no routing key is specified, Courier will use the default routing - * configuration or routing defined by the template. - */ - fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) - - /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ - fun routing(routing: Optional) = routing(routing.getOrNull()) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun routing(routing: JsonField) = apply { - this.routing = routing - } - - /** - * Time in ms to attempt the channel before failing over to the next available - * channel. - */ - fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) - - /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ - fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) - - /** - * Sets [Builder.timeout] to an arbitrary JSON value. - * - * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun timeout(timeout: JsonField) = apply { - this.timeout = timeout - } - - /** - * Describes the content of the message in a way that will work for email, push, - * chat, or any channel. Either this or template must be specified. - */ - fun content(content: Content) = content(JsonField.of(content)) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [Content] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) - - /** - * Alias for calling [content] with - * `Content.ofElementalContentSugar(elementalContentSugar)`. - */ - fun content(elementalContentSugar: Content.ElementalContentSugar) = - content(Content.ofElementalContentSugar(elementalContentSugar)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InboundBulkContentMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .content() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InboundBulkContentMessage = - InboundBulkContentMessage( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - checkRequired("content", content), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InboundBulkContentMessage = apply { - if (validated) { - return@apply - } - - brandId() - channels().ifPresent { it.validate() } - context().ifPresent { it.validate() } - data().ifPresent { it.validate() } - delay().ifPresent { it.validate() } - expiry().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - preferences().ifPresent { it.validate() } - providers().ifPresent { it.validate() } - routing().ifPresent { it.validate() } - timeout().ifPresent { it.validate() } - content().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brandId.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.validity() ?: 0) + - (context.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (delay.asKnown().getOrNull()?.validity() ?: 0) + - (expiry.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.validity() ?: 0) + - (routing.asKnown().getOrNull()?.validity() ?: 0) + - (timeout.asKnown().getOrNull()?.validity() ?: 0) + - (content.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundBulkContentMessage && - brandId == other.brandId && - channels == other.channels && - context == other.context && - data == other.data && - delay == other.delay && - expiry == other.expiry && - metadata == other.metadata && - preferences == other.preferences && - providers == other.providers && - routing == other.routing && - timeout == other.timeout && - content == other.content && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - content, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundBulkContentMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, content=$content, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundBulkMessage && - brand == other.brand && - data == other.data && - event == other.event && - locale == other.locale && - message == other.message && - override == other.override && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(brand, data, event, locale, message, override, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundBulkMessage{brand=$brand, data=$data, event=$event, locale=$locale, message=$message, override=$override, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt deleted file mode 100644 index 2ebcd6da..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/InboundBulkMessageUser.kt +++ /dev/null @@ -1,264 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class InboundBulkMessageUser -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val data: JsonValue, - private val preferences: JsonField, - private val profile: JsonValue, - private val recipient: JsonField, - private val to: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonValue = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonValue = JsonMissing.of(), - @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), - ) : this(data, preferences, profile, recipient, to, mutableMapOf()) - - @JsonProperty("data") @ExcludeMissing fun _data(): JsonValue = data - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonValue = profile - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun recipient(): Optional = recipient.getOptional("recipient") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [InboundBulkMessageUser]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundBulkMessageUser]. */ - class Builder internal constructor() { - - private var data: JsonValue = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var profile: JsonValue = JsonMissing.of() - private var recipient: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundBulkMessageUser: InboundBulkMessageUser) = apply { - data = inboundBulkMessageUser.data - preferences = inboundBulkMessageUser.preferences - profile = inboundBulkMessageUser.profile - recipient = inboundBulkMessageUser.recipient - to = inboundBulkMessageUser.to - additionalProperties = inboundBulkMessageUser.additionalProperties.toMutableMap() - } - - fun data(data: JsonValue) = apply { this.data = data } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun profile(profile: JsonValue) = apply { this.profile = profile } - - fun recipient(recipient: String?) = recipient(JsonField.ofNullable(recipient)) - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - fun to(to: UserRecipient?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [UserRecipient] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun to(to: JsonField) = apply { this.to = to } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InboundBulkMessageUser]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InboundBulkMessageUser = - InboundBulkMessageUser( - data, - preferences, - profile, - recipient, - to, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InboundBulkMessageUser = apply { - if (validated) { - return@apply - } - - preferences().ifPresent { it.validate() } - recipient() - to().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (to.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundBulkMessageUser && - data == other.data && - preferences == other.preferences && - profile == other.profile && - recipient == other.recipient && - to == other.to && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, preferences, profile, recipient, to, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundBulkMessageUser{data=$data, preferences=$preferences, profile=$profile, recipient=$recipient, to=$to, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt deleted file mode 100644 index 4514b207..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/bulk/UserRecipient.kt +++ /dev/null @@ -1,1046 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.send.MessageContext -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class UserRecipient -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val accountId: JsonField, - private val context: JsonField, - private val data: JsonField, - private val email: JsonField, - private val locale: JsonField, - private val phoneNumber: JsonField, - private val preferences: JsonField, - private val tenantId: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - context: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), - @JsonProperty("locale") @ExcludeMissing locale: JsonField = JsonMissing.of(), - @JsonProperty("phone_number") - @ExcludeMissing - phoneNumber: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), - ) : this( - accountId, - context, - data, - email, - locale, - phoneNumber, - preferences, - tenantId, - userId, - mutableMapOf(), - ) - - /** - * Use `tenant_id` instad. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun accountId(): Optional = accountId.getOptional("account_id") - - /** - * Context information such as tenant_id to send the notification with. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun email(): Optional = email.getOptional("email") - - /** - * The user's preferred ISO 639-1 language code. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun locale(): Optional = locale.getOptional("locale") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * An id of a tenant, [see tenants api docs](https://www.courier.com/docs/reference/tenants). - * Will load brand, default preferences and any other base context data associated with this - * tenant. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tenantId(): Optional = tenantId.getOptional("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userId(): Optional = userId.getOptional("user_id") - - /** - * Returns the raw JSON value of [accountId]. - * - * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - /** - * Returns the raw JSON value of [locale]. - * - * Unlike [locale], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale - - /** - * Returns the raw JSON value of [phoneNumber]. - * - * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("phone_number") - @ExcludeMissing - fun _phoneNumber(): JsonField = phoneNumber - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UserRecipient]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UserRecipient]. */ - class Builder internal constructor() { - - private var accountId: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var locale: JsonField = JsonMissing.of() - private var phoneNumber: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var tenantId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(userRecipient: UserRecipient) = apply { - accountId = userRecipient.accountId - context = userRecipient.context - data = userRecipient.data - email = userRecipient.email - locale = userRecipient.locale - phoneNumber = userRecipient.phoneNumber - preferences = userRecipient.preferences - tenantId = userRecipient.tenantId - userId = userRecipient.userId - additionalProperties = userRecipient.additionalProperties.toMutableMap() - } - - /** Use `tenant_id` instad. */ - fun accountId(accountId: String?) = accountId(JsonField.ofNullable(accountId)) - - /** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */ - fun accountId(accountId: Optional) = accountId(accountId.getOrNull()) - - /** - * Sets [Builder.accountId] to an arbitrary JSON value. - * - * You should usually call [Builder.accountId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun accountId(accountId: JsonField) = apply { this.accountId = accountId } - - /** Context information such as tenant_id to send the notification with. */ - fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [MessageContext] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun email(email: String?) = email(JsonField.ofNullable(email)) - - /** Alias for calling [Builder.email] with `email.orElse(null)`. */ - fun email(email: Optional) = email(email.getOrNull()) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - /** The user's preferred ISO 639-1 language code. */ - fun locale(locale: String?) = locale(JsonField.ofNullable(locale)) - - /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ - fun locale(locale: Optional) = locale(locale.getOrNull()) - - /** - * Sets [Builder.locale] to an arbitrary JSON value. - * - * You should usually call [Builder.locale] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun locale(locale: JsonField) = apply { this.locale = locale } - - fun phoneNumber(phoneNumber: String?) = phoneNumber(JsonField.ofNullable(phoneNumber)) - - /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ - fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.getOrNull()) - - /** - * Sets [Builder.phoneNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } - - fun preferences(preferences: Preferences?) = preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [Preferences] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** - * An id of a tenant, - * [see tenants api docs](https://www.courier.com/docs/reference/tenants). Will load brand, - * default preferences and any other base context data associated with this tenant. - */ - fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UserRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UserRecipient = - UserRecipient( - accountId, - context, - data, - email, - locale, - phoneNumber, - preferences, - tenantId, - userId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UserRecipient = apply { - if (validated) { - return@apply - } - - accountId() - context().ifPresent { it.validate() } - data().ifPresent { it.validate() } - email() - locale() - phoneNumber() - preferences().ifPresent { it.validate() } - tenantId() - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accountId.asKnown().isPresent) 1 else 0) + - (context.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (email.asKnown().isPresent) 1 else 0) + - (if (locale.asKnown().isPresent) 1 else 0) + - (if (phoneNumber.asKnown().isPresent) 1 else 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Preferences - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val notifications: JsonField, - private val categories: JsonField, - private val templateId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("notifications") - @ExcludeMissing - notifications: JsonField = JsonMissing.of(), - @JsonProperty("categories") - @ExcludeMissing - categories: JsonField = JsonMissing.of(), - @JsonProperty("templateId") - @ExcludeMissing - templateId: JsonField = JsonMissing.of(), - ) : this(notifications, categories, templateId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun notifications(): Notifications = notifications.getRequired("notifications") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun categories(): Optional = categories.getOptional("categories") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun templateId(): Optional = templateId.getOptional("templateId") - - /** - * Returns the raw JSON value of [notifications]. - * - * Unlike [notifications], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("notifications") - @ExcludeMissing - fun _notifications(): JsonField = notifications - - /** - * Returns the raw JSON value of [categories]. - * - * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("categories") - @ExcludeMissing - fun _categories(): JsonField = categories - - /** - * Returns the raw JSON value of [templateId]. - * - * Unlike [templateId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("templateId") - @ExcludeMissing - fun _templateId(): JsonField = templateId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Preferences]. - * - * The following fields are required: - * ```java - * .notifications() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Preferences]. */ - class Builder internal constructor() { - - private var notifications: JsonField? = null - private var categories: JsonField = JsonMissing.of() - private var templateId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(preferences: Preferences) = apply { - notifications = preferences.notifications - categories = preferences.categories - templateId = preferences.templateId - additionalProperties = preferences.additionalProperties.toMutableMap() - } - - fun notifications(notifications: Notifications) = - notifications(JsonField.of(notifications)) - - /** - * Sets [Builder.notifications] to an arbitrary JSON value. - * - * You should usually call [Builder.notifications] with a well-typed [Notifications] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun notifications(notifications: JsonField) = apply { - this.notifications = notifications - } - - fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - - /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ - fun categories(categories: Optional) = categories(categories.getOrNull()) - - /** - * Sets [Builder.categories] to an arbitrary JSON value. - * - * You should usually call [Builder.categories] with a well-typed [Categories] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun categories(categories: JsonField) = apply { - this.categories = categories - } - - fun templateId(templateId: String?) = templateId(JsonField.ofNullable(templateId)) - - /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ - fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) - - /** - * Sets [Builder.templateId] to an arbitrary JSON value. - * - * You should usually call [Builder.templateId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun templateId(templateId: JsonField) = apply { this.templateId = templateId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Preferences]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .notifications() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Preferences = - Preferences( - checkRequired("notifications", notifications), - categories, - templateId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Preferences = apply { - if (validated) { - return@apply - } - - notifications().validate() - categories().ifPresent { it.validate() } - templateId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (notifications.asKnown().getOrNull()?.validity() ?: 0) + - (categories.asKnown().getOrNull()?.validity() ?: 0) + - (if (templateId.asKnown().isPresent) 1 else 0) - - class Notifications - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Notifications]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Notifications]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(notifications: Notifications) = apply { - additionalProperties = notifications.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Notifications]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Notifications = Notifications(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Notifications = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Notifications && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Notifications{additionalProperties=$additionalProperties}" - } - - class Categories - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Categories]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Categories]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(categories: Categories) = apply { - additionalProperties = categories.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Categories]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Categories = Categories(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Categories = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Categories && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Categories{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Preferences && - notifications == other.notifications && - categories == other.categories && - templateId == other.templateId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(notifications, categories, templateId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Preferences{notifications=$notifications, categories=$categories, templateId=$templateId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserRecipient && - accountId == other.accountId && - context == other.context && - data == other.data && - email == other.email && - locale == other.locale && - phoneNumber == other.phoneNumber && - preferences == other.preferences && - tenantId == other.tenantId && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - accountId, - context, - data, - email, - locale, - phoneNumber, - preferences, - tenantId, - userId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UserRecipient{accountId=$accountId, context=$context, data=$data, email=$email, locale=$locale, phoneNumber=$phoneNumber, preferences=$preferences, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt deleted file mode 100644 index 8f548040..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventParams.kt +++ /dev/null @@ -1,925 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.inbound - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Courier Track Event */ -class InboundTrackEventParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * A descriptive name of the event. This name will appear as a trigger in the Courier Automation - * Trigger node. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun event(): String = body.event() - - /** - * A required unique identifier that will be used to de-duplicate requests. If not unique, will - * respond with 409 Conflict status - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun messageId(): String = body.messageId() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun properties(): Properties = body.properties() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = body.type() - - /** - * The user id associatiated with the track - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userId(): Optional = body.userId() - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _event(): JsonField = body._event() - - /** - * Returns the raw JSON value of [messageId]. - * - * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _messageId(): JsonField = body._messageId() - - /** - * Returns the raw JSON value of [properties]. - * - * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _properties(): JsonField = body._properties() - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _type(): JsonField = body._type() - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _userId(): JsonField = body._userId() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [InboundTrackEventParams]. - * - * The following fields are required: - * ```java - * .event() - * .messageId() - * .properties() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundTrackEventParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(inboundTrackEventParams: InboundTrackEventParams) = apply { - body = inboundTrackEventParams.body.toBuilder() - additionalHeaders = inboundTrackEventParams.additionalHeaders.toBuilder() - additionalQueryParams = inboundTrackEventParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [event] - * - [messageId] - * - [properties] - * - [type] - * - [userId] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** - * A descriptive name of the event. This name will appear as a trigger in the Courier - * Automation Trigger node. - */ - fun event(event: String) = apply { body.event(event) } - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun event(event: JsonField) = apply { body.event(event) } - - /** - * A required unique identifier that will be used to de-duplicate requests. If not unique, - * will respond with 409 Conflict status - */ - fun messageId(messageId: String) = apply { body.messageId(messageId) } - - /** - * Sets [Builder.messageId] to an arbitrary JSON value. - * - * You should usually call [Builder.messageId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun messageId(messageId: JsonField) = apply { body.messageId(messageId) } - - fun properties(properties: Properties) = apply { body.properties(properties) } - - /** - * Sets [Builder.properties] to an arbitrary JSON value. - * - * You should usually call [Builder.properties] with a well-typed [Properties] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun properties(properties: JsonField) = apply { body.properties(properties) } - - fun type(type: Type) = apply { body.type(type) } - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { body.type(type) } - - /** The user id associatiated with the track */ - fun userId(userId: String?) = apply { body.userId(userId) } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { body.userId(userId) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [InboundTrackEventParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .event() - * .messageId() - * .properties() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InboundTrackEventParams = - InboundTrackEventParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val event: JsonField, - private val messageId: JsonField, - private val properties: JsonField, - private val type: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("messageId") - @ExcludeMissing - messageId: JsonField = JsonMissing.of(), - @JsonProperty("properties") - @ExcludeMissing - properties: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("userId") @ExcludeMissing userId: JsonField = JsonMissing.of(), - ) : this(event, messageId, properties, type, userId, mutableMapOf()) - - /** - * A descriptive name of the event. This name will appear as a trigger in the Courier - * Automation Trigger node. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun event(): String = event.getRequired("event") - - /** - * A required unique identifier that will be used to de-duplicate requests. If not unique, - * will respond with 409 Conflict status - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun messageId(): String = messageId.getRequired("messageId") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun properties(): Properties = properties.getRequired("properties") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * The user id associatiated with the track - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userId(): Optional = userId.getOptional("userId") - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - - /** - * Returns the raw JSON value of [messageId]. - * - * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId - - /** - * Returns the raw JSON value of [properties]. - * - * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("properties") - @ExcludeMissing - fun _properties(): JsonField = properties - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("userId") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .event() - * .messageId() - * .properties() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var event: JsonField? = null - private var messageId: JsonField? = null - private var properties: JsonField? = null - private var type: JsonField? = null - private var userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - event = body.event - messageId = body.messageId - properties = body.properties - type = body.type - userId = body.userId - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** - * A descriptive name of the event. This name will appear as a trigger in the Courier - * Automation Trigger node. - */ - fun event(event: String) = event(JsonField.of(event)) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - /** - * A required unique identifier that will be used to de-duplicate requests. If not - * unique, will respond with 409 Conflict status - */ - fun messageId(messageId: String) = messageId(JsonField.of(messageId)) - - /** - * Sets [Builder.messageId] to an arbitrary JSON value. - * - * You should usually call [Builder.messageId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun messageId(messageId: JsonField) = apply { this.messageId = messageId } - - fun properties(properties: Properties) = properties(JsonField.of(properties)) - - /** - * Sets [Builder.properties] to an arbitrary JSON value. - * - * You should usually call [Builder.properties] with a well-typed [Properties] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun properties(properties: JsonField) = apply { - this.properties = properties - } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** The user id associatiated with the track */ - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .event() - * .messageId() - * .properties() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("event", event), - checkRequired("messageId", messageId), - checkRequired("properties", properties), - checkRequired("type", type), - userId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - event() - messageId() - properties().validate() - type().validate() - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (event.asKnown().isPresent) 1 else 0) + - (if (messageId.asKnown().isPresent) 1 else 0) + - (properties.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - event == other.event && - messageId == other.messageId && - properties == other.properties && - type == other.type && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(event, messageId, properties, type, userId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{event=$event, messageId=$messageId, properties=$properties, type=$type, userId=$userId, additionalProperties=$additionalProperties}" - } - - class Properties - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Properties]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Properties]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(properties: Properties) = apply { - additionalProperties = properties.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Properties]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Properties = Properties(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Properties = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Properties && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Properties{additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TRACK = of("track") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TRACK - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TRACK, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TRACK -> Value.TRACK - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TRACK -> Known.TRACK - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundTrackEventParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "InboundTrackEventParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt deleted file mode 100644 index 0021c852..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/inbound/InboundTrackEventResponse.kt +++ /dev/null @@ -1,177 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.inbound - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class InboundTrackEventResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val messageId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("messageId") @ExcludeMissing messageId: JsonField = JsonMissing.of() - ) : this(messageId, mutableMapOf()) - - /** - * A successful call returns a `202` status code along with a `requestId` in the response body. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun messageId(): String = messageId.getRequired("messageId") - - /** - * Returns the raw JSON value of [messageId]. - * - * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("messageId") @ExcludeMissing fun _messageId(): JsonField = messageId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [InboundTrackEventResponse]. - * - * The following fields are required: - * ```java - * .messageId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InboundTrackEventResponse]. */ - class Builder internal constructor() { - - private var messageId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(inboundTrackEventResponse: InboundTrackEventResponse) = apply { - messageId = inboundTrackEventResponse.messageId - additionalProperties = inboundTrackEventResponse.additionalProperties.toMutableMap() - } - - /** - * A successful call returns a `202` status code along with a `requestId` in the response - * body. - */ - fun messageId(messageId: String) = messageId(JsonField.of(messageId)) - - /** - * Sets [Builder.messageId] to an arbitrary JSON value. - * - * You should usually call [Builder.messageId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun messageId(messageId: JsonField) = apply { this.messageId = messageId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InboundTrackEventResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .messageId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): InboundTrackEventResponse = - InboundTrackEventResponse( - checkRequired("messageId", messageId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): InboundTrackEventResponse = apply { - if (validated) { - return@apply - } - - messageId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (messageId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InboundTrackEventResponse && - messageId == other.messageId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(messageId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InboundTrackEventResponse{messageId=$messageId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt deleted file mode 100644 index b7713493..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/List.kt +++ /dev/null @@ -1,277 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class List -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val name: JsonField, - private val created: JsonField, - private val updated: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), - @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), - ) : this(id, name, created, updated, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun created(): Optional = created.getOptional("created") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun updated(): Optional = updated.getOptional("updated") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [created]. - * - * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - - /** - * Returns the raw JSON value of [updated]. - * - * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [List]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var created: JsonField = JsonMissing.of() - private var updated: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - id = list.id - name = list.name - created = list.created - updated = list.updated - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun created(created: String?) = created(JsonField.ofNullable(created)) - - /** Alias for calling [Builder.created] with `created.orElse(null)`. */ - fun created(created: Optional) = created(created.getOrNull()) - - /** - * Sets [Builder.created] to an arbitrary JSON value. - * - * You should usually call [Builder.created] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun created(created: JsonField) = apply { this.created = created } - - fun updated(updated: String?) = updated(JsonField.ofNullable(updated)) - - /** Alias for calling [Builder.updated] with `updated.orElse(null)`. */ - fun updated(updated: Optional) = updated(updated.getOrNull()) - - /** - * Sets [Builder.updated] to an arbitrary JSON value. - * - * You should usually call [Builder.updated] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [List]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): List = - List( - checkRequired("id", id), - checkRequired("name", name), - created, - updated, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - id() - name() - created() - updated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (created.asKnown().isPresent) 1 else 0) + - (if (updated.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is List && - id == other.id && - name == other.name && - created == other.created && - updated == other.updated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, name, created, updated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{id=$id, name=$name, created=$created, updated=$updated, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt deleted file mode 100644 index d528739e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete a list by list ID. */ -class ListDeleteParams -private constructor( - private val listId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ListDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ListDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListDeleteParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(listDeleteParams: ListDeleteParams) = apply { - listId = listDeleteParams.listId - additionalHeaders = listDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = listDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = listDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [ListDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ListDeleteParams = - ListDeleteParams( - listId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListDeleteParams && - listId == other.listId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(listId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "ListDeleteParams{listId=$listId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt deleted file mode 100644 index ed5ba28a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListParams.kt +++ /dev/null @@ -1,220 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns all of the lists, with the ability to filter based on a pattern. */ -class ListListParams -private constructor( - private val cursor: String?, - private val pattern: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** A unique identifier that allows for fetching the next page of lists. */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** - * "A pattern used to filter the list items returned. Pattern types supported: exact match on - * `list_id` or a pattern of one or more pattern parts. you may replace a part with either: `*` - * to match all parts in that position, or `**` to signify a wildcard `endsWith` pattern match." - */ - fun pattern(): Optional = Optional.ofNullable(pattern) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ListListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ListListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListListParams]. */ - class Builder internal constructor() { - - private var cursor: String? = null - private var pattern: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(listListParams: ListListParams) = apply { - cursor = listListParams.cursor - pattern = listListParams.pattern - additionalHeaders = listListParams.additionalHeaders.toBuilder() - additionalQueryParams = listListParams.additionalQueryParams.toBuilder() - } - - /** A unique identifier that allows for fetching the next page of lists. */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** - * "A pattern used to filter the list items returned. Pattern types supported: exact match - * on `list_id` or a pattern of one or more pattern parts. you may replace a part with - * either: `*` to match all parts in that position, or `**` to signify a wildcard `endsWith` - * pattern match." - */ - fun pattern(pattern: String?) = apply { this.pattern = pattern } - - /** Alias for calling [Builder.pattern] with `pattern.orElse(null)`. */ - fun pattern(pattern: Optional) = pattern(pattern.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ListListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ListListParams = - ListListParams( - cursor, - pattern, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - pattern?.let { put("pattern", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListListParams && - cursor == other.cursor && - pattern == other.pattern && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(cursor, pattern, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ListListParams{cursor=$cursor, pattern=$pattern, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt deleted file mode 100644 index f7c1b69f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListListResponse.kt +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ListListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListListResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListListResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(listListResponse: ListListResponse) = apply { - items = listListResponse.items.map { it.toMutableList() } - paging = listListResponse.paging - additionalProperties = listListResponse.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [List] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: List) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ListListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListListResponse = - ListListResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ListListResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListListResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ListListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt deleted file mode 100644 index f2571912..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRestoreParams.kt +++ /dev/null @@ -1,219 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Restore a previously deleted list. */ -class ListRestoreParams -private constructor( - private val listId: String?, - private val body: JsonValue, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - fun body(): JsonValue = body - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListRestoreParams]. - * - * The following fields are required: - * ```java - * .body() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListRestoreParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var body: JsonValue? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(listRestoreParams: ListRestoreParams) = apply { - listId = listRestoreParams.listId - body = listRestoreParams.body - additionalHeaders = listRestoreParams.additionalHeaders.toBuilder() - additionalQueryParams = listRestoreParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - fun body(body: JsonValue) = apply { this.body = body } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ListRestoreParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .body() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListRestoreParams = - ListRestoreParams( - listId, - checkRequired("body", body), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): JsonValue = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListRestoreParams && - listId == other.listId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(listId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ListRestoreParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt deleted file mode 100644 index dfafc11c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns a list based on the list ID provided. */ -class ListRetrieveParams -private constructor( - private val listId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ListRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ListRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListRetrieveParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(listRetrieveParams: ListRetrieveParams) = apply { - listId = listRetrieveParams.listId - additionalHeaders = listRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = listRetrieveParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ListRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ListRetrieveParams = - ListRetrieveParams(listId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListRetrieveParams && - listId == other.listId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(listId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ListRetrieveParams{listId=$listId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt deleted file mode 100644 index e6d72757..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/ListUpdateParams.kt +++ /dev/null @@ -1,508 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Create or replace an existing list with the supplied values. */ -class ListUpdateParams -private constructor( - private val listId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = body.name() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = body.preferences() - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _name(): JsonField = body._name() - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _preferences(): JsonField = body._preferences() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListUpdateParams]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListUpdateParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(listUpdateParams: ListUpdateParams) = apply { - listId = listUpdateParams.listId - body = listUpdateParams.body.toBuilder() - additionalHeaders = listUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = listUpdateParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [name] - * - [preferences] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun name(name: String) = apply { body.name(name) } - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { body.name(name) } - - fun preferences(preferences: RecipientPreferences?) = apply { - body.preferences(preferences) - } - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - body.preferences(preferences) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ListUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListUpdateParams = - ListUpdateParams( - listId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val preferences: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - ) : this(name, preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - preferences = body.preferences - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("name", name), preferences, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - name() - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - name == other.name && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, preferences, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{name=$name, preferences=$preferences, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListUpdateParams && - listId == other.listId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(listId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ListUpdateParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt deleted file mode 100644 index 1117de10..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetails.kt +++ /dev/null @@ -1,292 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.ChannelPreference -import com.courier.api.models.Rule -import com.courier.api.models.users.preferences.PreferenceStatus -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class NotificationPreferenceDetails -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val channelPreferences: JsonField>, - private val rules: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("channel_preferences") - @ExcludeMissing - channelPreferences: JsonField> = JsonMissing.of(), - @JsonProperty("rules") @ExcludeMissing rules: JsonField> = JsonMissing.of(), - ) : this(status, channelPreferences, rules, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): PreferenceStatus = status.getRequired("status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channelPreferences(): Optional> = - channelPreferences.getOptional("channel_preferences") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun rules(): Optional> = rules.getOptional("rules") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [channelPreferences]. - * - * Unlike [channelPreferences], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channel_preferences") - @ExcludeMissing - fun _channelPreferences(): JsonField> = channelPreferences - - /** - * Returns the raw JSON value of [rules]. - * - * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NotificationPreferenceDetails]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NotificationPreferenceDetails]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var channelPreferences: JsonField>? = null - private var rules: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(notificationPreferenceDetails: NotificationPreferenceDetails) = apply { - status = notificationPreferenceDetails.status - channelPreferences = - notificationPreferenceDetails.channelPreferences.map { it.toMutableList() } - rules = notificationPreferenceDetails.rules.map { it.toMutableList() } - additionalProperties = notificationPreferenceDetails.additionalProperties.toMutableMap() - } - - fun status(status: PreferenceStatus) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun channelPreferences(channelPreferences: List?) = - channelPreferences(JsonField.ofNullable(channelPreferences)) - - /** - * Alias for calling [Builder.channelPreferences] with `channelPreferences.orElse(null)`. - */ - fun channelPreferences(channelPreferences: Optional>) = - channelPreferences(channelPreferences.getOrNull()) - - /** - * Sets [Builder.channelPreferences] to an arbitrary JSON value. - * - * You should usually call [Builder.channelPreferences] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun channelPreferences(channelPreferences: JsonField>) = apply { - this.channelPreferences = channelPreferences.map { it.toMutableList() } - } - - /** - * Adds a single [ChannelPreference] to [channelPreferences]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannelPreference(channelPreference: ChannelPreference) = apply { - channelPreferences = - (channelPreferences ?: JsonField.of(mutableListOf())).also { - checkKnown("channelPreferences", it).add(channelPreference) - } - } - - fun rules(rules: List?) = rules(JsonField.ofNullable(rules)) - - /** Alias for calling [Builder.rules] with `rules.orElse(null)`. */ - fun rules(rules: Optional>) = rules(rules.getOrNull()) - - /** - * Sets [Builder.rules] to an arbitrary JSON value. - * - * You should usually call [Builder.rules] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun rules(rules: JsonField>) = apply { - this.rules = rules.map { it.toMutableList() } - } - - /** - * Adds a single [Rule] to [rules]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRule(rule: Rule) = apply { - rules = - (rules ?: JsonField.of(mutableListOf())).also { checkKnown("rules", it).add(rule) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NotificationPreferenceDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NotificationPreferenceDetails = - NotificationPreferenceDetails( - checkRequired("status", status), - (channelPreferences ?: JsonMissing.of()).map { it.toImmutable() }, - (rules ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NotificationPreferenceDetails = apply { - if (validated) { - return@apply - } - - status().validate() - channelPreferences().ifPresent { it.forEach { it.validate() } } - rules().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (status.asKnown().getOrNull()?.validity() ?: 0) + - (channelPreferences.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NotificationPreferenceDetails && - status == other.status && - channelPreferences == other.channelPreferences && - rules == other.rules && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(status, channelPreferences, rules, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NotificationPreferenceDetails{status=$status, channelPreferences=$channelPreferences, rules=$rules, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt deleted file mode 100644 index 6f14ed16..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipient.kt +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class PutSubscriptionsRecipient -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val recipientId: JsonField, - private val preferences: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("recipientId") - @ExcludeMissing - recipientId: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - ) : this(recipientId, preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipientId(): String = recipientId.getRequired("recipientId") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [recipientId]. - * - * Unlike [recipientId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipientId") @ExcludeMissing fun _recipientId(): JsonField = recipientId - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PutSubscriptionsRecipient]. - * - * The following fields are required: - * ```java - * .recipientId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PutSubscriptionsRecipient]. */ - class Builder internal constructor() { - - private var recipientId: JsonField? = null - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(putSubscriptionsRecipient: PutSubscriptionsRecipient) = apply { - recipientId = putSubscriptionsRecipient.recipientId - preferences = putSubscriptionsRecipient.preferences - additionalProperties = putSubscriptionsRecipient.additionalProperties.toMutableMap() - } - - fun recipientId(recipientId: String) = recipientId(JsonField.of(recipientId)) - - /** - * Sets [Builder.recipientId] to an arbitrary JSON value. - * - * You should usually call [Builder.recipientId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipientId(recipientId: JsonField) = apply { this.recipientId = recipientId } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PutSubscriptionsRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recipientId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PutSubscriptionsRecipient = - PutSubscriptionsRecipient( - checkRequired("recipientId", recipientId), - preferences, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PutSubscriptionsRecipient = apply { - if (validated) { - return@apply - } - - recipientId() - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (recipientId.asKnown().isPresent) 1 else 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PutSubscriptionsRecipient && - recipientId == other.recipientId && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(recipientId, preferences, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PutSubscriptionsRecipient{recipientId=$recipientId, preferences=$preferences, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt deleted file mode 100644 index 227752b7..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferences.kt +++ /dev/null @@ -1,407 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class RecipientPreferences -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val categories: JsonField, - private val notifications: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("categories") - @ExcludeMissing - categories: JsonField = JsonMissing.of(), - @JsonProperty("notifications") - @ExcludeMissing - notifications: JsonField = JsonMissing.of(), - ) : this(categories, notifications, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun categories(): Optional = categories.getOptional("categories") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun notifications(): Optional = notifications.getOptional("notifications") - - /** - * Returns the raw JSON value of [categories]. - * - * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("categories") - @ExcludeMissing - fun _categories(): JsonField = categories - - /** - * Returns the raw JSON value of [notifications]. - * - * Unlike [notifications], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("notifications") - @ExcludeMissing - fun _notifications(): JsonField = notifications - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RecipientPreferences]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RecipientPreferences]. */ - class Builder internal constructor() { - - private var categories: JsonField = JsonMissing.of() - private var notifications: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(recipientPreferences: RecipientPreferences) = apply { - categories = recipientPreferences.categories - notifications = recipientPreferences.notifications - additionalProperties = recipientPreferences.additionalProperties.toMutableMap() - } - - fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - - /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ - fun categories(categories: Optional) = categories(categories.getOrNull()) - - /** - * Sets [Builder.categories] to an arbitrary JSON value. - * - * You should usually call [Builder.categories] with a well-typed [Categories] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun categories(categories: JsonField) = apply { this.categories = categories } - - fun notifications(notifications: Notifications?) = - notifications(JsonField.ofNullable(notifications)) - - /** Alias for calling [Builder.notifications] with `notifications.orElse(null)`. */ - fun notifications(notifications: Optional) = - notifications(notifications.getOrNull()) - - /** - * Sets [Builder.notifications] to an arbitrary JSON value. - * - * You should usually call [Builder.notifications] with a well-typed [Notifications] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun notifications(notifications: JsonField) = apply { - this.notifications = notifications - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RecipientPreferences]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RecipientPreferences = - RecipientPreferences(categories, notifications, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): RecipientPreferences = apply { - if (validated) { - return@apply - } - - categories().ifPresent { it.validate() } - notifications().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (categories.asKnown().getOrNull()?.validity() ?: 0) + - (notifications.asKnown().getOrNull()?.validity() ?: 0) - - class Categories - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Categories]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Categories]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(categories: Categories) = apply { - additionalProperties = categories.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Categories]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Categories = Categories(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Categories = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Categories && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Categories{additionalProperties=$additionalProperties}" - } - - class Notifications - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Notifications]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Notifications]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(notifications: Notifications) = apply { - additionalProperties = notifications.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Notifications]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Notifications = Notifications(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Notifications = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Notifications && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Notifications{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RecipientPreferences && - categories == other.categories && - notifications == other.notifications && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(categories, notifications, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "RecipientPreferences{categories=$categories, notifications=$notifications, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt deleted file mode 100644 index e53154a4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParams.kt +++ /dev/null @@ -1,473 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Subscribes additional users to the list, without modifying existing subscriptions. If the list - * does not exist, it will be automatically created. - */ -class SubscriptionAddParams -private constructor( - private val listId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipients(): List = body.recipients() - - /** - * Returns the raw JSON value of [recipients]. - * - * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _recipients(): JsonField> = body._recipients() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SubscriptionAddParams]. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionAddParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(subscriptionAddParams: SubscriptionAddParams) = apply { - listId = subscriptionAddParams.listId - body = subscriptionAddParams.body.toBuilder() - additionalHeaders = subscriptionAddParams.additionalHeaders.toBuilder() - additionalQueryParams = subscriptionAddParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [recipients] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun recipients(recipients: List) = apply { - body.recipients(recipients) - } - - /** - * Sets [Builder.recipients] to an arbitrary JSON value. - * - * You should usually call [Builder.recipients] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun recipients(recipients: JsonField>) = apply { - body.recipients(recipients) - } - - /** - * Adds a single [PutSubscriptionsRecipient] to [recipients]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { - body.addRecipient(recipient) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [SubscriptionAddParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionAddParams = - SubscriptionAddParams( - listId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val recipients: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("recipients") - @ExcludeMissing - recipients: JsonField> = JsonMissing.of() - ) : this(recipients, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipients(): List = recipients.getRequired("recipients") - - /** - * Returns the raw JSON value of [recipients]. - * - * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipients") - @ExcludeMissing - fun _recipients(): JsonField> = recipients - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var recipients: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - recipients = body.recipients.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun recipients(recipients: List) = - recipients(JsonField.of(recipients)) - - /** - * Sets [Builder.recipients] to an arbitrary JSON value. - * - * You should usually call [Builder.recipients] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun recipients(recipients: JsonField>) = apply { - this.recipients = recipients.map { it.toMutableList() } - } - - /** - * Adds a single [PutSubscriptionsRecipient] to [recipients]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { - recipients = - (recipients ?: JsonField.of(mutableListOf())).also { - checkKnown("recipients", it).add(recipient) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("recipients", recipients).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - recipients().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (recipients.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - recipients == other.recipients && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(recipients, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{recipients=$recipients, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionAddParams && - listId == other.listId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(listId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "SubscriptionAddParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt deleted file mode 100644 index d0b88e1f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParams.kt +++ /dev/null @@ -1,214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get the list's subscriptions. */ -class SubscriptionListParams -private constructor( - private val listId: String?, - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - /** A unique identifier that allows for fetching the next set of list subscriptions */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): SubscriptionListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [SubscriptionListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionListParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(subscriptionListParams: SubscriptionListParams) = apply { - listId = subscriptionListParams.listId - cursor = subscriptionListParams.cursor - additionalHeaders = subscriptionListParams.additionalHeaders.toBuilder() - additionalQueryParams = subscriptionListParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - /** A unique identifier that allows for fetching the next set of list subscriptions */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [SubscriptionListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): SubscriptionListParams = - SubscriptionListParams( - listId, - cursor, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionListParams && - listId == other.listId && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(listId, cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "SubscriptionListParams{listId=$listId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt deleted file mode 100644 index 3fc3f033..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponse.kt +++ /dev/null @@ -1,467 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class SubscriptionListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SubscriptionListResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionListResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionListResponse: SubscriptionListResponse) = apply { - items = subscriptionListResponse.items.map { it.toMutableList() } - paging = subscriptionListResponse.paging - additionalProperties = subscriptionListResponse.additionalProperties.toMutableMap() - } - - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Item] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Item) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SubscriptionListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionListResponse = - SubscriptionListResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SubscriptionListResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val recipientId: JsonField, - private val created: JsonField, - private val preferences: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("recipientId") - @ExcludeMissing - recipientId: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - ) : this(recipientId, created, preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipientId(): String = recipientId.getRequired("recipientId") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun created(): Optional = created.getOptional("created") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [recipientId]. - * - * Unlike [recipientId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipientId") - @ExcludeMissing - fun _recipientId(): JsonField = recipientId - - /** - * Returns the raw JSON value of [created]. - * - * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Item]. - * - * The following fields are required: - * ```java - * .recipientId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var recipientId: JsonField? = null - private var created: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - recipientId = item.recipientId - created = item.created - preferences = item.preferences - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun recipientId(recipientId: String) = recipientId(JsonField.of(recipientId)) - - /** - * Sets [Builder.recipientId] to an arbitrary JSON value. - * - * You should usually call [Builder.recipientId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun recipientId(recipientId: JsonField) = apply { - this.recipientId = recipientId - } - - fun created(created: String?) = created(JsonField.ofNullable(created)) - - /** Alias for calling [Builder.created] with `created.orElse(null)`. */ - fun created(created: Optional) = created(created.getOrNull()) - - /** - * Sets [Builder.created] to an arbitrary JSON value. - * - * You should usually call [Builder.created] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun created(created: JsonField) = apply { this.created = created } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recipientId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - checkRequired("recipientId", recipientId), - created, - preferences, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - recipientId() - created() - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (recipientId.asKnown().isPresent) 1 else 0) + - (if (created.asKnown().isPresent) 1 else 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - recipientId == other.recipientId && - created == other.created && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(recipientId, created, preferences, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{recipientId=$recipientId, created=$created, preferences=$preferences, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionListResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionListResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt deleted file mode 100644 index 3e5e4186..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParams.kt +++ /dev/null @@ -1,473 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Subscribes the users to the list, overwriting existing subscriptions. If the list does not exist, - * it will be automatically created. - */ -class SubscriptionSubscribeParams -private constructor( - private val listId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): Optional = Optional.ofNullable(listId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipients(): List = body.recipients() - - /** - * Returns the raw JSON value of [recipients]. - * - * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _recipients(): JsonField> = body._recipients() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SubscriptionSubscribeParams]. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionSubscribeParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(subscriptionSubscribeParams: SubscriptionSubscribeParams) = apply { - listId = subscriptionSubscribeParams.listId - body = subscriptionSubscribeParams.body.toBuilder() - additionalHeaders = subscriptionSubscribeParams.additionalHeaders.toBuilder() - additionalQueryParams = subscriptionSubscribeParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String?) = apply { this.listId = listId } - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [recipients] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun recipients(recipients: List) = apply { - body.recipients(recipients) - } - - /** - * Sets [Builder.recipients] to an arbitrary JSON value. - * - * You should usually call [Builder.recipients] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun recipients(recipients: JsonField>) = apply { - body.recipients(recipients) - } - - /** - * Adds a single [PutSubscriptionsRecipient] to [recipients]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { - body.addRecipient(recipient) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [SubscriptionSubscribeParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionSubscribeParams = - SubscriptionSubscribeParams( - listId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val recipients: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("recipients") - @ExcludeMissing - recipients: JsonField> = JsonMissing.of() - ) : this(recipients, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipients(): List = recipients.getRequired("recipients") - - /** - * Returns the raw JSON value of [recipients]. - * - * Unlike [recipients], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipients") - @ExcludeMissing - fun _recipients(): JsonField> = recipients - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var recipients: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - recipients = body.recipients.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun recipients(recipients: List) = - recipients(JsonField.of(recipients)) - - /** - * Sets [Builder.recipients] to an arbitrary JSON value. - * - * You should usually call [Builder.recipients] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun recipients(recipients: JsonField>) = apply { - this.recipients = recipients.map { it.toMutableList() } - } - - /** - * Adds a single [PutSubscriptionsRecipient] to [recipients]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addRecipient(recipient: PutSubscriptionsRecipient) = apply { - recipients = - (recipients ?: JsonField.of(mutableListOf())).also { - checkKnown("recipients", it).add(recipient) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .recipients() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("recipients", recipients).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - recipients().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (recipients.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - recipients == other.recipients && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(recipients, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{recipients=$recipients, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionSubscribeParams && - listId == other.listId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(listId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "SubscriptionSubscribeParams{listId=$listId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt deleted file mode 100644 index c646c26c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParams.kt +++ /dev/null @@ -1,452 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Subscribe a user to an existing list (note: if the List does not exist, it will be automatically - * created). - */ -class SubscriptionSubscribeUserParams -private constructor( - private val listId: String, - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun listId(): String = listId - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = body.preferences() - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _preferences(): JsonField = body._preferences() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SubscriptionSubscribeUserParams]. - * - * The following fields are required: - * ```java - * .listId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionSubscribeUserParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(subscriptionSubscribeUserParams: SubscriptionSubscribeUserParams) = - apply { - listId = subscriptionSubscribeUserParams.listId - userId = subscriptionSubscribeUserParams.userId - body = subscriptionSubscribeUserParams.body.toBuilder() - additionalHeaders = subscriptionSubscribeUserParams.additionalHeaders.toBuilder() - additionalQueryParams = - subscriptionSubscribeUserParams.additionalQueryParams.toBuilder() - } - - fun listId(listId: String) = apply { this.listId = listId } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [preferences] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun preferences(preferences: RecipientPreferences?) = apply { - body.preferences(preferences) - } - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - body.preferences(preferences) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [SubscriptionSubscribeUserParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .listId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionSubscribeUserParams = - SubscriptionSubscribeUserParams( - checkRequired("listId", listId), - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId - 1 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val preferences: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of() - ) : this(preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - preferences = body.preferences - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(preferences, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (preferences.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(preferences, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{preferences=$preferences, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionSubscribeUserParams && - listId == other.listId && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(listId, userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "SubscriptionSubscribeUserParams{listId=$listId, userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt deleted file mode 100644 index 32972d56..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParams.kt +++ /dev/null @@ -1,262 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete a subscription to a list by list ID and user ID. */ -class SubscriptionUnsubscribeUserParams -private constructor( - private val listId: String, - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun listId(): String = listId - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SubscriptionUnsubscribeUserParams]. - * - * The following fields are required: - * ```java - * .listId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionUnsubscribeUserParams]. */ - class Builder internal constructor() { - - private var listId: String? = null - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionUnsubscribeUserParams: SubscriptionUnsubscribeUserParams) = - apply { - listId = subscriptionUnsubscribeUserParams.listId - userId = subscriptionUnsubscribeUserParams.userId - additionalHeaders = subscriptionUnsubscribeUserParams.additionalHeaders.toBuilder() - additionalQueryParams = - subscriptionUnsubscribeUserParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - subscriptionUnsubscribeUserParams.additionalBodyProperties.toMutableMap() - } - - fun listId(listId: String) = apply { this.listId = listId } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [SubscriptionUnsubscribeUserParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .listId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionUnsubscribeUserParams = - SubscriptionUnsubscribeUserParams( - checkRequired("listId", listId), - userId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> listId - 1 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionUnsubscribeUserParams && - listId == other.listId && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash( - listId, - userId, - additionalHeaders, - additionalQueryParams, - additionalBodyProperties, - ) - - override fun toString() = - "SubscriptionUnsubscribeUserParams{listId=$listId, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt deleted file mode 100644 index 20b8d109..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageCancelParams.kt +++ /dev/null @@ -1,234 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Cancel a message that is currently in the process of being delivered. A well-formatted API call - * to the cancel message API will return either `200` status code for a successful cancellation or - * `409` status code for an unsuccessful cancellation. Both cases will include the actual message - * record in the response body (see details below). - */ -class MessageCancelParams -private constructor( - private val messageId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun messageId(): Optional = Optional.ofNullable(messageId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): MessageCancelParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [MessageCancelParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageCancelParams]. */ - class Builder internal constructor() { - - private var messageId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(messageCancelParams: MessageCancelParams) = apply { - messageId = messageCancelParams.messageId - additionalHeaders = messageCancelParams.additionalHeaders.toBuilder() - additionalQueryParams = messageCancelParams.additionalQueryParams.toBuilder() - additionalBodyProperties = messageCancelParams.additionalBodyProperties.toMutableMap() - } - - fun messageId(messageId: String?) = apply { this.messageId = messageId } - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [MessageCancelParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MessageCancelParams = - MessageCancelParams( - messageId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> messageId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageCancelParams && - messageId == other.messageId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(messageId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "MessageCancelParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt deleted file mode 100644 index d05ee1e6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentParams.kt +++ /dev/null @@ -1,193 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get message content */ -class MessageContentParams -private constructor( - private val messageId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun messageId(): Optional = Optional.ofNullable(messageId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): MessageContentParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [MessageContentParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageContentParams]. */ - class Builder internal constructor() { - - private var messageId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(messageContentParams: MessageContentParams) = apply { - messageId = messageContentParams.messageId - additionalHeaders = messageContentParams.additionalHeaders.toBuilder() - additionalQueryParams = messageContentParams.additionalQueryParams.toBuilder() - } - - fun messageId(messageId: String?) = apply { this.messageId = messageId } - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [MessageContentParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MessageContentParams = - MessageContentParams( - messageId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> messageId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageContentParams && - messageId == other.messageId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(messageId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "MessageContentParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt deleted file mode 100644 index d27bc382..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageContentResponse.kt +++ /dev/null @@ -1,1015 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class MessageContentResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of() - ) : this(results, mutableMapOf()) - - /** - * An array of render output of a previously sent message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MessageContentResponse]. - * - * The following fields are required: - * ```java - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageContentResponse]. */ - class Builder internal constructor() { - - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(messageContentResponse: MessageContentResponse) = apply { - results = messageContentResponse.results.map { it.toMutableList() } - additionalProperties = messageContentResponse.additionalProperties.toMutableMap() - } - - /** An array of render output of a previously sent message. */ - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MessageContentResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MessageContentResponse = - MessageContentResponse( - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MessageContentResponse = apply { - if (validated) { - return@apply - } - - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Result - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channel: JsonField, - private val channelId: JsonField, - private val content: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channel_id") - @ExcludeMissing - channelId: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - ) : this(channel, channelId, content, mutableMapOf()) - - /** - * The channel used for rendering the message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * The ID of channel used for rendering the message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channelId(): String = channelId.getRequired("channel_id") - - /** - * Content details of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun content(): Content = content.getRequired("content") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channelId]. - * - * Unlike [channelId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel_id") @ExcludeMissing fun _channelId(): JsonField = channelId - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Result]. - * - * The following fields are required: - * ```java - * .channel() - * .channelId() - * .content() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var channelId: JsonField? = null - private var content: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - channel = result.channel - channelId = result.channelId - content = result.content - additionalProperties = result.additionalProperties.toMutableMap() - } - - /** The channel used for rendering the message. */ - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - /** The ID of channel used for rendering the message. */ - fun channelId(channelId: String) = channelId(JsonField.of(channelId)) - - /** - * Sets [Builder.channelId] to an arbitrary JSON value. - * - * You should usually call [Builder.channelId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channelId(channelId: JsonField) = apply { this.channelId = channelId } - - /** Content details of the rendered message. */ - fun content(content: Content) = content(JsonField.of(content)) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [Content] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * .channelId() - * .content() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Result = - Result( - checkRequired("channel", channel), - checkRequired("channelId", channelId), - checkRequired("content", content), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Result = apply { - if (validated) { - return@apply - } - - channel() - channelId() - content().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (if (channelId.asKnown().isPresent) 1 else 0) + - (content.asKnown().getOrNull()?.validity() ?: 0) - - /** Content details of the rendered message. */ - class Content - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val blocks: JsonField>, - private val body: JsonField, - private val html: JsonField, - private val subject: JsonField, - private val text: JsonField, - private val title: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("blocks") - @ExcludeMissing - blocks: JsonField> = JsonMissing.of(), - @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), - @JsonProperty("html") @ExcludeMissing html: JsonField = JsonMissing.of(), - @JsonProperty("subject") - @ExcludeMissing - subject: JsonField = JsonMissing.of(), - @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - ) : this(blocks, body, html, subject, text, title, mutableMapOf()) - - /** - * The blocks of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun blocks(): List = blocks.getRequired("blocks") - - /** - * The body of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun body(): String = body.getRequired("body") - - /** - * The html content of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun html(): String = html.getRequired("html") - - /** - * The subject of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun subject(): String = subject.getRequired("subject") - - /** - * The text of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun text(): String = text.getRequired("text") - - /** - * The title of the rendered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun title(): String = title.getRequired("title") - - /** - * Returns the raw JSON value of [blocks]. - * - * Unlike [blocks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("blocks") @ExcludeMissing fun _blocks(): JsonField> = blocks - - /** - * Returns the raw JSON value of [body]. - * - * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - - /** - * Returns the raw JSON value of [html]. - * - * Unlike [html], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("html") @ExcludeMissing fun _html(): JsonField = html - - /** - * Returns the raw JSON value of [subject]. - * - * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("subject") @ExcludeMissing fun _subject(): JsonField = subject - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Content]. - * - * The following fields are required: - * ```java - * .blocks() - * .body() - * .html() - * .subject() - * .text() - * .title() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Content]. */ - class Builder internal constructor() { - - private var blocks: JsonField>? = null - private var body: JsonField? = null - private var html: JsonField? = null - private var subject: JsonField? = null - private var text: JsonField? = null - private var title: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(content: Content) = apply { - blocks = content.blocks.map { it.toMutableList() } - body = content.body - html = content.html - subject = content.subject - text = content.text - title = content.title - additionalProperties = content.additionalProperties.toMutableMap() - } - - /** The blocks of the rendered message. */ - fun blocks(blocks: List) = blocks(JsonField.of(blocks)) - - /** - * Sets [Builder.blocks] to an arbitrary JSON value. - * - * You should usually call [Builder.blocks] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun blocks(blocks: JsonField>) = apply { - this.blocks = blocks.map { it.toMutableList() } - } - - /** - * Adds a single [Block] to [blocks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBlock(block: Block) = apply { - blocks = - (blocks ?: JsonField.of(mutableListOf())).also { - checkKnown("blocks", it).add(block) - } - } - - /** The body of the rendered message. */ - fun body(body: String) = body(JsonField.of(body)) - - /** - * Sets [Builder.body] to an arbitrary JSON value. - * - * You should usually call [Builder.body] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun body(body: JsonField) = apply { this.body = body } - - /** The html content of the rendered message. */ - fun html(html: String) = html(JsonField.of(html)) - - /** - * Sets [Builder.html] to an arbitrary JSON value. - * - * You should usually call [Builder.html] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun html(html: JsonField) = apply { this.html = html } - - /** The subject of the rendered message. */ - fun subject(subject: String) = subject(JsonField.of(subject)) - - /** - * Sets [Builder.subject] to an arbitrary JSON value. - * - * You should usually call [Builder.subject] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun subject(subject: JsonField) = apply { this.subject = subject } - - /** The text of the rendered message. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** The title of the rendered message. */ - fun title(title: String) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Content]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .blocks() - * .body() - * .html() - * .subject() - * .text() - * .title() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Content = - Content( - checkRequired("blocks", blocks).map { it.toImmutable() }, - checkRequired("body", body), - checkRequired("html", html), - checkRequired("subject", subject), - checkRequired("text", text), - checkRequired("title", title), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Content = apply { - if (validated) { - return@apply - } - - blocks().forEach { it.validate() } - body() - html() - subject() - text() - title() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (blocks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (body.asKnown().isPresent) 1 else 0) + - (if (html.asKnown().isPresent) 1 else 0) + - (if (subject.asKnown().isPresent) 1 else 0) + - (if (text.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) - - class Block - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val text: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("text") - @ExcludeMissing - text: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(text, type, mutableMapOf()) - - /** - * The block text of the rendered message block. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun text(): String = text.getRequired("text") - - /** - * The block type of the rendered message block. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun type(): String = type.getRequired("type") - - /** - * Returns the raw JSON value of [text]. - * - * Unlike [text], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Block]. - * - * The following fields are required: - * ```java - * .text() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Block]. */ - class Builder internal constructor() { - - private var text: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(block: Block) = apply { - text = block.text - type = block.type - additionalProperties = block.additionalProperties.toMutableMap() - } - - /** The block text of the rendered message block. */ - fun text(text: String) = text(JsonField.of(text)) - - /** - * Sets [Builder.text] to an arbitrary JSON value. - * - * You should usually call [Builder.text] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun text(text: JsonField) = apply { this.text = text } - - /** The block type of the rendered message block. */ - fun type(type: String) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Block]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .text() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Block = - Block( - checkRequired("text", text), - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Block = apply { - if (validated) { - return@apply - } - - text() - type() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (text.asKnown().isPresent) 1 else 0) + - (if (type.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Block && - text == other.text && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(text, type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Block{text=$text, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - blocks == other.blocks && - body == other.body && - html == other.html && - subject == other.subject && - text == other.text && - title == other.title && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(blocks, body, html, subject, text, title, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Content{blocks=$blocks, body=$body, html=$html, subject=$subject, text=$text, title=$title, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && - channel == other.channel && - channelId == other.channelId && - content == other.content && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channel, channelId, content, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Result{channel=$channel, channelId=$channelId, content=$content, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageContentResponse && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MessageContentResponse{results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt deleted file mode 100644 index fcdf2c21..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageDetails.kt +++ /dev/null @@ -1,1009 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class MessageDetails -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val clicked: JsonField, - private val delivered: JsonField, - private val enqueued: JsonField, - private val event: JsonField, - private val notification: JsonField, - private val opened: JsonField, - private val recipient: JsonField, - private val sent: JsonField, - private val status: JsonField, - private val error: JsonField, - private val reason: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("clicked") @ExcludeMissing clicked: JsonField = JsonMissing.of(), - @JsonProperty("delivered") @ExcludeMissing delivered: JsonField = JsonMissing.of(), - @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), - @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("notification") - @ExcludeMissing - notification: JsonField = JsonMissing.of(), - @JsonProperty("opened") @ExcludeMissing opened: JsonField = JsonMissing.of(), - @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), - @JsonProperty("sent") @ExcludeMissing sent: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), - ) : this( - id, - clicked, - delivered, - enqueued, - event, - notification, - opened, - recipient, - sent, - status, - error, - reason, - mutableMapOf(), - ) - - /** - * A unique identifier associated with the message you wish to retrieve (results from a send). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored - * as a millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun clicked(): Long = clicked.getRequired("clicked") - - /** - * A UTC timestamp at which the Integration provider delivered the message. Stored as a - * millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun delivered(): Long = delivered.getRequired("delivered") - - /** - * A UTC timestamp at which Courier received the message request. Stored as a millisecond - * representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun enqueued(): Long = enqueued.getRequired("enqueued") - - /** - * A unique identifier associated with the event of the delivered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun event(): String = event.getRequired("event") - - /** - * A unique identifier associated with the notification of the delivered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun notification(): String = notification.getRequired("notification") - - /** - * A UTC timestamp at which the recipient opened a message for the first time. Stored as a - * millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun opened(): Long = opened.getRequired("opened") - - /** - * A unique identifier associated with the recipient of the delivered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipient(): String = recipient.getRequired("recipient") - - /** - * A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a - * millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun sent(): Long = sent.getRequired("sent") - - /** - * The current status of the message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * A message describing the error that occurred. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun error(): Optional = error.getOptional("error") - - /** - * The reason for the current status of the message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [clicked]. - * - * Unlike [clicked], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("clicked") @ExcludeMissing fun _clicked(): JsonField = clicked - - /** - * Returns the raw JSON value of [delivered]. - * - * Unlike [delivered], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delivered") @ExcludeMissing fun _delivered(): JsonField = delivered - - /** - * Returns the raw JSON value of [enqueued]. - * - * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - - /** - * Returns the raw JSON value of [notification]. - * - * Unlike [notification], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("notification") - @ExcludeMissing - fun _notification(): JsonField = notification - - /** - * Returns the raw JSON value of [opened]. - * - * Unlike [opened], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("opened") @ExcludeMissing fun _opened(): JsonField = opened - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [sent]. - * - * Unlike [sent], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sent") @ExcludeMissing fun _sent(): JsonField = sent - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [error]. - * - * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MessageDetails]. - * - * The following fields are required: - * ```java - * .id() - * .clicked() - * .delivered() - * .enqueued() - * .event() - * .notification() - * .opened() - * .recipient() - * .sent() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageDetails]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var clicked: JsonField? = null - private var delivered: JsonField? = null - private var enqueued: JsonField? = null - private var event: JsonField? = null - private var notification: JsonField? = null - private var opened: JsonField? = null - private var recipient: JsonField? = null - private var sent: JsonField? = null - private var status: JsonField? = null - private var error: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(messageDetails: MessageDetails) = apply { - id = messageDetails.id - clicked = messageDetails.clicked - delivered = messageDetails.delivered - enqueued = messageDetails.enqueued - event = messageDetails.event - notification = messageDetails.notification - opened = messageDetails.opened - recipient = messageDetails.recipient - sent = messageDetails.sent - status = messageDetails.status - error = messageDetails.error - reason = messageDetails.reason - additionalProperties = messageDetails.additionalProperties.toMutableMap() - } - - /** - * A unique identifier associated with the message you wish to retrieve (results from a - * send). - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * A UTC timestamp at which the recipient clicked on a tracked link for the first time. - * Stored as a millisecond representation of the Unix epoch. - */ - fun clicked(clicked: Long) = clicked(JsonField.of(clicked)) - - /** - * Sets [Builder.clicked] to an arbitrary JSON value. - * - * You should usually call [Builder.clicked] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun clicked(clicked: JsonField) = apply { this.clicked = clicked } - - /** - * A UTC timestamp at which the Integration provider delivered the message. Stored as a - * millisecond representation of the Unix epoch. - */ - fun delivered(delivered: Long) = delivered(JsonField.of(delivered)) - - /** - * Sets [Builder.delivered] to an arbitrary JSON value. - * - * You should usually call [Builder.delivered] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun delivered(delivered: JsonField) = apply { this.delivered = delivered } - - /** - * A UTC timestamp at which Courier received the message request. Stored as a millisecond - * representation of the Unix epoch. - */ - fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) - - /** - * Sets [Builder.enqueued] to an arbitrary JSON value. - * - * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } - - /** A unique identifier associated with the event of the delivered message. */ - fun event(event: String) = event(JsonField.of(event)) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - /** A unique identifier associated with the notification of the delivered message. */ - fun notification(notification: String) = notification(JsonField.of(notification)) - - /** - * Sets [Builder.notification] to an arbitrary JSON value. - * - * You should usually call [Builder.notification] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun notification(notification: JsonField) = apply { - this.notification = notification - } - - /** - * A UTC timestamp at which the recipient opened a message for the first time. Stored as a - * millisecond representation of the Unix epoch. - */ - fun opened(opened: Long) = opened(JsonField.of(opened)) - - /** - * Sets [Builder.opened] to an arbitrary JSON value. - * - * You should usually call [Builder.opened] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun opened(opened: JsonField) = apply { this.opened = opened } - - /** A unique identifier associated with the recipient of the delivered message. */ - fun recipient(recipient: String) = recipient(JsonField.of(recipient)) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - /** - * A UTC timestamp at which Courier passed the message to the Integration provider. Stored - * as a millisecond representation of the Unix epoch. - */ - fun sent(sent: Long) = sent(JsonField.of(sent)) - - /** - * Sets [Builder.sent] to an arbitrary JSON value. - * - * You should usually call [Builder.sent] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun sent(sent: JsonField) = apply { this.sent = sent } - - /** The current status of the message. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** A message describing the error that occurred. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) - - /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) - - /** - * Sets [Builder.error] to an arbitrary JSON value. - * - * You should usually call [Builder.error] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun error(error: JsonField) = apply { this.error = error } - - /** The reason for the current status of the message. */ - fun reason(reason: Reason?) = reason(JsonField.ofNullable(reason)) - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [Reason] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MessageDetails]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .clicked() - * .delivered() - * .enqueued() - * .event() - * .notification() - * .opened() - * .recipient() - * .sent() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MessageDetails = - MessageDetails( - checkRequired("id", id), - checkRequired("clicked", clicked), - checkRequired("delivered", delivered), - checkRequired("enqueued", enqueued), - checkRequired("event", event), - checkRequired("notification", notification), - checkRequired("opened", opened), - checkRequired("recipient", recipient), - checkRequired("sent", sent), - checkRequired("status", status), - error, - reason, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MessageDetails = apply { - if (validated) { - return@apply - } - - id() - clicked() - delivered() - enqueued() - event() - notification() - opened() - recipient() - sent() - status().validate() - error() - reason().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (clicked.asKnown().isPresent) 1 else 0) + - (if (delivered.asKnown().isPresent) 1 else 0) + - (if (enqueued.asKnown().isPresent) 1 else 0) + - (if (event.asKnown().isPresent) 1 else 0) + - (if (notification.asKnown().isPresent) 1 else 0) + - (if (opened.asKnown().isPresent) 1 else 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (if (sent.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (error.asKnown().isPresent) 1 else 0) + - (reason.asKnown().getOrNull()?.validity() ?: 0) - - /** The current status of the message. */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELED = of("CANCELED") - - @JvmField val CLICKED = of("CLICKED") - - @JvmField val DELAYED = of("DELAYED") - - @JvmField val DELIVERED = of("DELIVERED") - - @JvmField val DIGESTED = of("DIGESTED") - - @JvmField val ENQUEUED = of("ENQUEUED") - - @JvmField val FILTERED = of("FILTERED") - - @JvmField val OPENED = of("OPENED") - - @JvmField val ROUTED = of("ROUTED") - - @JvmField val SENT = of("SENT") - - @JvmField val SIMULATED = of("SIMULATED") - - @JvmField val THROTTLED = of("THROTTLED") - - @JvmField val UNDELIVERABLE = of("UNDELIVERABLE") - - @JvmField val UNMAPPED = of("UNMAPPED") - - @JvmField val UNROUTABLE = of("UNROUTABLE") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELED, - CLICKED, - DELAYED, - DELIVERED, - DIGESTED, - ENQUEUED, - FILTERED, - OPENED, - ROUTED, - SENT, - SIMULATED, - THROTTLED, - UNDELIVERABLE, - UNMAPPED, - UNROUTABLE, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELED, - CLICKED, - DELAYED, - DELIVERED, - DIGESTED, - ENQUEUED, - FILTERED, - OPENED, - ROUTED, - SENT, - SIMULATED, - THROTTLED, - UNDELIVERABLE, - UNMAPPED, - UNROUTABLE, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELED -> Value.CANCELED - CLICKED -> Value.CLICKED - DELAYED -> Value.DELAYED - DELIVERED -> Value.DELIVERED - DIGESTED -> Value.DIGESTED - ENQUEUED -> Value.ENQUEUED - FILTERED -> Value.FILTERED - OPENED -> Value.OPENED - ROUTED -> Value.ROUTED - SENT -> Value.SENT - SIMULATED -> Value.SIMULATED - THROTTLED -> Value.THROTTLED - UNDELIVERABLE -> Value.UNDELIVERABLE - UNMAPPED -> Value.UNMAPPED - UNROUTABLE -> Value.UNROUTABLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CANCELED -> Known.CANCELED - CLICKED -> Known.CLICKED - DELAYED -> Known.DELAYED - DELIVERED -> Known.DELIVERED - DIGESTED -> Known.DIGESTED - ENQUEUED -> Known.ENQUEUED - FILTERED -> Known.FILTERED - OPENED -> Known.OPENED - ROUTED -> Known.ROUTED - SENT -> Known.SENT - SIMULATED -> Known.SIMULATED - THROTTLED -> Known.THROTTLED - UNDELIVERABLE -> Known.UNDELIVERABLE - UNMAPPED -> Known.UNMAPPED - UNROUTABLE -> Known.UNROUTABLE - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The reason for the current status of the message. */ - class Reason @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val BOUNCED = of("BOUNCED") - - @JvmField val FAILED = of("FAILED") - - @JvmField val FILTERED = of("FILTERED") - - @JvmField val NO_CHANNELS = of("NO_CHANNELS") - - @JvmField val NO_PROVIDERS = of("NO_PROVIDERS") - - @JvmField val OPT_IN_REQUIRED = of("OPT_IN_REQUIRED") - - @JvmField val PROVIDER_ERROR = of("PROVIDER_ERROR") - - @JvmField val UNPUBLISHED = of("UNPUBLISHED") - - @JvmField val UNSUBSCRIBED = of("UNSUBSCRIBED") - - @JvmStatic fun of(value: String) = Reason(JsonField.of(value)) - } - - /** An enum containing [Reason]'s known values. */ - enum class Known { - BOUNCED, - FAILED, - FILTERED, - NO_CHANNELS, - NO_PROVIDERS, - OPT_IN_REQUIRED, - PROVIDER_ERROR, - UNPUBLISHED, - UNSUBSCRIBED, - } - - /** - * An enum containing [Reason]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Reason] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - BOUNCED, - FAILED, - FILTERED, - NO_CHANNELS, - NO_PROVIDERS, - OPT_IN_REQUIRED, - PROVIDER_ERROR, - UNPUBLISHED, - UNSUBSCRIBED, - /** An enum member indicating that [Reason] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - BOUNCED -> Value.BOUNCED - FAILED -> Value.FAILED - FILTERED -> Value.FILTERED - NO_CHANNELS -> Value.NO_CHANNELS - NO_PROVIDERS -> Value.NO_PROVIDERS - OPT_IN_REQUIRED -> Value.OPT_IN_REQUIRED - PROVIDER_ERROR -> Value.PROVIDER_ERROR - UNPUBLISHED -> Value.UNPUBLISHED - UNSUBSCRIBED -> Value.UNSUBSCRIBED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - BOUNCED -> Known.BOUNCED - FAILED -> Known.FAILED - FILTERED -> Known.FILTERED - NO_CHANNELS -> Known.NO_CHANNELS - NO_PROVIDERS -> Known.NO_PROVIDERS - OPT_IN_REQUIRED -> Known.OPT_IN_REQUIRED - PROVIDER_ERROR -> Known.PROVIDER_ERROR - UNPUBLISHED -> Known.UNPUBLISHED - UNSUBSCRIBED -> Known.UNSUBSCRIBED - else -> throw CourierInvalidDataException("Unknown Reason: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Reason = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Reason && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageDetails && - id == other.id && - clicked == other.clicked && - delivered == other.delivered && - enqueued == other.enqueued && - event == other.event && - notification == other.notification && - opened == other.opened && - recipient == other.recipient && - sent == other.sent && - status == other.status && - error == other.error && - reason == other.reason && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - clicked, - delivered, - enqueued, - event, - notification, - opened, - recipient, - sent, - status, - error, - reason, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MessageDetails{id=$id, clicked=$clicked, delivered=$delivered, enqueued=$enqueued, event=$event, notification=$notification, opened=$opened, recipient=$recipient, sent=$sent, status=$status, error=$error, reason=$reason, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt deleted file mode 100644 index eb6a365d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryParams.kt +++ /dev/null @@ -1,214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch the array of events of a message you've previously sent. */ -class MessageHistoryParams -private constructor( - private val messageId: String?, - private val type: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun messageId(): Optional = Optional.ofNullable(messageId) - - /** A supported Message History type that will filter the events returned. */ - fun type(): Optional = Optional.ofNullable(type) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): MessageHistoryParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [MessageHistoryParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageHistoryParams]. */ - class Builder internal constructor() { - - private var messageId: String? = null - private var type: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(messageHistoryParams: MessageHistoryParams) = apply { - messageId = messageHistoryParams.messageId - type = messageHistoryParams.type - additionalHeaders = messageHistoryParams.additionalHeaders.toBuilder() - additionalQueryParams = messageHistoryParams.additionalQueryParams.toBuilder() - } - - fun messageId(messageId: String?) = apply { this.messageId = messageId } - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - /** A supported Message History type that will filter the events returned. */ - fun type(type: String?) = apply { this.type = type } - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [MessageHistoryParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MessageHistoryParams = - MessageHistoryParams( - messageId, - type, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> messageId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - type?.let { put("type", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageHistoryParams && - messageId == other.messageId && - type == other.type && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(messageId, type, additionalHeaders, additionalQueryParams) - - override fun toString() = - "MessageHistoryParams{messageId=$messageId, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt deleted file mode 100644 index cf2ba77a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageHistoryResponse.kt +++ /dev/null @@ -1,289 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class MessageHistoryResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of() - ) : this(results, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MessageHistoryResponse]. - * - * The following fields are required: - * ```java - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageHistoryResponse]. */ - class Builder internal constructor() { - - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(messageHistoryResponse: MessageHistoryResponse) = apply { - results = messageHistoryResponse.results.map { it.toMutableList() } - additionalProperties = messageHistoryResponse.additionalProperties.toMutableMap() - } - - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MessageHistoryResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MessageHistoryResponse = - MessageHistoryResponse( - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MessageHistoryResponse = apply { - if (validated) { - return@apply - } - - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Result - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Result]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - additionalProperties = result.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Result = Result(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Result = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Result{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageHistoryResponse && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MessageHistoryResponse{results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt deleted file mode 100644 index 92a1fa81..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListParams.kt +++ /dev/null @@ -1,475 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch the statuses of messages you've previously sent. */ -class MessageListParams -private constructor( - private val archived: Boolean?, - private val cursor: String?, - private val enqueuedAfter: String?, - private val event: String?, - private val list: String?, - private val messageId: String?, - private val notification: String?, - private val provider: List?, - private val recipient: String?, - private val status: List?, - private val tag: List?, - private val tags: String?, - private val tenantId: String?, - private val traceId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * A boolean value that indicates whether archived messages should be included in the response. - */ - fun archived(): Optional = Optional.ofNullable(archived) - - /** A unique identifier that allows for fetching the next set of messages. */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** The enqueued datetime of a message to filter out messages received before. */ - fun enqueuedAfter(): Optional = Optional.ofNullable(enqueuedAfter) - - /** A unique identifier representing the event that was used to send the event. */ - fun event(): Optional = Optional.ofNullable(event) - - /** A unique identifier representing the list the message was sent to. */ - fun list(): Optional = Optional.ofNullable(list) - - /** A unique identifier representing the message_id returned from either /send or /send/list. */ - fun messageId(): Optional = Optional.ofNullable(messageId) - - /** A unique identifier representing the notification that was used to send the event. */ - fun notification(): Optional = Optional.ofNullable(notification) - - /** - * The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, - * slack, msteams, etc. Allows multiple values to be set in query parameters. - */ - fun provider(): Optional> = Optional.ofNullable(provider) - - /** A unique identifier representing the recipient associated with the requested profile. */ - fun recipient(): Optional = Optional.ofNullable(recipient) - - /** - * An indicator of the current status of the message. Allows multiple values to be set in query - * parameters. - */ - fun status(): Optional> = Optional.ofNullable(status) - - /** - * A tag placed in the metadata.tags during a notification send. Allows multiple values to be - * set in query parameters. - */ - fun tag(): Optional> = Optional.ofNullable(tag) - - /** - * A comma delimited list of 'tags'. Messages will be returned if they match any of the tags - * passed in. - */ - fun tags(): Optional = Optional.ofNullable(tags) - - /** Messages sent with the context of a Tenant */ - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** The unique identifier used to trace the requests */ - fun traceId(): Optional = Optional.ofNullable(traceId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): MessageListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [MessageListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageListParams]. */ - class Builder internal constructor() { - - private var archived: Boolean? = null - private var cursor: String? = null - private var enqueuedAfter: String? = null - private var event: String? = null - private var list: String? = null - private var messageId: String? = null - private var notification: String? = null - private var provider: MutableList? = null - private var recipient: String? = null - private var status: MutableList? = null - private var tag: MutableList? = null - private var tags: String? = null - private var tenantId: String? = null - private var traceId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(messageListParams: MessageListParams) = apply { - archived = messageListParams.archived - cursor = messageListParams.cursor - enqueuedAfter = messageListParams.enqueuedAfter - event = messageListParams.event - list = messageListParams.list - messageId = messageListParams.messageId - notification = messageListParams.notification - provider = messageListParams.provider?.toMutableList() - recipient = messageListParams.recipient - status = messageListParams.status?.toMutableList() - tag = messageListParams.tag?.toMutableList() - tags = messageListParams.tags - tenantId = messageListParams.tenantId - traceId = messageListParams.traceId - additionalHeaders = messageListParams.additionalHeaders.toBuilder() - additionalQueryParams = messageListParams.additionalQueryParams.toBuilder() - } - - /** - * A boolean value that indicates whether archived messages should be included in the - * response. - */ - fun archived(archived: Boolean?) = apply { this.archived = archived } - - /** - * Alias for [Builder.archived]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun archived(archived: Boolean) = archived(archived as Boolean?) - - /** Alias for calling [Builder.archived] with `archived.orElse(null)`. */ - fun archived(archived: Optional) = archived(archived.getOrNull()) - - /** A unique identifier that allows for fetching the next set of messages. */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** The enqueued datetime of a message to filter out messages received before. */ - fun enqueuedAfter(enqueuedAfter: String?) = apply { this.enqueuedAfter = enqueuedAfter } - - /** Alias for calling [Builder.enqueuedAfter] with `enqueuedAfter.orElse(null)`. */ - fun enqueuedAfter(enqueuedAfter: Optional) = - enqueuedAfter(enqueuedAfter.getOrNull()) - - /** A unique identifier representing the event that was used to send the event. */ - fun event(event: String?) = apply { this.event = event } - - /** Alias for calling [Builder.event] with `event.orElse(null)`. */ - fun event(event: Optional) = event(event.getOrNull()) - - /** A unique identifier representing the list the message was sent to. */ - fun list(list: String?) = apply { this.list = list } - - /** Alias for calling [Builder.list] with `list.orElse(null)`. */ - fun list(list: Optional) = list(list.getOrNull()) - - /** - * A unique identifier representing the message_id returned from either /send or /send/list. - */ - fun messageId(messageId: String?) = apply { this.messageId = messageId } - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - /** A unique identifier representing the notification that was used to send the event. */ - fun notification(notification: String?) = apply { this.notification = notification } - - /** Alias for calling [Builder.notification] with `notification.orElse(null)`. */ - fun notification(notification: Optional) = notification(notification.getOrNull()) - - /** - * The key assocated to the provider you want to filter on. E.g., sendgrid, inbox, twilio, - * slack, msteams, etc. Allows multiple values to be set in query parameters. - */ - fun provider(provider: List?) = apply { this.provider = provider?.toMutableList() } - - /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ - fun provider(provider: Optional>) = provider(provider.getOrNull()) - - /** - * Adds a single [String] to [Builder.provider]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProvider(provider: String) = apply { - this.provider = (this.provider ?: mutableListOf()).apply { add(provider) } - } - - /** A unique identifier representing the recipient associated with the requested profile. */ - fun recipient(recipient: String?) = apply { this.recipient = recipient } - - /** Alias for calling [Builder.recipient] with `recipient.orElse(null)`. */ - fun recipient(recipient: Optional) = recipient(recipient.getOrNull()) - - /** - * An indicator of the current status of the message. Allows multiple values to be set in - * query parameters. - */ - fun status(status: List?) = apply { this.status = status?.toMutableList() } - - /** Alias for calling [Builder.status] with `status.orElse(null)`. */ - fun status(status: Optional>) = status(status.getOrNull()) - - /** - * Adds a single [String] to [Builder.status]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addStatus(status: String) = apply { - this.status = (this.status ?: mutableListOf()).apply { add(status) } - } - - /** - * A tag placed in the metadata.tags during a notification send. Allows multiple values to - * be set in query parameters. - */ - fun tag(tag: List?) = apply { this.tag = tag?.toMutableList() } - - /** Alias for calling [Builder.tag] with `tag.orElse(null)`. */ - fun tag(tag: Optional>) = tag(tag.getOrNull()) - - /** - * Adds a single [String] to [Builder.tag]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - this.tag = (this.tag ?: mutableListOf()).apply { add(tag) } - } - - /** - * A comma delimited list of 'tags'. Messages will be returned if they match any of the tags - * passed in. - */ - fun tags(tags: String?) = apply { this.tags = tags } - - /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ - fun tags(tags: Optional) = tags(tags.getOrNull()) - - /** Messages sent with the context of a Tenant */ - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** The unique identifier used to trace the requests */ - fun traceId(traceId: String?) = apply { this.traceId = traceId } - - /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ - fun traceId(traceId: Optional) = traceId(traceId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [MessageListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MessageListParams = - MessageListParams( - archived, - cursor, - enqueuedAfter, - event, - list, - messageId, - notification, - provider?.toImmutable(), - recipient, - status?.toImmutable(), - tag?.toImmutable(), - tags, - tenantId, - traceId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - archived?.let { put("archived", it.toString()) } - cursor?.let { put("cursor", it) } - enqueuedAfter?.let { put("enqueued_after", it) } - event?.let { put("event", it) } - list?.let { put("list", it) } - messageId?.let { put("messageId", it) } - notification?.let { put("notification", it) } - provider?.let { put("provider", it.joinToString(",")) } - recipient?.let { put("recipient", it) } - status?.let { put("status", it.joinToString(",")) } - tag?.let { put("tag", it.joinToString(",")) } - tags?.let { put("tags", it) } - tenantId?.let { put("tenant_id", it) } - traceId?.let { put("traceId", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageListParams && - archived == other.archived && - cursor == other.cursor && - enqueuedAfter == other.enqueuedAfter && - event == other.event && - list == other.list && - messageId == other.messageId && - notification == other.notification && - provider == other.provider && - recipient == other.recipient && - status == other.status && - tag == other.tag && - tags == other.tags && - tenantId == other.tenantId && - traceId == other.traceId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - archived, - cursor, - enqueuedAfter, - event, - list, - messageId, - notification, - provider, - recipient, - status, - tag, - tags, - tenantId, - traceId, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "MessageListParams{archived=$archived, cursor=$cursor, enqueuedAfter=$enqueuedAfter, event=$event, list=$list, messageId=$messageId, notification=$notification, provider=$provider, recipient=$recipient, status=$status, tag=$tag, tags=$tags, tenantId=$tenantId, traceId=$traceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt deleted file mode 100644 index 4cb37861..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageListResponse.kt +++ /dev/null @@ -1,234 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class MessageListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val paging: JsonField, - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("results") - @ExcludeMissing - results: JsonField> = JsonMissing.of(), - ) : this(paging, results, mutableMapOf()) - - /** - * Paging information for the result set. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * An array of messages with their details. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") - @ExcludeMissing - fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MessageListResponse]. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageListResponse]. */ - class Builder internal constructor() { - - private var paging: JsonField? = null - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(messageListResponse: MessageListResponse) = apply { - paging = messageListResponse.paging - results = messageListResponse.results.map { it.toMutableList() } - additionalProperties = messageListResponse.additionalProperties.toMutableMap() - } - - /** Paging information for the result set. */ - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - /** An array of messages with their details. */ - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [MessageDetails] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: MessageDetails) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MessageListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MessageListResponse = - MessageListResponse( - checkRequired("paging", paging), - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MessageListResponse = apply { - if (validated) { - return@apply - } - - paging().validate() - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageListResponse && - paging == other.paging && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MessageListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt deleted file mode 100644 index de135e40..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveParams.kt +++ /dev/null @@ -1,193 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch the status of a message you've previously sent. */ -class MessageRetrieveParams -private constructor( - private val messageId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun messageId(): Optional = Optional.ofNullable(messageId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): MessageRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [MessageRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageRetrieveParams]. */ - class Builder internal constructor() { - - private var messageId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(messageRetrieveParams: MessageRetrieveParams) = apply { - messageId = messageRetrieveParams.messageId - additionalHeaders = messageRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = messageRetrieveParams.additionalQueryParams.toBuilder() - } - - fun messageId(messageId: String?) = apply { this.messageId = messageId } - - /** Alias for calling [Builder.messageId] with `messageId.orElse(null)`. */ - fun messageId(messageId: Optional) = messageId(messageId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [MessageRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MessageRetrieveParams = - MessageRetrieveParams( - messageId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> messageId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageRetrieveParams && - messageId == other.messageId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(messageId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "MessageRetrieveParams{messageId=$messageId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt deleted file mode 100644 index ef93ce21..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/messages/MessageRetrieveResponse.kt +++ /dev/null @@ -1,814 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class MessageRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val clicked: JsonField, - private val delivered: JsonField, - private val enqueued: JsonField, - private val event: JsonField, - private val notification: JsonField, - private val opened: JsonField, - private val recipient: JsonField, - private val sent: JsonField, - private val status: JsonField, - private val error: JsonField, - private val reason: JsonField, - private val providers: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("clicked") @ExcludeMissing clicked: JsonField = JsonMissing.of(), - @JsonProperty("delivered") @ExcludeMissing delivered: JsonField = JsonMissing.of(), - @JsonProperty("enqueued") @ExcludeMissing enqueued: JsonField = JsonMissing.of(), - @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("notification") - @ExcludeMissing - notification: JsonField = JsonMissing.of(), - @JsonProperty("opened") @ExcludeMissing opened: JsonField = JsonMissing.of(), - @JsonProperty("recipient") @ExcludeMissing recipient: JsonField = JsonMissing.of(), - @JsonProperty("sent") @ExcludeMissing sent: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - reason: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField> = JsonMissing.of(), - ) : this( - id, - clicked, - delivered, - enqueued, - event, - notification, - opened, - recipient, - sent, - status, - error, - reason, - providers, - mutableMapOf(), - ) - - fun toMessageDetails(): MessageDetails = - MessageDetails.builder() - .id(id) - .clicked(clicked) - .delivered(delivered) - .enqueued(enqueued) - .event(event) - .notification(notification) - .opened(opened) - .recipient(recipient) - .sent(sent) - .status(status) - .error(error) - .reason(reason) - .build() - - /** - * A unique identifier associated with the message you wish to retrieve (results from a send). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * A UTC timestamp at which the recipient clicked on a tracked link for the first time. Stored - * as a millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun clicked(): Long = clicked.getRequired("clicked") - - /** - * A UTC timestamp at which the Integration provider delivered the message. Stored as a - * millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun delivered(): Long = delivered.getRequired("delivered") - - /** - * A UTC timestamp at which Courier received the message request. Stored as a millisecond - * representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun enqueued(): Long = enqueued.getRequired("enqueued") - - /** - * A unique identifier associated with the event of the delivered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun event(): String = event.getRequired("event") - - /** - * A unique identifier associated with the notification of the delivered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun notification(): String = notification.getRequired("notification") - - /** - * A UTC timestamp at which the recipient opened a message for the first time. Stored as a - * millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun opened(): Long = opened.getRequired("opened") - - /** - * A unique identifier associated with the recipient of the delivered message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun recipient(): String = recipient.getRequired("recipient") - - /** - * A UTC timestamp at which Courier passed the message to the Integration provider. Stored as a - * millisecond representation of the Unix epoch. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun sent(): Long = sent.getRequired("sent") - - /** - * The current status of the message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): MessageDetails.Status = status.getRequired("status") - - /** - * A message describing the error that occurred. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun error(): Optional = error.getOptional("error") - - /** - * The reason for the current status of the message. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun providers(): Optional> = providers.getOptional("providers") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [clicked]. - * - * Unlike [clicked], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("clicked") @ExcludeMissing fun _clicked(): JsonField = clicked - - /** - * Returns the raw JSON value of [delivered]. - * - * Unlike [delivered], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delivered") @ExcludeMissing fun _delivered(): JsonField = delivered - - /** - * Returns the raw JSON value of [enqueued]. - * - * Unlike [enqueued], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("enqueued") @ExcludeMissing fun _enqueued(): JsonField = enqueued - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - - /** - * Returns the raw JSON value of [notification]. - * - * Unlike [notification], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("notification") - @ExcludeMissing - fun _notification(): JsonField = notification - - /** - * Returns the raw JSON value of [opened]. - * - * Unlike [opened], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("opened") @ExcludeMissing fun _opened(): JsonField = opened - - /** - * Returns the raw JSON value of [recipient]. - * - * Unlike [recipient], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("recipient") @ExcludeMissing fun _recipient(): JsonField = recipient - - /** - * Returns the raw JSON value of [sent]. - * - * Unlike [sent], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("sent") @ExcludeMissing fun _sent(): JsonField = sent - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [error]. - * - * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("providers") - @ExcludeMissing - fun _providers(): JsonField> = providers - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MessageRetrieveResponse]. - * - * The following fields are required: - * ```java - * .id() - * .clicked() - * .delivered() - * .enqueued() - * .event() - * .notification() - * .opened() - * .recipient() - * .sent() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MessageRetrieveResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var clicked: JsonField? = null - private var delivered: JsonField? = null - private var enqueued: JsonField? = null - private var event: JsonField? = null - private var notification: JsonField? = null - private var opened: JsonField? = null - private var recipient: JsonField? = null - private var sent: JsonField? = null - private var status: JsonField? = null - private var error: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var providers: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(messageRetrieveResponse: MessageRetrieveResponse) = apply { - id = messageRetrieveResponse.id - clicked = messageRetrieveResponse.clicked - delivered = messageRetrieveResponse.delivered - enqueued = messageRetrieveResponse.enqueued - event = messageRetrieveResponse.event - notification = messageRetrieveResponse.notification - opened = messageRetrieveResponse.opened - recipient = messageRetrieveResponse.recipient - sent = messageRetrieveResponse.sent - status = messageRetrieveResponse.status - error = messageRetrieveResponse.error - reason = messageRetrieveResponse.reason - providers = messageRetrieveResponse.providers.map { it.toMutableList() } - additionalProperties = messageRetrieveResponse.additionalProperties.toMutableMap() - } - - /** - * A unique identifier associated with the message you wish to retrieve (results from a - * send). - */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * A UTC timestamp at which the recipient clicked on a tracked link for the first time. - * Stored as a millisecond representation of the Unix epoch. - */ - fun clicked(clicked: Long) = clicked(JsonField.of(clicked)) - - /** - * Sets [Builder.clicked] to an arbitrary JSON value. - * - * You should usually call [Builder.clicked] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun clicked(clicked: JsonField) = apply { this.clicked = clicked } - - /** - * A UTC timestamp at which the Integration provider delivered the message. Stored as a - * millisecond representation of the Unix epoch. - */ - fun delivered(delivered: Long) = delivered(JsonField.of(delivered)) - - /** - * Sets [Builder.delivered] to an arbitrary JSON value. - * - * You should usually call [Builder.delivered] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun delivered(delivered: JsonField) = apply { this.delivered = delivered } - - /** - * A UTC timestamp at which Courier received the message request. Stored as a millisecond - * representation of the Unix epoch. - */ - fun enqueued(enqueued: Long) = enqueued(JsonField.of(enqueued)) - - /** - * Sets [Builder.enqueued] to an arbitrary JSON value. - * - * You should usually call [Builder.enqueued] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun enqueued(enqueued: JsonField) = apply { this.enqueued = enqueued } - - /** A unique identifier associated with the event of the delivered message. */ - fun event(event: String) = event(JsonField.of(event)) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - /** A unique identifier associated with the notification of the delivered message. */ - fun notification(notification: String) = notification(JsonField.of(notification)) - - /** - * Sets [Builder.notification] to an arbitrary JSON value. - * - * You should usually call [Builder.notification] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun notification(notification: JsonField) = apply { - this.notification = notification - } - - /** - * A UTC timestamp at which the recipient opened a message for the first time. Stored as a - * millisecond representation of the Unix epoch. - */ - fun opened(opened: Long) = opened(JsonField.of(opened)) - - /** - * Sets [Builder.opened] to an arbitrary JSON value. - * - * You should usually call [Builder.opened] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun opened(opened: JsonField) = apply { this.opened = opened } - - /** A unique identifier associated with the recipient of the delivered message. */ - fun recipient(recipient: String) = recipient(JsonField.of(recipient)) - - /** - * Sets [Builder.recipient] to an arbitrary JSON value. - * - * You should usually call [Builder.recipient] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun recipient(recipient: JsonField) = apply { this.recipient = recipient } - - /** - * A UTC timestamp at which Courier passed the message to the Integration provider. Stored - * as a millisecond representation of the Unix epoch. - */ - fun sent(sent: Long) = sent(JsonField.of(sent)) - - /** - * Sets [Builder.sent] to an arbitrary JSON value. - * - * You should usually call [Builder.sent] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun sent(sent: JsonField) = apply { this.sent = sent } - - /** The current status of the message. */ - fun status(status: MessageDetails.Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [MessageDetails.Status] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** A message describing the error that occurred. */ - fun error(error: String?) = error(JsonField.ofNullable(error)) - - /** Alias for calling [Builder.error] with `error.orElse(null)`. */ - fun error(error: Optional) = error(error.getOrNull()) - - /** - * Sets [Builder.error] to an arbitrary JSON value. - * - * You should usually call [Builder.error] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun error(error: JsonField) = apply { this.error = error } - - /** The reason for the current status of the message. */ - fun reason(reason: MessageDetails.Reason?) = reason(JsonField.ofNullable(reason)) - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [MessageDetails.Reason] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun providers(providers: List?) = providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional>) = providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun providers(providers: JsonField>) = apply { - this.providers = providers.map { it.toMutableList() } - } - - /** - * Adds a single [Provider] to [providers]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProvider(provider: Provider) = apply { - providers = - (providers ?: JsonField.of(mutableListOf())).also { - checkKnown("providers", it).add(provider) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MessageRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .clicked() - * .delivered() - * .enqueued() - * .event() - * .notification() - * .opened() - * .recipient() - * .sent() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MessageRetrieveResponse = - MessageRetrieveResponse( - checkRequired("id", id), - checkRequired("clicked", clicked), - checkRequired("delivered", delivered), - checkRequired("enqueued", enqueued), - checkRequired("event", event), - checkRequired("notification", notification), - checkRequired("opened", opened), - checkRequired("recipient", recipient), - checkRequired("sent", sent), - checkRequired("status", status), - error, - reason, - (providers ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MessageRetrieveResponse = apply { - if (validated) { - return@apply - } - - id() - clicked() - delivered() - enqueued() - event() - notification() - opened() - recipient() - sent() - status().validate() - error() - reason().ifPresent { it.validate() } - providers().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (clicked.asKnown().isPresent) 1 else 0) + - (if (delivered.asKnown().isPresent) 1 else 0) + - (if (enqueued.asKnown().isPresent) 1 else 0) + - (if (event.asKnown().isPresent) 1 else 0) + - (if (notification.asKnown().isPresent) 1 else 0) + - (if (opened.asKnown().isPresent) 1 else 0) + - (if (recipient.asKnown().isPresent) 1 else 0) + - (if (sent.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (error.asKnown().isPresent) 1 else 0) + - (reason.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Provider - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Provider]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Provider]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(provider: Provider) = apply { - additionalProperties = provider.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Provider]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Provider = Provider(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Provider = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Provider && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Provider{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MessageRetrieveResponse && - id == other.id && - clicked == other.clicked && - delivered == other.delivered && - enqueued == other.enqueued && - event == other.event && - notification == other.notification && - opened == other.opened && - recipient == other.recipient && - sent == other.sent && - status == other.status && - error == other.error && - reason == other.reason && - providers == other.providers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - clicked, - delivered, - enqueued, - event, - notification, - opened, - recipient, - sent, - status, - error, - reason, - providers, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MessageRetrieveResponse{id=$id, clicked=$clicked, delivered=$delivered, enqueued=$enqueued, event=$event, notification=$notification, opened=$opened, recipient=$recipient, sent=$sent, status=$status, error=$error, reason=$reason, providers=$providers, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt deleted file mode 100644 index 5b4c3ae5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationGetContent.kt +++ /dev/null @@ -1,1906 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class NotificationGetContent -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val blocks: JsonField>, - private val channels: JsonField>, - private val checksum: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("blocks") @ExcludeMissing blocks: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("checksum") @ExcludeMissing checksum: JsonField = JsonMissing.of(), - ) : this(blocks, channels, checksum, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun blocks(): Optional> = blocks.getOptional("blocks") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun checksum(): Optional = checksum.getOptional("checksum") - - /** - * Returns the raw JSON value of [blocks]. - * - * Unlike [blocks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("blocks") @ExcludeMissing fun _blocks(): JsonField> = blocks - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [checksum]. - * - * Unlike [checksum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("checksum") @ExcludeMissing fun _checksum(): JsonField = checksum - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [NotificationGetContent]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NotificationGetContent]. */ - class Builder internal constructor() { - - private var blocks: JsonField>? = null - private var channels: JsonField>? = null - private var checksum: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(notificationGetContent: NotificationGetContent) = apply { - blocks = notificationGetContent.blocks.map { it.toMutableList() } - channels = notificationGetContent.channels.map { it.toMutableList() } - checksum = notificationGetContent.checksum - additionalProperties = notificationGetContent.additionalProperties.toMutableMap() - } - - fun blocks(blocks: List?) = blocks(JsonField.ofNullable(blocks)) - - /** Alias for calling [Builder.blocks] with `blocks.orElse(null)`. */ - fun blocks(blocks: Optional>) = blocks(blocks.getOrNull()) - - /** - * Sets [Builder.blocks] to an arbitrary JSON value. - * - * You should usually call [Builder.blocks] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun blocks(blocks: JsonField>) = apply { - this.blocks = blocks.map { it.toMutableList() } - } - - /** - * Adds a single [Block] to [blocks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addBlock(block: Block) = apply { - blocks = - (blocks ?: JsonField.of(mutableListOf())).also { - checkKnown("blocks", it).add(block) - } - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [Channel] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: Channel) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun checksum(checksum: String?) = checksum(JsonField.ofNullable(checksum)) - - /** Alias for calling [Builder.checksum] with `checksum.orElse(null)`. */ - fun checksum(checksum: Optional) = checksum(checksum.getOrNull()) - - /** - * Sets [Builder.checksum] to an arbitrary JSON value. - * - * You should usually call [Builder.checksum] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun checksum(checksum: JsonField) = apply { this.checksum = checksum } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NotificationGetContent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): NotificationGetContent = - NotificationGetContent( - (blocks ?: JsonMissing.of()).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - checksum, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NotificationGetContent = apply { - if (validated) { - return@apply - } - - blocks().ifPresent { it.forEach { it.validate() } } - channels().ifPresent { it.forEach { it.validate() } } - checksum() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (blocks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (checksum.asKnown().isPresent) 1 else 0) - - class Block - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val type: JsonField, - private val alias: JsonField, - private val checksum: JsonField, - private val content: JsonField, - private val context: JsonField, - private val locales: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("alias") @ExcludeMissing alias: JsonField = JsonMissing.of(), - @JsonProperty("checksum") - @ExcludeMissing - checksum: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - @JsonProperty("context") @ExcludeMissing context: JsonField = JsonMissing.of(), - @JsonProperty("locales") @ExcludeMissing locales: JsonField = JsonMissing.of(), - ) : this(id, type, alias, checksum, content, context, locales, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun alias(): Optional = alias.getOptional("alias") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun checksum(): Optional = checksum.getOptional("checksum") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun locales(): Optional = locales.getOptional("locales") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [alias]. - * - * Unlike [alias], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("alias") @ExcludeMissing fun _alias(): JsonField = alias - - /** - * Returns the raw JSON value of [checksum]. - * - * Unlike [checksum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("checksum") @ExcludeMissing fun _checksum(): JsonField = checksum - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [locales]. - * - * Unlike [locales], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("locales") @ExcludeMissing fun _locales(): JsonField = locales - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Block]. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Block]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var type: JsonField? = null - private var alias: JsonField = JsonMissing.of() - private var checksum: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var locales: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(block: Block) = apply { - id = block.id - type = block.type - alias = block.alias - checksum = block.checksum - content = block.content - context = block.context - locales = block.locales - additionalProperties = block.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun alias(alias: String?) = alias(JsonField.ofNullable(alias)) - - /** Alias for calling [Builder.alias] with `alias.orElse(null)`. */ - fun alias(alias: Optional) = alias(alias.getOrNull()) - - /** - * Sets [Builder.alias] to an arbitrary JSON value. - * - * You should usually call [Builder.alias] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun alias(alias: JsonField) = apply { this.alias = alias } - - fun checksum(checksum: String?) = checksum(JsonField.ofNullable(checksum)) - - /** Alias for calling [Builder.checksum] with `checksum.orElse(null)`. */ - fun checksum(checksum: Optional) = checksum(checksum.getOrNull()) - - /** - * Sets [Builder.checksum] to an arbitrary JSON value. - * - * You should usually call [Builder.checksum] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun checksum(checksum: JsonField) = apply { this.checksum = checksum } - - fun content(content: Content?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [Content] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - /** Alias for calling [content] with `Content.ofString(string)`. */ - fun content(string: String) = content(Content.ofString(string)) - - /** - * Alias for calling [content] with - * `Content.ofNotificationContentHierarchy(notificationContentHierarchy)`. - */ - fun content(notificationContentHierarchy: Content.NotificationContentHierarchy) = - content(Content.ofNotificationContentHierarchy(notificationContentHierarchy)) - - fun context(context: String?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - fun locales(locales: Locales?) = locales(JsonField.ofNullable(locales)) - - /** Alias for calling [Builder.locales] with `locales.orElse(null)`. */ - fun locales(locales: Optional) = locales(locales.getOrNull()) - - /** - * Sets [Builder.locales] to an arbitrary JSON value. - * - * You should usually call [Builder.locales] with a well-typed [Locales] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun locales(locales: JsonField) = apply { this.locales = locales } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Block]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Block = - Block( - checkRequired("id", id), - checkRequired("type", type), - alias, - checksum, - content, - context, - locales, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Block = apply { - if (validated) { - return@apply - } - - id() - type().validate() - alias() - checksum() - content().ifPresent { it.validate() } - context() - locales().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (alias.asKnown().isPresent) 1 else 0) + - (if (checksum.asKnown().isPresent) 1 else 0) + - (content.asKnown().getOrNull()?.validity() ?: 0) + - (if (context.asKnown().isPresent) 1 else 0) + - (locales.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTION = of("action") - - @JvmField val DIVIDER = of("divider") - - @JvmField val IMAGE = of("image") - - @JvmField val JSONNET = of("jsonnet") - - @JvmField val LIST = of("list") - - @JvmField val MARKDOWN = of("markdown") - - @JvmField val QUOTE = of("quote") - - @JvmField val TEMPLATE = of("template") - - @JvmField val TEXT = of("text") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ACTION, - DIVIDER, - IMAGE, - JSONNET, - LIST, - MARKDOWN, - QUOTE, - TEMPLATE, - TEXT, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTION, - DIVIDER, - IMAGE, - JSONNET, - LIST, - MARKDOWN, - QUOTE, - TEMPLATE, - TEXT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTION -> Value.ACTION - DIVIDER -> Value.DIVIDER - IMAGE -> Value.IMAGE - JSONNET -> Value.JSONNET - LIST -> Value.LIST - MARKDOWN -> Value.MARKDOWN - QUOTE -> Value.QUOTE - TEMPLATE -> Value.TEMPLATE - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTION -> Known.ACTION - DIVIDER -> Known.DIVIDER - IMAGE -> Known.IMAGE - JSONNET -> Known.JSONNET - LIST -> Known.LIST - MARKDOWN -> Known.MARKDOWN - QUOTE -> Known.QUOTE - TEMPLATE -> Known.TEMPLATE - TEXT -> Known.TEXT - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - @JsonDeserialize(using = Content.Deserializer::class) - @JsonSerialize(using = Content.Serializer::class) - class Content - private constructor( - private val string: String? = null, - private val notificationContentHierarchy: NotificationContentHierarchy? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun notificationContentHierarchy(): Optional = - Optional.ofNullable(notificationContentHierarchy) - - fun isString(): Boolean = string != null - - fun isNotificationContentHierarchy(): Boolean = notificationContentHierarchy != null - - fun asString(): String = string.getOrThrow("string") - - fun asNotificationContentHierarchy(): NotificationContentHierarchy = - notificationContentHierarchy.getOrThrow("notificationContentHierarchy") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - notificationContentHierarchy != null -> - visitor.visitNotificationContentHierarchy(notificationContentHierarchy) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Content = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitNotificationContentHierarchy( - notificationContentHierarchy: NotificationContentHierarchy - ) { - notificationContentHierarchy.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitNotificationContentHierarchy( - notificationContentHierarchy: NotificationContentHierarchy - ) = notificationContentHierarchy.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - string == other.string && - notificationContentHierarchy == other.notificationContentHierarchy - } - - override fun hashCode(): Int = Objects.hash(string, notificationContentHierarchy) - - override fun toString(): String = - when { - string != null -> "Content{string=$string}" - notificationContentHierarchy != null -> - "Content{notificationContentHierarchy=$notificationContentHierarchy}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - - companion object { - - @JvmStatic fun ofString(string: String) = Content(string = string) - - @JvmStatic - fun ofNotificationContentHierarchy( - notificationContentHierarchy: NotificationContentHierarchy - ) = Content(notificationContentHierarchy = notificationContentHierarchy) - } - - /** - * An interface that defines how to map each variant of [Content] to a value of type - * [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitNotificationContentHierarchy( - notificationContentHierarchy: NotificationContentHierarchy - ): T - - /** - * Maps an unknown variant of [Content] to a value of type [T]. - * - * An instance of [Content] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Content: $json") - } - } - - internal class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { - Content(notificationContentHierarchy = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from array). - 0 -> Content(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.notificationContentHierarchy != null -> - generator.writeObject(value.notificationContentHierarchy) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - class NotificationContentHierarchy - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val children: JsonField, - private val parent: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("children") - @ExcludeMissing - children: JsonField = JsonMissing.of(), - @JsonProperty("parent") - @ExcludeMissing - parent: JsonField = JsonMissing.of(), - ) : this(children, parent, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun children(): Optional = children.getOptional("children") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun parent(): Optional = parent.getOptional("parent") - - /** - * Returns the raw JSON value of [children]. - * - * Unlike [children], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("children") - @ExcludeMissing - fun _children(): JsonField = children - - /** - * Returns the raw JSON value of [parent]. - * - * Unlike [parent], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [NotificationContentHierarchy]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NotificationContentHierarchy]. */ - class Builder internal constructor() { - - private var children: JsonField = JsonMissing.of() - private var parent: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(notificationContentHierarchy: NotificationContentHierarchy) = - apply { - children = notificationContentHierarchy.children - parent = notificationContentHierarchy.parent - additionalProperties = - notificationContentHierarchy.additionalProperties.toMutableMap() - } - - fun children(children: String?) = children(JsonField.ofNullable(children)) - - /** Alias for calling [Builder.children] with `children.orElse(null)`. */ - fun children(children: Optional) = children(children.getOrNull()) - - /** - * Sets [Builder.children] to an arbitrary JSON value. - * - * You should usually call [Builder.children] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun children(children: JsonField) = apply { this.children = children } - - fun parent(parent: String?) = parent(JsonField.ofNullable(parent)) - - /** Alias for calling [Builder.parent] with `parent.orElse(null)`. */ - fun parent(parent: Optional) = parent(parent.getOrNull()) - - /** - * Sets [Builder.parent] to an arbitrary JSON value. - * - * You should usually call [Builder.parent] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun parent(parent: JsonField) = apply { this.parent = parent } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NotificationContentHierarchy]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): NotificationContentHierarchy = - NotificationContentHierarchy( - children, - parent, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NotificationContentHierarchy = apply { - if (validated) { - return@apply - } - - children() - parent() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (children.asKnown().isPresent) 1 else 0) + - (if (parent.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NotificationContentHierarchy && - children == other.children && - parent == other.parent && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(children, parent, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NotificationContentHierarchy{children=$children, parent=$parent, additionalProperties=$additionalProperties}" - } - } - - class Locales - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Locales]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Locales]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(locales: Locales) = apply { - additionalProperties = locales.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Locales]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Locales = Locales(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Locales = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Locales && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Locales{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Block && - id == other.id && - type == other.type && - alias == other.alias && - checksum == other.checksum && - content == other.content && - context == other.context && - locales == other.locales && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, type, alias, checksum, content, context, locales, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Block{id=$id, type=$type, alias=$alias, checksum=$checksum, content=$content, context=$context, locales=$locales, additionalProperties=$additionalProperties}" - } - - class Channel - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val checksum: JsonField, - private val content: JsonField, - private val locales: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("checksum") - @ExcludeMissing - checksum: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - @JsonProperty("locales") @ExcludeMissing locales: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(id, checksum, content, locales, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun checksum(): Optional = checksum.getOptional("checksum") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun locales(): Optional = locales.getOptional("locales") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [checksum]. - * - * Unlike [checksum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("checksum") @ExcludeMissing fun _checksum(): JsonField = checksum - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [locales]. - * - * Unlike [locales], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("locales") @ExcludeMissing fun _locales(): JsonField = locales - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Channel]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Channel]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var checksum: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var locales: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(channel: Channel) = apply { - id = channel.id - checksum = channel.checksum - content = channel.content - locales = channel.locales - type = channel.type - additionalProperties = channel.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun checksum(checksum: String?) = checksum(JsonField.ofNullable(checksum)) - - /** Alias for calling [Builder.checksum] with `checksum.orElse(null)`. */ - fun checksum(checksum: Optional) = checksum(checksum.getOrNull()) - - /** - * Sets [Builder.checksum] to an arbitrary JSON value. - * - * You should usually call [Builder.checksum] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun checksum(checksum: JsonField) = apply { this.checksum = checksum } - - fun content(content: Content?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [Content] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - fun locales(locales: Locales?) = locales(JsonField.ofNullable(locales)) - - /** Alias for calling [Builder.locales] with `locales.orElse(null)`. */ - fun locales(locales: Optional) = locales(locales.getOrNull()) - - /** - * Sets [Builder.locales] to an arbitrary JSON value. - * - * You should usually call [Builder.locales] with a well-typed [Locales] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun locales(locales: JsonField) = apply { this.locales = locales } - - fun type(type: String?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Channel]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Channel = - Channel( - checkRequired("id", id), - checksum, - content, - locales, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Channel = apply { - if (validated) { - return@apply - } - - id() - checksum() - content().ifPresent { it.validate() } - locales().ifPresent { it.validate() } - type() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (checksum.asKnown().isPresent) 1 else 0) + - (content.asKnown().getOrNull()?.validity() ?: 0) + - (locales.asKnown().getOrNull()?.validity() ?: 0) + - (if (type.asKnown().isPresent) 1 else 0) - - class Content - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val subject: JsonField, - private val title: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("subject") - @ExcludeMissing - subject: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - ) : this(subject, title, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subject(): Optional = subject.getOptional("subject") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun title(): Optional = title.getOptional("title") - - /** - * Returns the raw JSON value of [subject]. - * - * Unlike [subject], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("subject") @ExcludeMissing fun _subject(): JsonField = subject - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Content]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Content]. */ - class Builder internal constructor() { - - private var subject: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(content: Content) = apply { - subject = content.subject - title = content.title - additionalProperties = content.additionalProperties.toMutableMap() - } - - fun subject(subject: String?) = subject(JsonField.ofNullable(subject)) - - /** Alias for calling [Builder.subject] with `subject.orElse(null)`. */ - fun subject(subject: Optional) = subject(subject.getOrNull()) - - /** - * Sets [Builder.subject] to an arbitrary JSON value. - * - * You should usually call [Builder.subject] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun subject(subject: JsonField) = apply { this.subject = subject } - - fun title(title: String?) = title(JsonField.ofNullable(title)) - - /** Alias for calling [Builder.title] with `title.orElse(null)`. */ - fun title(title: Optional) = title(title.getOrNull()) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Content]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Content = Content(subject, title, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Content = apply { - if (validated) { - return@apply - } - - subject() - title() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (subject.asKnown().isPresent) 1 else 0) + - (if (title.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - subject == other.subject && - title == other.title && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(subject, title, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Content{subject=$subject, title=$title, additionalProperties=$additionalProperties}" - } - - class Locales - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Locales]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Locales]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(locales: Locales) = apply { - additionalProperties = locales.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Locales]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Locales = Locales(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Locales = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Locales && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Locales{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Channel && - id == other.id && - checksum == other.checksum && - content == other.content && - locales == other.locales && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, checksum, content, locales, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Channel{id=$id, checksum=$checksum, content=$content, locales=$locales, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NotificationGetContent && - blocks == other.blocks && - channels == other.channels && - checksum == other.checksum && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(blocks, channels, checksum, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NotificationGetContent{blocks=$blocks, channels=$channels, checksum=$checksum, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt deleted file mode 100644 index 16af7e50..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListParams.kt +++ /dev/null @@ -1,215 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class NotificationListParams -private constructor( - private val cursor: String?, - private val notes: Boolean?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Retrieve the notes from the Notification template settings. */ - fun notes(): Optional = Optional.ofNullable(notes) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): NotificationListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [NotificationListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NotificationListParams]. */ - class Builder internal constructor() { - - private var cursor: String? = null - private var notes: Boolean? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(notificationListParams: NotificationListParams) = apply { - cursor = notificationListParams.cursor - notes = notificationListParams.notes - additionalHeaders = notificationListParams.additionalHeaders.toBuilder() - additionalQueryParams = notificationListParams.additionalQueryParams.toBuilder() - } - - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** Retrieve the notes from the Notification template settings. */ - fun notes(notes: Boolean?) = apply { this.notes = notes } - - /** - * Alias for [Builder.notes]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun notes(notes: Boolean) = notes(notes as Boolean?) - - /** Alias for calling [Builder.notes] with `notes.orElse(null)`. */ - fun notes(notes: Optional) = notes(notes.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [NotificationListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): NotificationListParams = - NotificationListParams( - cursor, - notes, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - notes?.let { put("notes", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NotificationListParams && - cursor == other.cursor && - notes == other.notes && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(cursor, notes, additionalHeaders, additionalQueryParams) - - override fun toString() = - "NotificationListParams{cursor=$cursor, notes=$notes, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt deleted file mode 100644 index e406ae39..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationListResponse.kt +++ /dev/null @@ -1,1014 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class NotificationListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val paging: JsonField, - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of(), - ) : this(paging, results, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [NotificationListResponse]. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NotificationListResponse]. */ - class Builder internal constructor() { - - private var paging: JsonField? = null - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(notificationListResponse: NotificationListResponse) = apply { - paging = notificationListResponse.paging - results = notificationListResponse.results.map { it.toMutableList() } - additionalProperties = notificationListResponse.additionalProperties.toMutableMap() - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [NotificationListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): NotificationListResponse = - NotificationListResponse( - checkRequired("paging", paging), - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): NotificationListResponse = apply { - if (validated) { - return@apply - } - - paging().validate() - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Result - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val createdAt: JsonField, - private val note: JsonField, - private val routing: JsonField, - private val topicId: JsonField, - private val updatedAt: JsonField, - private val tags: JsonField, - private val title: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("note") @ExcludeMissing note: JsonField = JsonMissing.of(), - @JsonProperty("routing") - @ExcludeMissing - routing: JsonField = JsonMissing.of(), - @JsonProperty("topic_id") @ExcludeMissing topicId: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing tags: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - ) : this(id, createdAt, note, routing, topicId, updatedAt, tags, title, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): Long = createdAt.getRequired("created_at") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun note(): String = note.getRequired("note") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun routing(): MessageRouting = routing.getRequired("routing") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun topicId(): String = topicId.getRequired("topic_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updatedAt(): Long = updatedAt.getRequired("updated_at") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tags(): Optional = tags.getOptional("tags") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun title(): Optional = title.getOptional("title") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [note]. - * - * Unlike [note], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("note") @ExcludeMissing fun _note(): JsonField = note - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") @ExcludeMissing fun _routing(): JsonField = routing - - /** - * Returns the raw JSON value of [topicId]. - * - * Unlike [topicId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic_id") @ExcludeMissing fun _topicId(): JsonField = topicId - - /** - * Returns the raw JSON value of [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt - - /** - * Returns the raw JSON value of [tags]. - * - * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField = tags - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Result]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .note() - * .routing() - * .topicId() - * .updatedAt() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var note: JsonField? = null - private var routing: JsonField? = null - private var topicId: JsonField? = null - private var updatedAt: JsonField? = null - private var tags: JsonField = JsonMissing.of() - private var title: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - id = result.id - createdAt = result.createdAt - note = result.note - routing = result.routing - topicId = result.topicId - updatedAt = result.updatedAt - tags = result.tags - title = result.title - additionalProperties = result.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun createdAt(createdAt: Long) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - fun note(note: String) = note(JsonField.of(note)) - - /** - * Sets [Builder.note] to an arbitrary JSON value. - * - * You should usually call [Builder.note] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun note(note: JsonField) = apply { this.note = note } - - fun routing(routing: MessageRouting) = routing(JsonField.of(routing)) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [MessageRouting] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun routing(routing: JsonField) = apply { this.routing = routing } - - fun topicId(topicId: String) = topicId(JsonField.of(topicId)) - - /** - * Sets [Builder.topicId] to an arbitrary JSON value. - * - * You should usually call [Builder.topicId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun topicId(topicId: JsonField) = apply { this.topicId = topicId } - - fun updatedAt(updatedAt: Long) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - fun tags(tags: Tags?) = tags(JsonField.ofNullable(tags)) - - /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ - fun tags(tags: Optional) = tags(tags.getOrNull()) - - /** - * Sets [Builder.tags] to an arbitrary JSON value. - * - * You should usually call [Builder.tags] with a well-typed [Tags] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tags(tags: JsonField) = apply { this.tags = tags } - - fun title(title: String?) = title(JsonField.ofNullable(title)) - - /** Alias for calling [Builder.title] with `title.orElse(null)`. */ - fun title(title: Optional) = title(title.getOrNull()) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .note() - * .routing() - * .topicId() - * .updatedAt() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Result = - Result( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("note", note), - checkRequired("routing", routing), - checkRequired("topicId", topicId), - checkRequired("updatedAt", updatedAt), - tags, - title, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Result = apply { - if (validated) { - return@apply - } - - id() - createdAt() - note() - routing().validate() - topicId() - updatedAt() - tags().ifPresent { it.validate() } - title() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (note.asKnown().isPresent) 1 else 0) + - (routing.asKnown().getOrNull()?.validity() ?: 0) + - (if (topicId.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (tags.asKnown().getOrNull()?.validity() ?: 0) + - (if (title.asKnown().isPresent) 1 else 0) - - class Tags - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField> = JsonMissing.of() - ) : this(data, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun data(): List = data.getRequired("data") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tags]. - * - * The following fields are required: - * ```java - * .data() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tags]. */ - class Builder internal constructor() { - - private var data: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tags: Tags) = apply { - data = tags.data.map { it.toMutableList() } - additionalProperties = tags.additionalProperties.toMutableMap() - } - - fun data(data: List) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun data(data: JsonField>) = apply { - this.data = data.map { it.toMutableList() } - } - - /** - * Adds a single [Data] to [Builder.data]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addData(data: Data) = apply { - this.data = - (this.data ?: JsonField.of(mutableListOf())).also { - checkKnown("data", it).add(data) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tags]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .data() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tags = - Tags( - checkRequired("data", data).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tags = apply { - if (validated) { - return@apply - } - - data().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (data.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Data - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(id, name, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Data]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - id = data.id - name = data.name - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Data = - Data( - checkRequired("id", id), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - id() - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - id == other.id && - name == other.name && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, name, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{id=$id, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tags && - data == other.data && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(data, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Tags{data=$data, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && - id == other.id && - createdAt == other.createdAt && - note == other.note && - routing == other.routing && - topicId == other.topicId && - updatedAt == other.updatedAt && - tags == other.tags && - title == other.title && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - createdAt, - note, - routing, - topicId, - updatedAt, - tags, - title, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Result{id=$id, createdAt=$createdAt, note=$note, routing=$routing, topicId=$topicId, updatedAt=$updatedAt, tags=$tags, title=$title, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NotificationListResponse && - paging == other.paging && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "NotificationListResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt deleted file mode 100644 index 218897c6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParams.kt +++ /dev/null @@ -1,197 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class NotificationRetrieveContentParams -private constructor( - private val id: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun id(): Optional = Optional.ofNullable(id) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): NotificationRetrieveContentParams = builder().build() - - /** - * Returns a mutable builder for constructing an instance of - * [NotificationRetrieveContentParams]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [NotificationRetrieveContentParams]. */ - class Builder internal constructor() { - - private var id: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(notificationRetrieveContentParams: NotificationRetrieveContentParams) = - apply { - id = notificationRetrieveContentParams.id - additionalHeaders = notificationRetrieveContentParams.additionalHeaders.toBuilder() - additionalQueryParams = - notificationRetrieveContentParams.additionalQueryParams.toBuilder() - } - - fun id(id: String?) = apply { this.id = id } - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [NotificationRetrieveContentParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): NotificationRetrieveContentParams = - NotificationRetrieveContentParams( - id, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> id ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is NotificationRetrieveContentParams && - id == other.id && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) - - override fun toString() = - "NotificationRetrieveContentParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt deleted file mode 100644 index 171e9dff..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/BaseCheck.kt +++ /dev/null @@ -1,490 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class BaseCheck -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val status: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(id, status, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BaseCheck]. - * - * The following fields are required: - * ```java - * .id() - * .status() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BaseCheck]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var status: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(baseCheck: BaseCheck) = apply { - id = baseCheck.id - status = baseCheck.status - type = baseCheck.type - additionalProperties = baseCheck.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BaseCheck]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .status() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BaseCheck = - BaseCheck( - checkRequired("id", id), - checkRequired("status", status), - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BaseCheck = apply { - if (validated) { - return@apply - } - - id() - status().validate() - type().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val RESOLVED = of("RESOLVED") - - @JvmField val FAILED = of("FAILED") - - @JvmField val PENDING = of("PENDING") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - RESOLVED, - FAILED, - PENDING, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - RESOLVED, - FAILED, - PENDING, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - RESOLVED -> Value.RESOLVED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - RESOLVED -> Known.RESOLVED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CUSTOM = of("custom") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CUSTOM - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CUSTOM, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CUSTOM -> Value.CUSTOM - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CUSTOM -> Known.CUSTOM - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BaseCheck && - id == other.id && - status == other.status && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, status, type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BaseCheck{id=$id, status=$status, type=$type, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt deleted file mode 100644 index e2c20679..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/Check.kt +++ /dev/null @@ -1,280 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class Check -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val status: JsonField, - private val type: JsonField, - private val updated: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), - ) : this(id, status, type, updated, mutableMapOf()) - - fun toBaseCheck(): BaseCheck = BaseCheck.builder().id(id).status(status).type(type).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): BaseCheck.Status = status.getRequired("status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): BaseCheck.Type = type.getRequired("type") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updated(): Long = updated.getRequired("updated") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [updated]. - * - * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Check]. - * - * The following fields are required: - * ```java - * .id() - * .status() - * .type() - * .updated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Check]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var status: JsonField? = null - private var type: JsonField? = null - private var updated: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(check: Check) = apply { - id = check.id - status = check.status - type = check.type - updated = check.updated - additionalProperties = check.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun status(status: BaseCheck.Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [BaseCheck.Status] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun type(type: BaseCheck.Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BaseCheck.Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun updated(updated: Long) = updated(JsonField.of(updated)) - - /** - * Sets [Builder.updated] to an arbitrary JSON value. - * - * You should usually call [Builder.updated] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Check]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .status() - * .type() - * .updated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Check = - Check( - checkRequired("id", id), - checkRequired("status", status), - checkRequired("type", type), - checkRequired("updated", updated), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Check = apply { - if (validated) { - return@apply - } - - id() - status().validate() - type().validate() - updated() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (updated.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Check && - id == other.id && - status == other.status && - type == other.type && - updated == other.updated && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, status, type, updated, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Check{id=$id, status=$status, type=$type, updated=$updated, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt deleted file mode 100644 index e4f88658..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParams.kt +++ /dev/null @@ -1,257 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class CheckDeleteParams -private constructor( - private val id: String, - private val submissionId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun id(): String = id - - fun submissionId(): Optional = Optional.ofNullable(submissionId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CheckDeleteParams]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CheckDeleteParams]. */ - class Builder internal constructor() { - - private var id: String? = null - private var submissionId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(checkDeleteParams: CheckDeleteParams) = apply { - id = checkDeleteParams.id - submissionId = checkDeleteParams.submissionId - additionalHeaders = checkDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = checkDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = checkDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun id(id: String) = apply { this.id = id } - - fun submissionId(submissionId: String?) = apply { this.submissionId = submissionId } - - /** Alias for calling [Builder.submissionId] with `submissionId.orElse(null)`. */ - fun submissionId(submissionId: Optional) = submissionId(submissionId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [CheckDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CheckDeleteParams = - CheckDeleteParams( - checkRequired("id", id), - submissionId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> id - 1 -> submissionId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CheckDeleteParams && - id == other.id && - submissionId == other.submissionId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash( - id, - submissionId, - additionalHeaders, - additionalQueryParams, - additionalBodyProperties, - ) - - override fun toString() = - "CheckDeleteParams{id=$id, submissionId=$submissionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt deleted file mode 100644 index cec93f6b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListParams.kt +++ /dev/null @@ -1,216 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class CheckListParams -private constructor( - private val id: String, - private val submissionId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun id(): String = id - - fun submissionId(): Optional = Optional.ofNullable(submissionId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CheckListParams]. - * - * The following fields are required: - * ```java - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CheckListParams]. */ - class Builder internal constructor() { - - private var id: String? = null - private var submissionId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(checkListParams: CheckListParams) = apply { - id = checkListParams.id - submissionId = checkListParams.submissionId - additionalHeaders = checkListParams.additionalHeaders.toBuilder() - additionalQueryParams = checkListParams.additionalQueryParams.toBuilder() - } - - fun id(id: String) = apply { this.id = id } - - fun submissionId(submissionId: String?) = apply { this.submissionId = submissionId } - - /** Alias for calling [Builder.submissionId] with `submissionId.orElse(null)`. */ - fun submissionId(submissionId: Optional) = submissionId(submissionId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [CheckListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CheckListParams = - CheckListParams( - checkRequired("id", id), - submissionId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> id - 1 -> submissionId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CheckListParams && - id == other.id && - submissionId == other.submissionId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(id, submissionId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "CheckListParams{id=$id, submissionId=$submissionId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt deleted file mode 100644 index b9032b32..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckListResponse.kt +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class CheckListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val checks: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("checks") @ExcludeMissing checks: JsonField> = JsonMissing.of() - ) : this(checks, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun checks(): List = checks.getRequired("checks") - - /** - * Returns the raw JSON value of [checks]. - * - * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): JsonField> = checks - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CheckListResponse]. - * - * The following fields are required: - * ```java - * .checks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CheckListResponse]. */ - class Builder internal constructor() { - - private var checks: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(checkListResponse: CheckListResponse) = apply { - checks = checkListResponse.checks.map { it.toMutableList() } - additionalProperties = checkListResponse.additionalProperties.toMutableMap() - } - - fun checks(checks: List) = checks(JsonField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary JSON value. - * - * You should usually call [Builder.checks] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun checks(checks: JsonField>) = apply { - this.checks = checks.map { it.toMutableList() } - } - - /** - * Adds a single [Check] to [checks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCheck(check: Check) = apply { - checks = - (checks ?: JsonField.of(mutableListOf())).also { - checkKnown("checks", it).add(check) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CheckListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .checks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CheckListResponse = - CheckListResponse( - checkRequired("checks", checks).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CheckListResponse = apply { - if (validated) { - return@apply - } - - checks().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (checks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CheckListResponse && - checks == other.checks && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(checks, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CheckListResponse{checks=$checks, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt deleted file mode 100644 index da33d0cf..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParams.kt +++ /dev/null @@ -1,471 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class CheckUpdateParams -private constructor( - private val id: String, - private val submissionId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun id(): String = id - - fun submissionId(): Optional = Optional.ofNullable(submissionId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun checks(): List = body.checks() - - /** - * Returns the raw JSON value of [checks]. - * - * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _checks(): JsonField> = body._checks() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CheckUpdateParams]. - * - * The following fields are required: - * ```java - * .id() - * .checks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CheckUpdateParams]. */ - class Builder internal constructor() { - - private var id: String? = null - private var submissionId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(checkUpdateParams: CheckUpdateParams) = apply { - id = checkUpdateParams.id - submissionId = checkUpdateParams.submissionId - body = checkUpdateParams.body.toBuilder() - additionalHeaders = checkUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = checkUpdateParams.additionalQueryParams.toBuilder() - } - - fun id(id: String) = apply { this.id = id } - - fun submissionId(submissionId: String?) = apply { this.submissionId = submissionId } - - /** Alias for calling [Builder.submissionId] with `submissionId.orElse(null)`. */ - fun submissionId(submissionId: Optional) = submissionId(submissionId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [checks] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun checks(checks: List) = apply { body.checks(checks) } - - /** - * Sets [Builder.checks] to an arbitrary JSON value. - * - * You should usually call [Builder.checks] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun checks(checks: JsonField>) = apply { body.checks(checks) } - - /** - * Adds a single [BaseCheck] to [checks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCheck(check: BaseCheck) = apply { body.addCheck(check) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [CheckUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .checks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CheckUpdateParams = - CheckUpdateParams( - checkRequired("id", id), - submissionId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> id - 1 -> submissionId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val checks: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("checks") - @ExcludeMissing - checks: JsonField> = JsonMissing.of() - ) : this(checks, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun checks(): List = checks.getRequired("checks") - - /** - * Returns the raw JSON value of [checks]. - * - * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): JsonField> = checks - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .checks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var checks: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - checks = body.checks.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun checks(checks: List) = checks(JsonField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary JSON value. - * - * You should usually call [Builder.checks] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun checks(checks: JsonField>) = apply { - this.checks = checks.map { it.toMutableList() } - } - - /** - * Adds a single [BaseCheck] to [checks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCheck(check: BaseCheck) = apply { - checks = - (checks ?: JsonField.of(mutableListOf())).also { - checkKnown("checks", it).add(check) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .checks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("checks", checks).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - checks().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (checks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - checks == other.checks && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(checks, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{checks=$checks, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CheckUpdateParams && - id == other.id && - submissionId == other.submissionId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(id, submissionId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "CheckUpdateParams{id=$id, submissionId=$submissionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt deleted file mode 100644 index 247b068e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponse.kt +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class CheckUpdateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val checks: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("checks") @ExcludeMissing checks: JsonField> = JsonMissing.of() - ) : this(checks, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun checks(): List = checks.getRequired("checks") - - /** - * Returns the raw JSON value of [checks]. - * - * Unlike [checks], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("checks") @ExcludeMissing fun _checks(): JsonField> = checks - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [CheckUpdateResponse]. - * - * The following fields are required: - * ```java - * .checks() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CheckUpdateResponse]. */ - class Builder internal constructor() { - - private var checks: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(checkUpdateResponse: CheckUpdateResponse) = apply { - checks = checkUpdateResponse.checks.map { it.toMutableList() } - additionalProperties = checkUpdateResponse.additionalProperties.toMutableMap() - } - - fun checks(checks: List) = checks(JsonField.of(checks)) - - /** - * Sets [Builder.checks] to an arbitrary JSON value. - * - * You should usually call [Builder.checks] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun checks(checks: JsonField>) = apply { - this.checks = checks.map { it.toMutableList() } - } - - /** - * Adds a single [Check] to [checks]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCheck(check: Check) = apply { - checks = - (checks ?: JsonField.of(mutableListOf())).also { - checkKnown("checks", it).add(check) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [CheckUpdateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .checks() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): CheckUpdateResponse = - CheckUpdateResponse( - checkRequired("checks", checks).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): CheckUpdateResponse = apply { - if (validated) { - return@apply - } - - checks().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (checks.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CheckUpdateResponse && - checks == other.checks && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(checks, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CheckUpdateResponse{checks=$checks, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt deleted file mode 100644 index 5c43c165..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParams.kt +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.draft - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class DraftRetrieveContentParams -private constructor( - private val id: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun id(): Optional = Optional.ofNullable(id) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): DraftRetrieveContentParams = builder().build() - - /** - * Returns a mutable builder for constructing an instance of [DraftRetrieveContentParams]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DraftRetrieveContentParams]. */ - class Builder internal constructor() { - - private var id: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(draftRetrieveContentParams: DraftRetrieveContentParams) = apply { - id = draftRetrieveContentParams.id - additionalHeaders = draftRetrieveContentParams.additionalHeaders.toBuilder() - additionalQueryParams = draftRetrieveContentParams.additionalQueryParams.toBuilder() - } - - fun id(id: String?) = apply { this.id = id } - - /** Alias for calling [Builder.id] with `id.orElse(null)`. */ - fun id(id: Optional) = id(id.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [DraftRetrieveContentParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): DraftRetrieveContentParams = - DraftRetrieveContentParams(id, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> id ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DraftRetrieveContentParams && - id == other.id && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(id, additionalHeaders, additionalQueryParams) - - override fun toString() = - "DraftRetrieveContentParams{id=$id, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt deleted file mode 100644 index 3152fbfa..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateParams.kt +++ /dev/null @@ -1,534 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Merge the supplied values with an existing profile or create a new profile if one doesn't already - * exist. - */ -class ProfileCreateParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun profile(): Profile = body.profile() - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _profile(): JsonField = body._profile() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProfileCreateParams]. - * - * The following fields are required: - * ```java - * .profile() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileCreateParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(profileCreateParams: ProfileCreateParams) = apply { - userId = profileCreateParams.userId - body = profileCreateParams.body.toBuilder() - additionalHeaders = profileCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = profileCreateParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [profile] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun profile(profile: Profile) = apply { body.profile(profile) } - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { body.profile(profile) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ProfileCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .profile() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProfileCreateParams = - ProfileCreateParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val profile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of() - ) : this(profile, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun profile(): Profile = profile.getRequired("profile") - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .profile() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var profile: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - profile = body.profile - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun profile(profile: Profile) = profile(JsonField.of(profile)) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .profile() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("profile", profile), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - profile().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (profile.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - profile == other.profile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(profile, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{profile=$profile, additionalProperties=$additionalProperties}" - } - - class Profile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Profile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Profile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profile: Profile) = apply { - additionalProperties = profile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Profile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Profile = Profile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Profile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileCreateParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ProfileCreateParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt deleted file mode 100644 index 3fbea25f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileCreateResponse.kt +++ /dev/null @@ -1,291 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ProfileCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() - ) : this(status, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProfileCreateResponse]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileCreateResponse]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profileCreateResponse: ProfileCreateResponse) = apply { - status = profileCreateResponse.status - additionalProperties = profileCreateResponse.additionalProperties.toMutableMap() - } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ProfileCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProfileCreateResponse = - ProfileCreateResponse( - checkRequired("status", status), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ProfileCreateResponse = apply { - if (validated) { - return@apply - } - - status().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SUCCESS = of("SUCCESS") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - SUCCESS - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SUCCESS, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SUCCESS -> Value.SUCCESS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SUCCESS -> Known.SUCCESS - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileCreateResponse && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProfileCreateResponse{status=$status, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt deleted file mode 100644 index 00f0c4ec..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Deletes the specified user profile. */ -class ProfileDeleteParams -private constructor( - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ProfileDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ProfileDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileDeleteParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profileDeleteParams: ProfileDeleteParams) = apply { - userId = profileDeleteParams.userId - additionalHeaders = profileDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = profileDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = profileDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [ProfileDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ProfileDeleteParams = - ProfileDeleteParams( - userId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileDeleteParams && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "ProfileDeleteParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt deleted file mode 100644 index b098e69f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceParams.kt +++ /dev/null @@ -1,536 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * When using `PUT`, be sure to include all the key-value pairs required by the recipient's profile. - * Any key-value pairs that exist in the profile but fail to be included in the `PUT` request will - * be removed from the profile. Remember, a `PUT` update is a full replacement of the data. For - * partial updates, use the [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. - */ -class ProfileReplaceParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun profile(): Profile = body.profile() - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _profile(): JsonField = body._profile() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProfileReplaceParams]. - * - * The following fields are required: - * ```java - * .profile() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileReplaceParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(profileReplaceParams: ProfileReplaceParams) = apply { - userId = profileReplaceParams.userId - body = profileReplaceParams.body.toBuilder() - additionalHeaders = profileReplaceParams.additionalHeaders.toBuilder() - additionalQueryParams = profileReplaceParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [profile] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun profile(profile: Profile) = apply { body.profile(profile) } - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { body.profile(profile) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ProfileReplaceParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .profile() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProfileReplaceParams = - ProfileReplaceParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val profile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of() - ) : this(profile, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun profile(): Profile = profile.getRequired("profile") - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .profile() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var profile: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - profile = body.profile - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun profile(profile: Profile) = profile(JsonField.of(profile)) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .profile() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("profile", profile), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - profile().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (profile.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - profile == other.profile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(profile, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{profile=$profile, additionalProperties=$additionalProperties}" - } - - class Profile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Profile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Profile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profile: Profile) = apply { - additionalProperties = profile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Profile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Profile = Profile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Profile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileReplaceParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ProfileReplaceParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt deleted file mode 100644 index aece92bb..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileReplaceResponse.kt +++ /dev/null @@ -1,291 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ProfileReplaceResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() - ) : this(status, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProfileReplaceResponse]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileReplaceResponse]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profileReplaceResponse: ProfileReplaceResponse) = apply { - status = profileReplaceResponse.status - additionalProperties = profileReplaceResponse.additionalProperties.toMutableMap() - } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ProfileReplaceResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProfileReplaceResponse = - ProfileReplaceResponse( - checkRequired("status", status), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ProfileReplaceResponse = apply { - if (validated) { - return@apply - } - - status().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SUCCESS = of("SUCCESS") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - SUCCESS - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SUCCESS, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SUCCESS -> Value.SUCCESS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SUCCESS -> Known.SUCCESS - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileReplaceResponse && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProfileReplaceResponse{status=$status, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt deleted file mode 100644 index f1473061..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns the specified user profile. */ -class ProfileRetrieveParams -private constructor( - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ProfileRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ProfileRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileRetrieveParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(profileRetrieveParams: ProfileRetrieveParams) = apply { - userId = profileRetrieveParams.userId - additionalHeaders = profileRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = profileRetrieveParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ProfileRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ProfileRetrieveParams = - ProfileRetrieveParams(userId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileRetrieveParams && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(userId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ProfileRetrieveParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt deleted file mode 100644 index 3cad1eaf..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponse.kt +++ /dev/null @@ -1,318 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ProfileRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val profile: JsonField, - private val preferences: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - ) : this(profile, preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun profile(): Profile = profile.getRequired("profile") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProfileRetrieveResponse]. - * - * The following fields are required: - * ```java - * .profile() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileRetrieveResponse]. */ - class Builder internal constructor() { - - private var profile: JsonField? = null - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profileRetrieveResponse: ProfileRetrieveResponse) = apply { - profile = profileRetrieveResponse.profile - preferences = profileRetrieveResponse.preferences - additionalProperties = profileRetrieveResponse.additionalProperties.toMutableMap() - } - - fun profile(profile: Profile) = profile(JsonField.of(profile)) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [RecipientPreferences] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ProfileRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .profile() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProfileRetrieveResponse = - ProfileRetrieveResponse( - checkRequired("profile", profile), - preferences, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ProfileRetrieveResponse = apply { - if (validated) { - return@apply - } - - profile().validate() - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (profile.asKnown().getOrNull()?.validity() ?: 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) - - class Profile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Profile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Profile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profile: Profile) = apply { - additionalProperties = profile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Profile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Profile = Profile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Profile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileRetrieveResponse && - profile == other.profile && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(profile, preferences, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProfileRetrieveResponse{profile=$profile, preferences=$preferences, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt deleted file mode 100644 index bba60512..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/ProfileUpdateParams.kt +++ /dev/null @@ -1,699 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Update a profile */ -class ProfileUpdateParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * List of patch operations to apply to the profile. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun patch(): List = body.patch() - - /** - * Returns the raw JSON value of [patch]. - * - * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _patch(): JsonField> = body._patch() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ProfileUpdateParams]. - * - * The following fields are required: - * ```java - * .patch() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProfileUpdateParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(profileUpdateParams: ProfileUpdateParams) = apply { - userId = profileUpdateParams.userId - body = profileUpdateParams.body.toBuilder() - additionalHeaders = profileUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = profileUpdateParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [patch] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** List of patch operations to apply to the profile. */ - fun patch(patch: List) = apply { body.patch(patch) } - - /** - * Sets [Builder.patch] to an arbitrary JSON value. - * - * You should usually call [Builder.patch] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun patch(patch: JsonField>) = apply { body.patch(patch) } - - /** - * Adds a single [Patch] to [Builder.patch]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPatch(patch: Patch) = apply { body.addPatch(patch) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ProfileUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .patch() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProfileUpdateParams = - ProfileUpdateParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val patch: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("patch") @ExcludeMissing patch: JsonField> = JsonMissing.of() - ) : this(patch, mutableMapOf()) - - /** - * List of patch operations to apply to the profile. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun patch(): List = patch.getRequired("patch") - - /** - * Returns the raw JSON value of [patch]. - * - * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("patch") @ExcludeMissing fun _patch(): JsonField> = patch - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .patch() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var patch: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - patch = body.patch.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** List of patch operations to apply to the profile. */ - fun patch(patch: List) = patch(JsonField.of(patch)) - - /** - * Sets [Builder.patch] to an arbitrary JSON value. - * - * You should usually call [Builder.patch] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun patch(patch: JsonField>) = apply { - this.patch = patch.map { it.toMutableList() } - } - - /** - * Adds a single [Patch] to [Builder.patch]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPatch(patch: Patch) = apply { - this.patch = - (this.patch ?: JsonField.of(mutableListOf())).also { - checkKnown("patch", it).add(patch) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .patch() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("patch", patch).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - patch().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (patch.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - patch == other.patch && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(patch, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{patch=$patch, additionalProperties=$additionalProperties}" - } - - class Patch - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val op: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("op") @ExcludeMissing op: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(op, path, value, mutableMapOf()) - - /** - * The operation to perform. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun op(): String = op.getRequired("op") - - /** - * The JSON path specifying the part of the profile to operate on. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun path(): String = path.getRequired("path") - - /** - * The value for the operation. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [op]. - * - * Unlike [op], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("op") @ExcludeMissing fun _op(): JsonField = op - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Patch]. - * - * The following fields are required: - * ```java - * .op() - * .path() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Patch]. */ - class Builder internal constructor() { - - private var op: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(patch: Patch) = apply { - op = patch.op - path = patch.path - value = patch.value - additionalProperties = patch.additionalProperties.toMutableMap() - } - - /** The operation to perform. */ - fun op(op: String) = op(JsonField.of(op)) - - /** - * Sets [Builder.op] to an arbitrary JSON value. - * - * You should usually call [Builder.op] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun op(op: JsonField) = apply { this.op = op } - - /** The JSON path specifying the part of the profile to operate on. */ - fun path(path: String) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun path(path: JsonField) = apply { this.path = path } - - /** The value for the operation. */ - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Patch]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .op() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Patch = - Patch( - checkRequired("op", op), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Patch = apply { - if (validated) { - return@apply - } - - op() - path() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (op.asKnown().isPresent) 1 else 0) + - (if (path.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Patch && - op == other.op && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(op, path, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Patch{op=$op, path=$path, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProfileUpdateParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ProfileUpdateParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt deleted file mode 100644 index 2ec008a1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Removes all list subscriptions for given user. */ -class ListDeleteParams -private constructor( - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ListDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ListDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListDeleteParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(listDeleteParams: ListDeleteParams) = apply { - userId = listDeleteParams.userId - additionalHeaders = listDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = listDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = listDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [ListDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ListDeleteParams = - ListDeleteParams( - userId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListDeleteParams && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "ListDeleteParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt deleted file mode 100644 index 87e9f656..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponse.kt +++ /dev/null @@ -1,288 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ListDeleteResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() - ) : this(status, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListDeleteResponse]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListDeleteResponse]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(listDeleteResponse: ListDeleteResponse) = apply { - status = listDeleteResponse.status - additionalProperties = listDeleteResponse.additionalProperties.toMutableMap() - } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ListDeleteResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListDeleteResponse = - ListDeleteResponse(checkRequired("status", status), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): ListDeleteResponse = apply { - if (validated) { - return@apply - } - - status().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SUCCESS = of("SUCCESS") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - SUCCESS - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SUCCESS, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SUCCESS -> Value.SUCCESS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SUCCESS -> Known.SUCCESS - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListDeleteResponse && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ListDeleteResponse{status=$status, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt deleted file mode 100644 index 58865be6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParams.kt +++ /dev/null @@ -1,214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns the subscribed lists for a specified user. */ -class ListRetrieveParams -private constructor( - private val userId: String?, - private val cursor: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** A unique identifier that allows for fetching the next set of message statuses. */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): ListRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [ListRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListRetrieveParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var cursor: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(listRetrieveParams: ListRetrieveParams) = apply { - userId = listRetrieveParams.userId - cursor = listRetrieveParams.cursor - additionalHeaders = listRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = listRetrieveParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** A unique identifier that allows for fetching the next set of message statuses. */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ListRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ListRetrieveParams = - ListRetrieveParams( - userId, - cursor, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListRetrieveParams && - userId == other.userId && - cursor == other.cursor && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, cursor, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ListRetrieveParams{userId=$userId, cursor=$cursor, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt deleted file mode 100644 index c9315e95..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponse.kt +++ /dev/null @@ -1,547 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ListRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val paging: JsonField, - private val results: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("results") @ExcludeMissing results: JsonField> = JsonMissing.of(), - ) : this(paging, results, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * An array of lists - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun results(): List = results.getRequired("results") - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - /** - * Returns the raw JSON value of [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListRetrieveResponse]. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListRetrieveResponse]. */ - class Builder internal constructor() { - - private var paging: JsonField? = null - private var results: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(listRetrieveResponse: ListRetrieveResponse) = apply { - paging = listRetrieveResponse.paging - results = listRetrieveResponse.results.map { it.toMutableList() } - additionalProperties = listRetrieveResponse.additionalProperties.toMutableMap() - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - /** An array of lists */ - fun results(results: List) = results(JsonField.of(results)) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ListRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .paging() - * .results() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListRetrieveResponse = - ListRetrieveResponse( - checkRequired("paging", paging), - checkRequired("results", results).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ListRetrieveResponse = apply { - if (validated) { - return@apply - } - - paging().validate() - results().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Result - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val created: JsonField, - private val name: JsonField, - private val updated: JsonField, - private val preferences: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created") @ExcludeMissing created: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("updated") @ExcludeMissing updated: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - ) : this(id, created, name, updated, preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * The date/time of when the list was created. Represented as a string in ISO format. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun created(): String = created.getRequired("created") - - /** - * List name - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * The date/time of when the list was updated. Represented as a string in ISO format. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updated(): String = updated.getRequired("updated") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [created]. - * - * Unlike [created], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created") @ExcludeMissing fun _created(): JsonField = created - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [updated]. - * - * Unlike [updated], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated") @ExcludeMissing fun _updated(): JsonField = updated - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Result]. - * - * The following fields are required: - * ```java - * .id() - * .created() - * .name() - * .updated() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var created: JsonField? = null - private var name: JsonField? = null - private var updated: JsonField? = null - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - id = result.id - created = result.created - name = result.name - updated = result.updated - preferences = result.preferences - additionalProperties = result.additionalProperties.toMutableMap() - } - - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** - * The date/time of when the list was created. Represented as a string in ISO format. - */ - fun created(created: String) = created(JsonField.of(created)) - - /** - * Sets [Builder.created] to an arbitrary JSON value. - * - * You should usually call [Builder.created] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun created(created: JsonField) = apply { this.created = created } - - /** List name */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** - * The date/time of when the list was updated. Represented as a string in ISO format. - */ - fun updated(updated: String) = updated(JsonField.of(updated)) - - /** - * Sets [Builder.updated] to an arbitrary JSON value. - * - * You should usually call [Builder.updated] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updated(updated: JsonField) = apply { this.updated = updated } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .created() - * .name() - * .updated() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Result = - Result( - checkRequired("id", id), - checkRequired("created", created), - checkRequired("name", name), - checkRequired("updated", updated), - preferences, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Result = apply { - if (validated) { - return@apply - } - - id() - created() - name() - updated() - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (created.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (updated.asKnown().isPresent) 1 else 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && - id == other.id && - created == other.created && - name == other.name && - updated == other.updated && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, created, name, updated, preferences, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Result{id=$id, created=$created, name=$name, updated=$updated, preferences=$preferences, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListRetrieveResponse && - paging == other.paging && - results == other.results && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(paging, results, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ListRetrieveResponse{paging=$paging, results=$results, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt deleted file mode 100644 index b8ae717f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParams.kt +++ /dev/null @@ -1,664 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Subscribes the given user to one or more lists. If the list does not exist, it will be created. - */ -class ListSubscribeParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lists(): List = body.lists() - - /** - * Returns the raw JSON value of [lists]. - * - * Unlike [lists], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _lists(): JsonField> = body._lists() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListSubscribeParams]. - * - * The following fields are required: - * ```java - * .lists() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListSubscribeParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(listSubscribeParams: ListSubscribeParams) = apply { - userId = listSubscribeParams.userId - body = listSubscribeParams.body.toBuilder() - additionalHeaders = listSubscribeParams.additionalHeaders.toBuilder() - additionalQueryParams = listSubscribeParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [lists] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun lists(lists: List) = apply { body.lists(lists) } - - /** - * Sets [Builder.lists] to an arbitrary JSON value. - * - * You should usually call [Builder.lists] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun lists(lists: JsonField>) = apply { body.lists(lists) } - - /** - * Adds a single [List] to [lists]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addList(list: List) = apply { body.addList(list) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ListSubscribeParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .lists() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListSubscribeParams = - ListSubscribeParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val lists: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("lists") @ExcludeMissing lists: JsonField> = JsonMissing.of() - ) : this(lists, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun lists(): List = lists.getRequired("lists") - - /** - * Returns the raw JSON value of [lists]. - * - * Unlike [lists], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lists") @ExcludeMissing fun _lists(): JsonField> = lists - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .lists() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var lists: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - lists = body.lists.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun lists(lists: List) = lists(JsonField.of(lists)) - - /** - * Sets [Builder.lists] to an arbitrary JSON value. - * - * You should usually call [Builder.lists] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun lists(lists: JsonField>) = apply { - this.lists = lists.map { it.toMutableList() } - } - - /** - * Adds a single [List] to [lists]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addList(list: List) = apply { - lists = - (lists ?: JsonField.of(mutableListOf())).also { - checkKnown("lists", it).add(list) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .lists() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("lists", lists).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - lists().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (lists.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - lists == other.lists && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(lists, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{lists=$lists, additionalProperties=$additionalProperties}" - } - - class List - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val listId: JsonField, - private val preferences: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("listId") @ExcludeMissing listId: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - ) : this(listId, preferences, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun listId(): String = listId.getRequired("listId") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * Returns the raw JSON value of [listId]. - * - * Unlike [listId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("listId") @ExcludeMissing fun _listId(): JsonField = listId - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [List]. - * - * The following fields are required: - * ```java - * .listId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [List]. */ - class Builder internal constructor() { - - private var listId: JsonField? = null - private var preferences: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(list: List) = apply { - listId = list.listId - preferences = list.preferences - additionalProperties = list.additionalProperties.toMutableMap() - } - - fun listId(listId: String) = listId(JsonField.of(listId)) - - /** - * Sets [Builder.listId] to an arbitrary JSON value. - * - * You should usually call [Builder.listId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun listId(listId: JsonField) = apply { this.listId = listId } - - fun preferences(preferences: RecipientPreferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [RecipientPreferences] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [List]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .listId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): List = - List( - checkRequired("listId", listId), - preferences, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): List = apply { - if (validated) { - return@apply - } - - listId() - preferences().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (listId.asKnown().isPresent) 1 else 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is List && - listId == other.listId && - preferences == other.preferences && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(listId, preferences, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "List{listId=$listId, preferences=$preferences, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListSubscribeParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "ListSubscribeParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt deleted file mode 100644 index 63337ea9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponse.kt +++ /dev/null @@ -1,291 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ListSubscribeResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of() - ) : this(status, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ListSubscribeResponse]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ListSubscribeResponse]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(listSubscribeResponse: ListSubscribeResponse) = apply { - status = listSubscribeResponse.status - additionalProperties = listSubscribeResponse.additionalProperties.toMutableMap() - } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ListSubscribeResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ListSubscribeResponse = - ListSubscribeResponse( - checkRequired("status", status), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ListSubscribeResponse = apply { - if (validated) { - return@apply - } - - status().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (status.asKnown().getOrNull()?.validity() ?: 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SUCCESS = of("SUCCESS") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - SUCCESS - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SUCCESS, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SUCCESS -> Value.SUCCESS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SUCCESS -> Known.SUCCESS - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ListSubscribeResponse && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(status, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ListSubscribeResponse{status=$status, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt deleted file mode 100644 index 7a8d7632..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/requests/RequestArchiveParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.requests - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Archive message */ -class RequestArchiveParams -private constructor( - private val requestId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun requestId(): Optional = Optional.ofNullable(requestId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): RequestArchiveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [RequestArchiveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RequestArchiveParams]. */ - class Builder internal constructor() { - - private var requestId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(requestArchiveParams: RequestArchiveParams) = apply { - requestId = requestArchiveParams.requestId - additionalHeaders = requestArchiveParams.additionalHeaders.toBuilder() - additionalQueryParams = requestArchiveParams.additionalQueryParams.toBuilder() - additionalBodyProperties = requestArchiveParams.additionalBodyProperties.toMutableMap() - } - - fun requestId(requestId: String?) = apply { this.requestId = requestId } - - /** Alias for calling [Builder.requestId] with `requestId.orElse(null)`. */ - fun requestId(requestId: Optional) = requestId(requestId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [RequestArchiveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RequestArchiveParams = - RequestArchiveParams( - requestId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> requestId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RequestArchiveParams && - requestId == other.requestId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(requestId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "RequestArchiveParams{requestId=$requestId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt deleted file mode 100644 index 68e71844..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessage.kt +++ /dev/null @@ -1,3017 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.notifications.MessageRouting -import com.courier.api.models.notifications.MessageRoutingChannel -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BaseMessage -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val brandId: JsonField, - private val channels: JsonField, - private val context: JsonField, - private val data: JsonField, - private val delay: JsonField, - private val expiry: JsonField, - private val metadata: JsonField, - private val preferences: JsonField, - private val providers: JsonField, - private val routing: JsonField, - private val timeout: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), - @JsonProperty("channels") @ExcludeMissing channels: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - context: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("delay") @ExcludeMissing delay: JsonField = JsonMissing.of(), - @JsonProperty("expiry") @ExcludeMissing expiry: JsonField = JsonMissing.of(), - @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField = JsonMissing.of(), - @JsonProperty("routing") @ExcludeMissing routing: JsonField = JsonMissing.of(), - @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), - ) : this( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - mutableMapOf(), - ) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * "Define run-time configuration for one or more channels. If you don't specify channels, the - * default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, - * inbox, direct_message, banner, and webhook." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional = channels.getOptional("channels") - - /** - * Context to load with this recipient. Will override any context set on message.context. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * An arbitrary object that includes any data you want to pass to the message. The data will - * populate the corresponding template or elements variables. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * Defines the time to wait before delivering the message. You can specify one of the following - * options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp - * that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like - * format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun delay(): Optional = delay.getOptional("delay") - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. Note: This - * is only valid for the Courier Inbox channel as of 12-08-2022." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiry(): Optional = expiry.getOptional("expiry") - - /** - * Metadata such as utm tracking attached with the notification through this channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = preferences.getOptional("preferences") - - /** - * An object whose keys are valid provider identifiers which map to an object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun providers(): Optional = providers.getOptional("providers") - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the message. If no - * routing key is specified, Courier will use the default routing configuration or routing - * defined by the template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun routing(): Optional = routing.getOptional("routing") - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun timeout(): Optional = timeout.getOptional("timeout") - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField = channels - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [delay]. - * - * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay - - /** - * Returns the raw JSON value of [expiry]. - * - * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry") @ExcludeMissing fun _expiry(): JsonField = expiry - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("providers") @ExcludeMissing fun _providers(): JsonField = providers - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") @ExcludeMissing fun _routing(): JsonField = routing - - /** - * Returns the raw JSON value of [timeout]. - * - * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BaseMessage]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BaseMessage]. */ - class Builder internal constructor() { - - private var brandId: JsonField = JsonMissing.of() - private var channels: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var delay: JsonField = JsonMissing.of() - private var expiry: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var providers: JsonField = JsonMissing.of() - private var routing: JsonField = JsonMissing.of() - private var timeout: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(baseMessage: BaseMessage) = apply { - brandId = baseMessage.brandId - channels = baseMessage.channels - context = baseMessage.context - data = baseMessage.data - delay = baseMessage.delay - expiry = baseMessage.expiry - metadata = baseMessage.metadata - preferences = baseMessage.preferences - providers = baseMessage.providers - routing = baseMessage.routing - timeout = baseMessage.timeout - additionalProperties = baseMessage.additionalProperties.toMutableMap() - } - - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * "Define run-time configuration for one or more channels. If you don't specify channels, - * the default configuration for each channel will be used. Valid ChannelId's are: email, - * sms, push, inbox, direct_message, banner, and webhook." - */ - fun channels(channels: Channels?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed [Channels] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun channels(channels: JsonField) = apply { this.channels = channels } - - /** - * Context to load with this recipient. Will override any context set on message.context. - */ - fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [MessageContext] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - /** - * An arbitrary object that includes any data you want to pass to the message. The data will - * populate the corresponding template or elements variables. - */ - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an ISO - * 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap - * opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - fun delay(delay: Delay?) = delay(JsonField.ofNullable(delay)) - - /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ - fun delay(delay: Optional) = delay(delay.getOrNull()) - - /** - * Sets [Builder.delay] to an arbitrary JSON value. - * - * You should usually call [Builder.delay] with a well-typed [Delay] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun delay(delay: JsonField) = apply { this.delay = delay } - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. Note: - * This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - fun expiry(expiry: Expiry?) = expiry(JsonField.ofNullable(expiry)) - - /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ - fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) - - /** - * Sets [Builder.expiry] to an arbitrary JSON value. - * - * You should usually call [Builder.expiry] with a well-typed [Expiry] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun expiry(expiry: JsonField) = apply { this.expiry = expiry } - - /** Metadata such as utm tracking attached with the notification through this channel. */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun preferences(preferences: Preferences?) = preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed [Preferences] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** An object whose keys are valid provider identifiers which map to an object. */ - fun providers(providers: Providers?) = providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional) = providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed [Providers] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun providers(providers: JsonField) = apply { this.providers = providers } - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the message. If - * no routing key is specified, Courier will use the default routing configuration or - * routing defined by the template. - */ - fun routing(routing: Routing?) = routing(JsonField.ofNullable(routing)) - - /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ - fun routing(routing: Optional) = routing(routing.getOrNull()) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [Routing] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun routing(routing: JsonField) = apply { this.routing = routing } - - /** Time in ms to attempt the channel before failing over to the next available channel. */ - fun timeout(timeout: Timeout?) = timeout(JsonField.ofNullable(timeout)) - - /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ - fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) - - /** - * Sets [Builder.timeout] to an arbitrary JSON value. - * - * You should usually call [Builder.timeout] with a well-typed [Timeout] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun timeout(timeout: JsonField) = apply { this.timeout = timeout } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BaseMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BaseMessage = - BaseMessage( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BaseMessage = apply { - if (validated) { - return@apply - } - - brandId() - channels().ifPresent { it.validate() } - context().ifPresent { it.validate() } - data().ifPresent { it.validate() } - delay().ifPresent { it.validate() } - expiry().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - preferences().ifPresent { it.validate() } - providers().ifPresent { it.validate() } - routing().ifPresent { it.validate() } - timeout().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brandId.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.validity() ?: 0) + - (context.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (delay.asKnown().getOrNull()?.validity() ?: 0) + - (expiry.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.validity() ?: 0) + - (routing.asKnown().getOrNull()?.validity() ?: 0) + - (timeout.asKnown().getOrNull()?.validity() ?: 0) - - /** - * "Define run-time configuration for one or more channels. If you don't specify channels, the - * default configuration for each channel will be used. Valid ChannelId's are: email, sms, push, - * inbox, direct_message, banner, and webhook." - */ - class Channels - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Channels]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Channels]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(channels: Channels) = apply { - additionalProperties = channels.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Channels]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Channels = Channels(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Channels = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Channels && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Channels{additionalProperties=$additionalProperties}" - } - - /** - * An arbitrary object that includes any data you want to pass to the message. The data will - * populate the corresponding template or elements variables. - */ - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - /** - * Defines the time to wait before delivering the message. You can specify one of the following - * options. Duration with the number of milliseconds to delay. Until with an ISO 8601 timestamp - * that specifies when it should be delivered. Until with an OpenStreetMap opening_hours-like - * format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - class Delay - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val duration: JsonField, - private val until: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), - @JsonProperty("until") @ExcludeMissing until: JsonField = JsonMissing.of(), - ) : this(duration, until, mutableMapOf()) - - /** - * The duration of the delay in milliseconds. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun duration(): Optional = duration.getOptional("duration") - - /** - * An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap - * opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun until(): Optional = until.getOptional("until") - - /** - * Returns the raw JSON value of [duration]. - * - * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - - /** - * Returns the raw JSON value of [until]. - * - * Unlike [until], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Delay]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Delay]. */ - class Builder internal constructor() { - - private var duration: JsonField = JsonMissing.of() - private var until: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(delay: Delay) = apply { - duration = delay.duration - until = delay.until - additionalProperties = delay.additionalProperties.toMutableMap() - } - - /** The duration of the delay in milliseconds. */ - fun duration(duration: Long?) = duration(JsonField.ofNullable(duration)) - - /** - * Alias for [Builder.duration]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun duration(duration: Long) = duration(duration as Long?) - - /** Alias for calling [Builder.duration] with `duration.orElse(null)`. */ - fun duration(duration: Optional) = duration(duration.getOrNull()) - - /** - * Sets [Builder.duration] to an arbitrary JSON value. - * - * You should usually call [Builder.duration] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun duration(duration: JsonField) = apply { this.duration = duration } - - /** - * An ISO 8601 timestamp that specifies when it should be delivered or an OpenStreetMap - * opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - fun until(until: String?) = until(JsonField.ofNullable(until)) - - /** Alias for calling [Builder.until] with `until.orElse(null)`. */ - fun until(until: Optional) = until(until.getOrNull()) - - /** - * Sets [Builder.until] to an arbitrary JSON value. - * - * You should usually call [Builder.until] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun until(until: JsonField) = apply { this.until = until } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Delay]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Delay = Delay(duration, until, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Delay = apply { - if (validated) { - return@apply - } - - duration() - until() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (duration.asKnown().isPresent) 1 else 0) + (if (until.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Delay && - duration == other.duration && - until == other.until && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(duration, until, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Delay{duration=$duration, until=$until, additionalProperties=$additionalProperties}" - } - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. Note: This - * is only valid for the Courier Inbox channel as of 12-08-2022." - */ - class Expiry - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val expiresIn: JsonField, - private val expiresAt: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("expires_in") - @ExcludeMissing - expiresIn: JsonField = JsonMissing.of(), - @JsonProperty("expires_at") - @ExcludeMissing - expiresAt: JsonField = JsonMissing.of(), - ) : this(expiresIn, expiresAt, mutableMapOf()) - - /** - * A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun expiresIn(): ExpiresIn = expiresIn.getRequired("expires_in") - - /** - * An epoch timestamp or ISO8601 timestamp with timezone `(YYYY-MM-DDThh:mm:ss.sTZD)` that - * describes the time in which a message expires. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiresAt(): Optional = expiresAt.getOptional("expires_at") - - /** - * Returns the raw JSON value of [expiresIn]. - * - * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expires_in") - @ExcludeMissing - fun _expiresIn(): JsonField = expiresIn - - /** - * Returns the raw JSON value of [expiresAt]. - * - * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expires_at") @ExcludeMissing fun _expiresAt(): JsonField = expiresAt - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Expiry]. - * - * The following fields are required: - * ```java - * .expiresIn() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Expiry]. */ - class Builder internal constructor() { - - private var expiresIn: JsonField? = null - private var expiresAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(expiry: Expiry) = apply { - expiresIn = expiry.expiresIn - expiresAt = expiry.expiresAt - additionalProperties = expiry.additionalProperties.toMutableMap() - } - - /** - * A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). - */ - fun expiresIn(expiresIn: ExpiresIn) = expiresIn(JsonField.of(expiresIn)) - - /** - * Sets [Builder.expiresIn] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresIn] with a well-typed [ExpiresIn] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } - - /** Alias for calling [expiresIn] with `ExpiresIn.ofString(string)`. */ - fun expiresIn(string: String) = expiresIn(ExpiresIn.ofString(string)) - - /** Alias for calling [expiresIn] with `ExpiresIn.ofInteger(integer)`. */ - fun expiresIn(integer: Long) = expiresIn(ExpiresIn.ofInteger(integer)) - - /** - * An epoch timestamp or ISO8601 timestamp with timezone `(YYYY-MM-DDThh:mm:ss.sTZD)` - * that describes the time in which a message expires. - */ - fun expiresAt(expiresAt: String?) = expiresAt(JsonField.ofNullable(expiresAt)) - - /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ - fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) - - /** - * Sets [Builder.expiresAt] to an arbitrary JSON value. - * - * You should usually call [Builder.expiresAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Expiry]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .expiresIn() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Expiry = - Expiry( - checkRequired("expiresIn", expiresIn), - expiresAt, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Expiry = apply { - if (validated) { - return@apply - } - - expiresIn().validate() - expiresAt() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (expiresIn.asKnown().getOrNull()?.validity() ?: 0) + - (if (expiresAt.asKnown().isPresent) 1 else 0) - - /** A duration in the form of milliseconds or an ISO8601 Duration format (i.e. P1DT4H). */ - @JsonDeserialize(using = ExpiresIn.Deserializer::class) - @JsonSerialize(using = ExpiresIn.Serializer::class) - class ExpiresIn - private constructor( - private val string: String? = null, - private val integer: Long? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun integer(): Optional = Optional.ofNullable(integer) - - fun isString(): Boolean = string != null - - fun isInteger(): Boolean = integer != null - - fun asString(): String = string.getOrThrow("string") - - fun asInteger(): Long = integer.getOrThrow("integer") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - integer != null -> visitor.visitInteger(integer) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ExpiresIn = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitInteger(integer: Long) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitInteger(integer: Long) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExpiresIn && string == other.string && integer == other.integer - } - - override fun hashCode(): Int = Objects.hash(string, integer) - - override fun toString(): String = - when { - string != null -> "ExpiresIn{string=$string}" - integer != null -> "ExpiresIn{integer=$integer}" - _json != null -> "ExpiresIn{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ExpiresIn") - } - - companion object { - - @JvmStatic fun ofString(string: String) = ExpiresIn(string = string) - - @JvmStatic fun ofInteger(integer: Long) = ExpiresIn(integer = integer) - } - - /** - * An interface that defines how to map each variant of [ExpiresIn] to a value of type - * [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitInteger(integer: Long): T - - /** - * Maps an unknown variant of [ExpiresIn] to a value of type [T]. - * - * An instance of [ExpiresIn] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown ExpiresIn: $json") - } - } - - internal class Deserializer : BaseDeserializer(ExpiresIn::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ExpiresIn { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - ExpiresIn(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ExpiresIn(integer = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> ExpiresIn(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ExpiresIn::class) { - - override fun serialize( - value: ExpiresIn, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.integer != null -> generator.writeObject(value.integer) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ExpiresIn") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Expiry && - expiresIn == other.expiresIn && - expiresAt == other.expiresAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(expiresIn, expiresAt, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Expiry{expiresIn=$expiresIn, expiresAt=$expiresAt, additionalProperties=$additionalProperties}" - } - - /** Metadata such as utm tracking attached with the notification through this channel. */ - class Metadata - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val event: JsonField, - private val tags: JsonField>, - private val traceId: JsonField, - private val utm: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), - @JsonProperty("tags") @ExcludeMissing tags: JsonField> = JsonMissing.of(), - @JsonProperty("trace_id") @ExcludeMissing traceId: JsonField = JsonMissing.of(), - @JsonProperty("utm") @ExcludeMissing utm: JsonField = JsonMissing.of(), - ) : this(event, tags, traceId, utm, mutableMapOf()) - - /** - * An arbitrary string to tracks the event that generated this request (e.g. 'signup'). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun event(): Optional = event.getOptional("event") - - /** - * An array of up to 9 tags you wish to associate with this request (and corresponding - * messages) for later analysis. Individual tags cannot be more than 30 characters in - * length. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tags(): Optional> = tags.getOptional("tags") - - /** - * A unique ID used to correlate this request to processing on your servers. Note: Courier - * does not verify the uniqueness of this ID. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun traceId(): Optional = traceId.getOptional("trace_id") - - /** - * Identify the campaign that refers traffic to a specific website, and attributes the - * browser's website session. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun utm(): Optional = utm.getOptional("utm") - - /** - * Returns the raw JSON value of [event]. - * - * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event - - /** - * Returns the raw JSON value of [tags]. - * - * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags - - /** - * Returns the raw JSON value of [traceId]. - * - * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField = traceId - - /** - * Returns the raw JSON value of [utm]. - * - * Unlike [utm], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("utm") @ExcludeMissing fun _utm(): JsonField = utm - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var event: JsonField = JsonMissing.of() - private var tags: JsonField>? = null - private var traceId: JsonField = JsonMissing.of() - private var utm: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - event = metadata.event - tags = metadata.tags.map { it.toMutableList() } - traceId = metadata.traceId - utm = metadata.utm - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * An arbitrary string to tracks the event that generated this request (e.g. 'signup'). - */ - fun event(event: String?) = event(JsonField.ofNullable(event)) - - /** Alias for calling [Builder.event] with `event.orElse(null)`. */ - fun event(event: Optional) = event(event.getOrNull()) - - /** - * Sets [Builder.event] to an arbitrary JSON value. - * - * You should usually call [Builder.event] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun event(event: JsonField) = apply { this.event = event } - - /** - * An array of up to 9 tags you wish to associate with this request (and corresponding - * messages) for later analysis. Individual tags cannot be more than 30 characters in - * length. - */ - fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) - - /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ - fun tags(tags: Optional>) = tags(tags.getOrNull()) - - /** - * Sets [Builder.tags] to an arbitrary JSON value. - * - * You should usually call [Builder.tags] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tags(tags: JsonField>) = apply { - this.tags = tags.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [tags]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTag(tag: String) = apply { - tags = - (tags ?: JsonField.of(mutableListOf())).also { checkKnown("tags", it).add(tag) } - } - - /** - * A unique ID used to correlate this request to processing on your servers. Note: - * Courier does not verify the uniqueness of this ID. - */ - fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) - - /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ - fun traceId(traceId: Optional) = traceId(traceId.getOrNull()) - - /** - * Sets [Builder.traceId] to an arbitrary JSON value. - * - * You should usually call [Builder.traceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun traceId(traceId: JsonField) = apply { this.traceId = traceId } - - /** - * Identify the campaign that refers traffic to a specific website, and attributes the - * browser's website session. - */ - fun utm(utm: Utm?) = utm(JsonField.ofNullable(utm)) - - /** Alias for calling [Builder.utm] with `utm.orElse(null)`. */ - fun utm(utm: Optional) = utm(utm.getOrNull()) - - /** - * Sets [Builder.utm] to an arbitrary JSON value. - * - * You should usually call [Builder.utm] with a well-typed [Utm] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun utm(utm: JsonField) = apply { this.utm = utm } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = - Metadata( - event, - (tags ?: JsonMissing.of()).map { it.toImmutable() }, - traceId, - utm, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - event() - tags() - traceId() - utm().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (event.asKnown().isPresent) 1 else 0) + - (tags.asKnown().getOrNull()?.size ?: 0) + - (if (traceId.asKnown().isPresent) 1 else 0) + - (utm.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Metadata && - event == other.event && - tags == other.tags && - traceId == other.traceId && - utm == other.utm && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(event, tags, traceId, utm, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{event=$event, tags=$tags, traceId=$traceId, utm=$utm, additionalProperties=$additionalProperties}" - } - - class Preferences - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val subscriptionTopicId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("subscription_topic_id") - @ExcludeMissing - subscriptionTopicId: JsonField = JsonMissing.of() - ) : this(subscriptionTopicId, mutableMapOf()) - - /** - * The ID of the subscription topic you want to apply to the message. If this is a templated - * message, it will override the subscription topic if already associated - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun subscriptionTopicId(): String = subscriptionTopicId.getRequired("subscription_topic_id") - - /** - * Returns the raw JSON value of [subscriptionTopicId]. - * - * Unlike [subscriptionTopicId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("subscription_topic_id") - @ExcludeMissing - fun _subscriptionTopicId(): JsonField = subscriptionTopicId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Preferences]. - * - * The following fields are required: - * ```java - * .subscriptionTopicId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Preferences]. */ - class Builder internal constructor() { - - private var subscriptionTopicId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(preferences: Preferences) = apply { - subscriptionTopicId = preferences.subscriptionTopicId - additionalProperties = preferences.additionalProperties.toMutableMap() - } - - /** - * The ID of the subscription topic you want to apply to the message. If this is a - * templated message, it will override the subscription topic if already associated - */ - fun subscriptionTopicId(subscriptionTopicId: String) = - subscriptionTopicId(JsonField.of(subscriptionTopicId)) - - /** - * Sets [Builder.subscriptionTopicId] to an arbitrary JSON value. - * - * You should usually call [Builder.subscriptionTopicId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun subscriptionTopicId(subscriptionTopicId: JsonField) = apply { - this.subscriptionTopicId = subscriptionTopicId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Preferences]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .subscriptionTopicId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Preferences = - Preferences( - checkRequired("subscriptionTopicId", subscriptionTopicId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Preferences = apply { - if (validated) { - return@apply - } - - subscriptionTopicId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (if (subscriptionTopicId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Preferences && - subscriptionTopicId == other.subscriptionTopicId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(subscriptionTopicId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Preferences{subscriptionTopicId=$subscriptionTopicId, additionalProperties=$additionalProperties}" - } - - /** An object whose keys are valid provider identifiers which map to an object. */ - class Providers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Providers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Providers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(providers: Providers) = apply { - additionalProperties = providers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Providers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Providers = Providers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Providers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Providers && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Providers{additionalProperties=$additionalProperties}" - } - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the message. If no - * routing key is specified, Courier will use the default routing configuration or routing - * defined by the template. - */ - class Routing - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val method: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), - ) : this(channels, method, mutableMapOf()) - - /** - * A list of channels or providers to send the message through. Can also recursively define - * sub-routing methods, which can be useful for defining advanced push notification delivery - * strategies. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channels(): List = channels.getRequired("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun method(): Method = method.getRequired("method") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [method]. - * - * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Routing]. - * - * The following fields are required: - * ```java - * .channels() - * .method() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Routing]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var method: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(routing: Routing) = apply { - channels = routing.channels.map { it.toMutableList() } - method = routing.method - additionalProperties = routing.additionalProperties.toMutableMap() - } - - /** - * A list of channels or providers to send the message through. Can also recursively - * define sub-routing methods, which can be useful for defining advanced push - * notification delivery strategies. - */ - fun channels(channels: List) = channels(JsonField.of(channels)) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [MessageRoutingChannel] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: MessageRoutingChannel) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** Alias for calling [addChannel] with `MessageRoutingChannel.ofString(string)`. */ - fun addChannel(string: String) = addChannel(MessageRoutingChannel.ofString(string)) - - /** - * Alias for calling [addChannel] with - * `MessageRoutingChannel.ofMessageRouting(messageRouting)`. - */ - fun addChannel(messageRouting: MessageRouting) = - addChannel(MessageRoutingChannel.ofMessageRouting(messageRouting)) - - fun method(method: Method) = method(JsonField.of(method)) - - /** - * Sets [Builder.method] to an arbitrary JSON value. - * - * You should usually call [Builder.method] with a well-typed [Method] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun method(method: JsonField) = apply { this.method = method } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Routing]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channels() - * .method() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Routing = - Routing( - checkRequired("channels", channels).map { it.toImmutable() }, - checkRequired("method", method), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Routing = apply { - if (validated) { - return@apply - } - - channels().forEach { it.validate() } - method().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (method.asKnown().getOrNull()?.validity() ?: 0) - - class Method @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ALL = of("all") - - @JvmField val SINGLE = of("single") - - @JvmStatic fun of(value: String) = Method(JsonField.of(value)) - } - - /** An enum containing [Method]'s known values. */ - enum class Known { - ALL, - SINGLE, - } - - /** - * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Method] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ALL, - SINGLE, - /** - * An enum member indicating that [Method] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ALL -> Value.ALL - SINGLE -> Value.SINGLE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ALL -> Known.ALL - SINGLE -> Known.SINGLE - else -> throw CourierInvalidDataException("Unknown Method: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Method = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Method && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Routing && - channels == other.channels && - method == other.method && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(channels, method, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Routing{channels=$channels, method=$method, additionalProperties=$additionalProperties}" - } - - /** Time in ms to attempt the channel before failing over to the next available channel. */ - class Timeout - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channel: JsonField, - private val criteria: JsonField, - private val escalation: JsonField, - private val message: JsonField, - private val provider: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("criteria") - @ExcludeMissing - criteria: JsonField = JsonMissing.of(), - @JsonProperty("escalation") - @ExcludeMissing - escalation: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("provider") - @ExcludeMissing - provider: JsonField = JsonMissing.of(), - ) : this(channel, criteria, escalation, message, provider, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channel(): Optional = channel.getOptional("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun criteria(): Optional = criteria.getOptional("criteria") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun escalation(): Optional = escalation.getOptional("escalation") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun message(): Optional = message.getOptional("message") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun provider(): Optional = provider.getOptional("provider") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [criteria]. - * - * Unlike [criteria], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("criteria") @ExcludeMissing fun _criteria(): JsonField = criteria - - /** - * Returns the raw JSON value of [escalation]. - * - * Unlike [escalation], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("escalation") @ExcludeMissing fun _escalation(): JsonField = escalation - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - /** - * Returns the raw JSON value of [provider]. - * - * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Timeout]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Timeout]. */ - class Builder internal constructor() { - - private var channel: JsonField = JsonMissing.of() - private var criteria: JsonField = JsonMissing.of() - private var escalation: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var provider: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(timeout: Timeout) = apply { - channel = timeout.channel - criteria = timeout.criteria - escalation = timeout.escalation - message = timeout.message - provider = timeout.provider - additionalProperties = timeout.additionalProperties.toMutableMap() - } - - fun channel(channel: Channel?) = channel(JsonField.ofNullable(channel)) - - /** Alias for calling [Builder.channel] with `channel.orElse(null)`. */ - fun channel(channel: Optional) = channel(channel.getOrNull()) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [Channel] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun criteria(criteria: Criteria?) = criteria(JsonField.ofNullable(criteria)) - - /** Alias for calling [Builder.criteria] with `criteria.orElse(null)`. */ - fun criteria(criteria: Optional) = criteria(criteria.getOrNull()) - - /** - * Sets [Builder.criteria] to an arbitrary JSON value. - * - * You should usually call [Builder.criteria] with a well-typed [Criteria] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun criteria(criteria: JsonField) = apply { this.criteria = criteria } - - fun escalation(escalation: Long?) = escalation(JsonField.ofNullable(escalation)) - - /** - * Alias for [Builder.escalation]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun escalation(escalation: Long) = escalation(escalation as Long?) - - /** Alias for calling [Builder.escalation] with `escalation.orElse(null)`. */ - fun escalation(escalation: Optional) = escalation(escalation.getOrNull()) - - /** - * Sets [Builder.escalation] to an arbitrary JSON value. - * - * You should usually call [Builder.escalation] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun escalation(escalation: JsonField) = apply { this.escalation = escalation } - - fun message(message: Long?) = message(JsonField.ofNullable(message)) - - /** - * Alias for [Builder.message]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun message(message: Long) = message(message as Long?) - - /** Alias for calling [Builder.message] with `message.orElse(null)`. */ - fun message(message: Optional) = message(message.getOrNull()) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - fun provider(provider: Provider?) = provider(JsonField.ofNullable(provider)) - - /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ - fun provider(provider: Optional) = provider(provider.getOrNull()) - - /** - * Sets [Builder.provider] to an arbitrary JSON value. - * - * You should usually call [Builder.provider] with a well-typed [Provider] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun provider(provider: JsonField) = apply { this.provider = provider } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Timeout]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Timeout = - Timeout( - channel, - criteria, - escalation, - message, - provider, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Timeout = apply { - if (validated) { - return@apply - } - - channel().ifPresent { it.validate() } - criteria().ifPresent { it.validate() } - escalation() - message() - provider().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channel.asKnown().getOrNull()?.validity() ?: 0) + - (criteria.asKnown().getOrNull()?.validity() ?: 0) + - (if (escalation.asKnown().isPresent) 1 else 0) + - (if (message.asKnown().isPresent) 1 else 0) + - (provider.asKnown().getOrNull()?.validity() ?: 0) - - class Channel - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Channel]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Channel]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(channel: Channel) = apply { - additionalProperties = channel.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Channel]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Channel = Channel(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Channel = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Channel && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Channel{additionalProperties=$additionalProperties}" - } - - class Criteria @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val NO_ESCALATION = of("no-escalation") - - @JvmField val DELIVERED = of("delivered") - - @JvmField val VIEWED = of("viewed") - - @JvmField val ENGAGED = of("engaged") - - @JvmStatic fun of(value: String) = Criteria(JsonField.of(value)) - } - - /** An enum containing [Criteria]'s known values. */ - enum class Known { - NO_ESCALATION, - DELIVERED, - VIEWED, - ENGAGED, - } - - /** - * An enum containing [Criteria]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Criteria] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NO_ESCALATION, - DELIVERED, - VIEWED, - ENGAGED, - /** - * An enum member indicating that [Criteria] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NO_ESCALATION -> Value.NO_ESCALATION - DELIVERED -> Value.DELIVERED - VIEWED -> Value.VIEWED - ENGAGED -> Value.ENGAGED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NO_ESCALATION -> Known.NO_ESCALATION - DELIVERED -> Known.DELIVERED - VIEWED -> Known.VIEWED - ENGAGED -> Known.ENGAGED - else -> throw CourierInvalidDataException("Unknown Criteria: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Criteria = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Criteria && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Provider - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Provider]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Provider]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(provider: Provider) = apply { - additionalProperties = provider.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Provider]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Provider = Provider(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Provider = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Provider && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Provider{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Timeout && - channel == other.channel && - criteria == other.criteria && - escalation == other.escalation && - message == other.message && - provider == other.provider && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channel, criteria, escalation, message, provider, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Timeout{channel=$channel, criteria=$criteria, escalation=$escalation, message=$message, provider=$provider, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BaseMessage && - brandId == other.brandId && - channels == other.channels && - context == other.context && - data == other.data && - delay == other.delay && - expiry == other.expiry && - metadata == other.metadata && - preferences == other.preferences && - providers == other.providers && - routing == other.routing && - timeout == other.timeout && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BaseMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt deleted file mode 100644 index 42f9e658..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/BaseMessageSendTo.kt +++ /dev/null @@ -1,7483 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.bulk.UserRecipient -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BaseMessageSendTo -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val to: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of() - ) : this(to, mutableMapOf()) - - /** - * The recipient or a list of recipients of the message - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BaseMessageSendTo]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BaseMessageSendTo]. */ - class Builder internal constructor() { - - private var to: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(baseMessageSendTo: BaseMessageSendTo) = apply { - to = baseMessageSendTo.to - additionalProperties = baseMessageSendTo.additionalProperties.toMutableMap() - } - - /** The recipient or a list of recipients of the message */ - fun to(to: To?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [To] value instead. This method is - * primarily for setting the field to an undocumented or not yet supported value. - */ - fun to(to: JsonField) = apply { this.to = to } - - /** Alias for calling [to] with `To.ofAudienceRecipient(audienceRecipient)`. */ - fun to(audienceRecipient: To.AudienceRecipient) = - to(To.ofAudienceRecipient(audienceRecipient)) - - /** Alias for calling [to] with `To.ofUnionMember1(unionMember1)`. */ - fun to(unionMember1: To.UnionMember1) = to(To.ofUnionMember1(unionMember1)) - - /** Alias for calling [to] with `To.ofUnionMember2(unionMember2)`. */ - fun to(unionMember2: To.UnionMember2) = to(To.ofUnionMember2(unionMember2)) - - /** Alias for calling [to] with `To.ofUserRecipient(userRecipient)`. */ - fun to(userRecipient: UserRecipient) = to(To.ofUserRecipient(userRecipient)) - - /** Alias for calling [to] with `To.ofSlackRecipient(slackRecipient)`. */ - fun to(slackRecipient: To.SlackRecipient) = to(To.ofSlackRecipient(slackRecipient)) - - /** Alias for calling [to] with `To.ofMsTeamsRecipient(msTeamsRecipient)`. */ - fun to(msTeamsRecipient: To.MsTeamsRecipient) = to(To.ofMsTeamsRecipient(msTeamsRecipient)) - - /** Alias for calling [to] with `To.ofRecipientData(recipientData)`. */ - fun to(recipientData: To.RecipientData) = to(To.ofRecipientData(recipientData)) - - /** Alias for calling [to] with `To.ofPagerdutyRecipient(pagerdutyRecipient)`. */ - fun to(pagerdutyRecipient: To.PagerdutyRecipient) = - to(To.ofPagerdutyRecipient(pagerdutyRecipient)) - - /** Alias for calling [to] with `To.ofWebhookRecipient(webhookRecipient)`. */ - fun to(webhookRecipient: To.WebhookRecipient) = to(To.ofWebhookRecipient(webhookRecipient)) - - /** Alias for calling [to] with `To.ofRecipients(recipients)`. */ - fun toOfRecipients(recipients: List) = to(To.ofRecipients(recipients)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BaseMessageSendTo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BaseMessageSendTo = BaseMessageSendTo(to, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): BaseMessageSendTo = apply { - if (validated) { - return@apply - } - - to().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (to.asKnown().getOrNull()?.validity() ?: 0) - - /** The recipient or a list of recipients of the message */ - @JsonDeserialize(using = To.Deserializer::class) - @JsonSerialize(using = To.Serializer::class) - class To - private constructor( - private val audienceRecipient: AudienceRecipient? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val userRecipient: UserRecipient? = null, - private val slackRecipient: SlackRecipient? = null, - private val msTeamsRecipient: MsTeamsRecipient? = null, - private val recipientData: RecipientData? = null, - private val pagerdutyRecipient: PagerdutyRecipient? = null, - private val webhookRecipient: WebhookRecipient? = null, - private val recipients: List? = null, - private val _json: JsonValue? = null, - ) { - - fun audienceRecipient(): Optional = - Optional.ofNullable(audienceRecipient) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun userRecipient(): Optional = Optional.ofNullable(userRecipient) - - fun slackRecipient(): Optional = Optional.ofNullable(slackRecipient) - - fun msTeamsRecipient(): Optional = Optional.ofNullable(msTeamsRecipient) - - fun recipientData(): Optional = Optional.ofNullable(recipientData) - - fun pagerdutyRecipient(): Optional = - Optional.ofNullable(pagerdutyRecipient) - - fun webhookRecipient(): Optional = Optional.ofNullable(webhookRecipient) - - fun recipients(): Optional> = Optional.ofNullable(recipients) - - fun isAudienceRecipient(): Boolean = audienceRecipient != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUserRecipient(): Boolean = userRecipient != null - - fun isSlackRecipient(): Boolean = slackRecipient != null - - fun isMsTeamsRecipient(): Boolean = msTeamsRecipient != null - - fun isRecipientData(): Boolean = recipientData != null - - fun isPagerdutyRecipient(): Boolean = pagerdutyRecipient != null - - fun isWebhookRecipient(): Boolean = webhookRecipient != null - - fun isRecipients(): Boolean = recipients != null - - fun asAudienceRecipient(): AudienceRecipient = - audienceRecipient.getOrThrow("audienceRecipient") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUserRecipient(): UserRecipient = userRecipient.getOrThrow("userRecipient") - - fun asSlackRecipient(): SlackRecipient = slackRecipient.getOrThrow("slackRecipient") - - fun asMsTeamsRecipient(): MsTeamsRecipient = msTeamsRecipient.getOrThrow("msTeamsRecipient") - - fun asRecipientData(): RecipientData = recipientData.getOrThrow("recipientData") - - fun asPagerdutyRecipient(): PagerdutyRecipient = - pagerdutyRecipient.getOrThrow("pagerdutyRecipient") - - fun asWebhookRecipient(): WebhookRecipient = webhookRecipient.getOrThrow("webhookRecipient") - - fun asRecipients(): List = recipients.getOrThrow("recipients") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - audienceRecipient != null -> visitor.visitAudienceRecipient(audienceRecipient) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - userRecipient != null -> visitor.visitUserRecipient(userRecipient) - slackRecipient != null -> visitor.visitSlackRecipient(slackRecipient) - msTeamsRecipient != null -> visitor.visitMsTeamsRecipient(msTeamsRecipient) - recipientData != null -> visitor.visitRecipientData(recipientData) - pagerdutyRecipient != null -> visitor.visitPagerdutyRecipient(pagerdutyRecipient) - webhookRecipient != null -> visitor.visitWebhookRecipient(webhookRecipient) - recipients != null -> visitor.visitRecipients(recipients) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): To = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitAudienceRecipient(audienceRecipient: AudienceRecipient) { - audienceRecipient.validate() - } - - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } - - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() - } - - override fun visitUserRecipient(userRecipient: UserRecipient) { - userRecipient.validate() - } - - override fun visitSlackRecipient(slackRecipient: SlackRecipient) { - slackRecipient.validate() - } - - override fun visitMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient) { - msTeamsRecipient.validate() - } - - override fun visitRecipientData(recipientData: RecipientData) { - recipientData.validate() - } - - override fun visitPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient) { - pagerdutyRecipient.validate() - } - - override fun visitWebhookRecipient(webhookRecipient: WebhookRecipient) { - webhookRecipient.validate() - } - - override fun visitRecipients(recipients: List) { - recipients.forEach { it.validate() } - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitAudienceRecipient(audienceRecipient: AudienceRecipient) = - audienceRecipient.validity() - - override fun visitUnionMember1(unionMember1: UnionMember1) = - unionMember1.validity() - - override fun visitUnionMember2(unionMember2: UnionMember2) = - unionMember2.validity() - - override fun visitUserRecipient(userRecipient: UserRecipient) = - userRecipient.validity() - - override fun visitSlackRecipient(slackRecipient: SlackRecipient) = - slackRecipient.validity() - - override fun visitMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient) = - msTeamsRecipient.validity() - - override fun visitRecipientData(recipientData: RecipientData) = - recipientData.validity() - - override fun visitPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient) = - pagerdutyRecipient.validity() - - override fun visitWebhookRecipient(webhookRecipient: WebhookRecipient) = - webhookRecipient.validity() - - override fun visitRecipients(recipients: List) = - recipients.sumOf { it.validity().toInt() } - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is To && - audienceRecipient == other.audienceRecipient && - unionMember1 == other.unionMember1 && - unionMember2 == other.unionMember2 && - userRecipient == other.userRecipient && - slackRecipient == other.slackRecipient && - msTeamsRecipient == other.msTeamsRecipient && - recipientData == other.recipientData && - pagerdutyRecipient == other.pagerdutyRecipient && - webhookRecipient == other.webhookRecipient && - recipients == other.recipients - } - - override fun hashCode(): Int = - Objects.hash( - audienceRecipient, - unionMember1, - unionMember2, - userRecipient, - slackRecipient, - msTeamsRecipient, - recipientData, - pagerdutyRecipient, - webhookRecipient, - recipients, - ) - - override fun toString(): String = - when { - audienceRecipient != null -> "To{audienceRecipient=$audienceRecipient}" - unionMember1 != null -> "To{unionMember1=$unionMember1}" - unionMember2 != null -> "To{unionMember2=$unionMember2}" - userRecipient != null -> "To{userRecipient=$userRecipient}" - slackRecipient != null -> "To{slackRecipient=$slackRecipient}" - msTeamsRecipient != null -> "To{msTeamsRecipient=$msTeamsRecipient}" - recipientData != null -> "To{recipientData=$recipientData}" - pagerdutyRecipient != null -> "To{pagerdutyRecipient=$pagerdutyRecipient}" - webhookRecipient != null -> "To{webhookRecipient=$webhookRecipient}" - recipients != null -> "To{recipients=$recipients}" - _json != null -> "To{_unknown=$_json}" - else -> throw IllegalStateException("Invalid To") - } - - companion object { - - @JvmStatic - fun ofAudienceRecipient(audienceRecipient: AudienceRecipient) = - To(audienceRecipient = audienceRecipient) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = To(unionMember1 = unionMember1) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = To(unionMember2 = unionMember2) - - @JvmStatic - fun ofUserRecipient(userRecipient: UserRecipient) = To(userRecipient = userRecipient) - - @JvmStatic - fun ofSlackRecipient(slackRecipient: SlackRecipient) = - To(slackRecipient = slackRecipient) - - @JvmStatic - fun ofMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient) = - To(msTeamsRecipient = msTeamsRecipient) - - @JvmStatic - fun ofRecipientData(recipientData: RecipientData) = To(recipientData = recipientData) - - @JvmStatic - fun ofPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient) = - To(pagerdutyRecipient = pagerdutyRecipient) - - @JvmStatic - fun ofWebhookRecipient(webhookRecipient: WebhookRecipient) = - To(webhookRecipient = webhookRecipient) - - @JvmStatic - fun ofRecipients(recipients: List) = - To(recipients = recipients.toImmutable()) - } - - /** An interface that defines how to map each variant of [To] to a value of type [T]. */ - interface Visitor { - - fun visitAudienceRecipient(audienceRecipient: AudienceRecipient): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUserRecipient(userRecipient: UserRecipient): T - - fun visitSlackRecipient(slackRecipient: SlackRecipient): T - - fun visitMsTeamsRecipient(msTeamsRecipient: MsTeamsRecipient): T - - fun visitRecipientData(recipientData: RecipientData): T - - fun visitPagerdutyRecipient(pagerdutyRecipient: PagerdutyRecipient): T - - fun visitWebhookRecipient(webhookRecipient: WebhookRecipient): T - - fun visitRecipients(recipients: List): T - - /** - * Maps an unknown variant of [To] to a value of type [T]. - * - * An instance of [To] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown To: $json") - } - } - - internal class Deserializer : BaseDeserializer(To::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): To { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - To(audienceRecipient = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(unionMember2 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(userRecipient = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(slackRecipient = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(msTeamsRecipient = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(recipientData = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(pagerdutyRecipient = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - To(webhookRecipient = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef>())?.let { - To(recipients = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> To(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(To::class) { - - override fun serialize( - value: To, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.audienceRecipient != null -> - generator.writeObject(value.audienceRecipient) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.userRecipient != null -> generator.writeObject(value.userRecipient) - value.slackRecipient != null -> generator.writeObject(value.slackRecipient) - value.msTeamsRecipient != null -> generator.writeObject(value.msTeamsRecipient) - value.recipientData != null -> generator.writeObject(value.recipientData) - value.pagerdutyRecipient != null -> - generator.writeObject(value.pagerdutyRecipient) - value.webhookRecipient != null -> generator.writeObject(value.webhookRecipient) - value.recipients != null -> generator.writeObject(value.recipients) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid To") - } - } - } - - class AudienceRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val audienceId: JsonField, - private val data: JsonField, - private val filters: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("audience_id") - @ExcludeMissing - audienceId: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - ) : this(audienceId, data, filters, mutableMapOf()) - - /** - * A unique identifier associated with an Audience. A message will be sent to each user - * in the audience. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun audienceId(): String = audienceId.getRequired("audience_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun filters(): Optional> = filters.getOptional("filters") - - /** - * Returns the raw JSON value of [audienceId]. - * - * Unlike [audienceId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("audience_id") - @ExcludeMissing - fun _audienceId(): JsonField = audienceId - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [AudienceRecipient]. - * - * The following fields are required: - * ```java - * .audienceId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AudienceRecipient]. */ - class Builder internal constructor() { - - private var audienceId: JsonField? = null - private var data: JsonField = JsonMissing.of() - private var filters: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(audienceRecipient: AudienceRecipient) = apply { - audienceId = audienceRecipient.audienceId - data = audienceRecipient.data - filters = audienceRecipient.filters.map { it.toMutableList() } - additionalProperties = audienceRecipient.additionalProperties.toMutableMap() - } - - /** - * A unique identifier associated with an Audience. A message will be sent to each - * user in the audience. - */ - fun audienceId(audienceId: String) = audienceId(JsonField.of(audienceId)) - - /** - * Sets [Builder.audienceId] to an arbitrary JSON value. - * - * You should usually call [Builder.audienceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun audienceId(audienceId: JsonField) = apply { - this.audienceId = audienceId - } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) - - /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ - fun filters(filters: Optional>) = filters(filters.getOrNull()) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } - - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AudienceRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .audienceId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): AudienceRecipient = - AudienceRecipient( - checkRequired("audienceId", audienceId), - data, - (filters ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AudienceRecipient = apply { - if (validated) { - return@apply - } - - audienceId() - data().ifPresent { it.validate() } - filters().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (audienceId.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val operator: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(operator, path, value, mutableMapOf()) - - /** - * Send to users only if they are member of the account - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun path(): Path = path.getRequired("path") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("operator") - @ExcludeMissing - fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var operator: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filter: Filter) = apply { - operator = filter.operator - path = filter.path - value = filter.value - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Send to users only if they are member of the account */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - fun path(path: Path) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [Path] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun path(path: JsonField) = apply { this.path = path } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("operator", operator), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - operator().validate() - path().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (path.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Send to users only if they are member of the account */ - class Operator - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MEMBER_OF = of("MEMBER_OF") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - MEMBER_OF - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MEMBER_OF, - /** - * An enum member indicating that [Operator] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MEMBER_OF -> Value.MEMBER_OF - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MEMBER_OF -> Known.MEMBER_OF - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Path @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ACCOUNT_ID = of("account_id") - - @JvmStatic fun of(value: String) = Path(JsonField.of(value)) - } - - /** An enum containing [Path]'s known values. */ - enum class Known { - ACCOUNT_ID - } - - /** - * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Path] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACCOUNT_ID, - /** - * An enum member indicating that [Path] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACCOUNT_ID -> Value.ACCOUNT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ACCOUNT_ID -> Known.ACCOUNT_ID - else -> throw CourierInvalidDataException("Unknown Path: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Path = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Path && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - operator == other.operator && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(operator, path, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AudienceRecipient && - audienceId == other.audienceId && - data == other.data && - filters == other.filters && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(audienceId, data, filters, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AudienceRecipient{audienceId=$audienceId, data=$data, filters=$filters, additionalProperties=$additionalProperties}" - } - - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonField, - private val filters: JsonField>, - private val listId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("list_id") - @ExcludeMissing - listId: JsonField = JsonMissing.of(), - ) : this(data, filters, listId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun filters(): Optional> = filters.getOptional("filters") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun listId(): Optional = listId.getOptional("list_id") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") - @ExcludeMissing - fun _filters(): JsonField> = filters - - /** - * Returns the raw JSON value of [listId]. - * - * Unlike [listId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("list_id") @ExcludeMissing fun _listId(): JsonField = listId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var data: JsonField = JsonMissing.of() - private var filters: JsonField>? = null - private var listId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - data = unionMember1.data - filters = unionMember1.filters.map { it.toMutableList() } - listId = unionMember1.listId - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) - - /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ - fun filters(filters: Optional>) = filters(filters.getOrNull()) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } - - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - fun listId(listId: String?) = listId(JsonField.ofNullable(listId)) - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - /** - * Sets [Builder.listId] to an arbitrary JSON value. - * - * You should usually call [Builder.listId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun listId(listId: JsonField) = apply { this.listId = listId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - data, - (filters ?: JsonMissing.of()).map { it.toImmutable() }, - listId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - data().ifPresent { it.validate() } - filters().ifPresent { it.forEach { it.validate() } } - listId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (data.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (listId.asKnown().isPresent) 1 else 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val operator: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(operator, path, value, mutableMapOf()) - - /** - * Send to users only if they are member of the account - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun path(): Path = path.getRequired("path") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("operator") - @ExcludeMissing - fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var operator: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filter: Filter) = apply { - operator = filter.operator - path = filter.path - value = filter.value - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Send to users only if they are member of the account */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - fun path(path: Path) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [Path] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun path(path: JsonField) = apply { this.path = path } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("operator", operator), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - operator().validate() - path().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (path.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Send to users only if they are member of the account */ - class Operator - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val MEMBER_OF = of("MEMBER_OF") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - MEMBER_OF - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MEMBER_OF, - /** - * An enum member indicating that [Operator] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MEMBER_OF -> Value.MEMBER_OF - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MEMBER_OF -> Known.MEMBER_OF - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Path @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val ACCOUNT_ID = of("account_id") - - @JvmStatic fun of(value: String) = Path(JsonField.of(value)) - } - - /** An enum containing [Path]'s known values. */ - enum class Known { - ACCOUNT_ID - } - - /** - * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Path] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACCOUNT_ID, - /** - * An enum member indicating that [Path] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACCOUNT_ID -> Value.ACCOUNT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ACCOUNT_ID -> Known.ACCOUNT_ID - else -> throw CourierInvalidDataException("Unknown Path: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Path = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Path && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - operator == other.operator && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(operator, path, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - data == other.data && - filters == other.filters && - listId == other.listId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, filters, listId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{data=$data, filters=$filters, listId=$listId, additionalProperties=$additionalProperties}" - } - - class UnionMember2 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonField, - private val listPattern: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("list_pattern") - @ExcludeMissing - listPattern: JsonField = JsonMissing.of(), - ) : this(data, listPattern, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun listPattern(): Optional = listPattern.getOptional("list_pattern") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [listPattern]. - * - * Unlike [listPattern], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("list_pattern") - @ExcludeMissing - fun _listPattern(): JsonField = listPattern - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember2]. */ - class Builder internal constructor() { - - private var data: JsonField = JsonMissing.of() - private var listPattern: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - data = unionMember2.data - listPattern = unionMember2.listPattern - additionalProperties = unionMember2.additionalProperties.toMutableMap() - } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun listPattern(listPattern: String?) = - listPattern(JsonField.ofNullable(listPattern)) - - /** Alias for calling [Builder.listPattern] with `listPattern.orElse(null)`. */ - fun listPattern(listPattern: Optional) = - listPattern(listPattern.getOrNull()) - - /** - * Sets [Builder.listPattern] to an arbitrary JSON value. - * - * You should usually call [Builder.listPattern] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun listPattern(listPattern: JsonField) = apply { - this.listPattern = listPattern - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember2]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember2 = - UnionMember2(data, listPattern, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): UnionMember2 = apply { - if (validated) { - return@apply - } - - data().ifPresent { it.validate() } - listPattern() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (listPattern.asKnown().isPresent) 1 else 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - data == other.data && - listPattern == other.listPattern && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, listPattern, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember2{data=$data, listPattern=$listPattern, additionalProperties=$additionalProperties}" - } - - class SlackRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val slack: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("slack") @ExcludeMissing slack: JsonField = JsonMissing.of() - ) : this(slack, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun slack(): Slack = slack.getRequired("slack") - - /** - * Returns the raw JSON value of [slack]. - * - * Unlike [slack], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("slack") @ExcludeMissing fun _slack(): JsonField = slack - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SlackRecipient]. - * - * The following fields are required: - * ```java - * .slack() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SlackRecipient]. */ - class Builder internal constructor() { - - private var slack: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(slackRecipient: SlackRecipient) = apply { - slack = slackRecipient.slack - additionalProperties = slackRecipient.additionalProperties.toMutableMap() - } - - fun slack(slack: Slack) = slack(JsonField.of(slack)) - - /** - * Sets [Builder.slack] to an arbitrary JSON value. - * - * You should usually call [Builder.slack] with a well-typed [Slack] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun slack(slack: JsonField) = apply { this.slack = slack } - - /** - * Alias for calling [slack] with `Slack.ofSendToSlackChannel(sendToSlackChannel)`. - */ - fun slack(sendToSlackChannel: Slack.SendToSlackChannel) = - slack(Slack.ofSendToSlackChannel(sendToSlackChannel)) - - /** Alias for calling [slack] with `Slack.ofSendToSlackEmail(sendToSlackEmail)`. */ - fun slack(sendToSlackEmail: Slack.SendToSlackEmail) = - slack(Slack.ofSendToSlackEmail(sendToSlackEmail)) - - /** - * Alias for calling [slack] with `Slack.ofSendToSlackUserId(sendToSlackUserId)`. - */ - fun slack(sendToSlackUserId: Slack.SendToSlackUserId) = - slack(Slack.ofSendToSlackUserId(sendToSlackUserId)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SlackRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .slack() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SlackRecipient = - SlackRecipient( - checkRequired("slack", slack), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SlackRecipient = apply { - if (validated) { - return@apply - } - - slack().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (slack.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = Slack.Deserializer::class) - @JsonSerialize(using = Slack.Serializer::class) - class Slack - private constructor( - private val sendToSlackChannel: SendToSlackChannel? = null, - private val sendToSlackEmail: SendToSlackEmail? = null, - private val sendToSlackUserId: SendToSlackUserId? = null, - private val _json: JsonValue? = null, - ) { - - fun sendToSlackChannel(): Optional = - Optional.ofNullable(sendToSlackChannel) - - fun sendToSlackEmail(): Optional = - Optional.ofNullable(sendToSlackEmail) - - fun sendToSlackUserId(): Optional = - Optional.ofNullable(sendToSlackUserId) - - fun isSendToSlackChannel(): Boolean = sendToSlackChannel != null - - fun isSendToSlackEmail(): Boolean = sendToSlackEmail != null - - fun isSendToSlackUserId(): Boolean = sendToSlackUserId != null - - fun asSendToSlackChannel(): SendToSlackChannel = - sendToSlackChannel.getOrThrow("sendToSlackChannel") - - fun asSendToSlackEmail(): SendToSlackEmail = - sendToSlackEmail.getOrThrow("sendToSlackEmail") - - fun asSendToSlackUserId(): SendToSlackUserId = - sendToSlackUserId.getOrThrow("sendToSlackUserId") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - sendToSlackChannel != null -> - visitor.visitSendToSlackChannel(sendToSlackChannel) - sendToSlackEmail != null -> visitor.visitSendToSlackEmail(sendToSlackEmail) - sendToSlackUserId != null -> - visitor.visitSendToSlackUserId(sendToSlackUserId) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Slack = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSendToSlackChannel( - sendToSlackChannel: SendToSlackChannel - ) { - sendToSlackChannel.validate() - } - - override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) { - sendToSlackEmail.validate() - } - - override fun visitSendToSlackUserId( - sendToSlackUserId: SendToSlackUserId - ) { - sendToSlackUserId.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitSendToSlackChannel( - sendToSlackChannel: SendToSlackChannel - ) = sendToSlackChannel.validity() - - override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = - sendToSlackEmail.validity() - - override fun visitSendToSlackUserId( - sendToSlackUserId: SendToSlackUserId - ) = sendToSlackUserId.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Slack && - sendToSlackChannel == other.sendToSlackChannel && - sendToSlackEmail == other.sendToSlackEmail && - sendToSlackUserId == other.sendToSlackUserId - } - - override fun hashCode(): Int = - Objects.hash(sendToSlackChannel, sendToSlackEmail, sendToSlackUserId) - - override fun toString(): String = - when { - sendToSlackChannel != null -> - "Slack{sendToSlackChannel=$sendToSlackChannel}" - sendToSlackEmail != null -> "Slack{sendToSlackEmail=$sendToSlackEmail}" - sendToSlackUserId != null -> "Slack{sendToSlackUserId=$sendToSlackUserId}" - _json != null -> "Slack{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Slack") - } - - companion object { - - @JvmStatic - fun ofSendToSlackChannel(sendToSlackChannel: SendToSlackChannel) = - Slack(sendToSlackChannel = sendToSlackChannel) - - @JvmStatic - fun ofSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = - Slack(sendToSlackEmail = sendToSlackEmail) - - @JvmStatic - fun ofSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) = - Slack(sendToSlackUserId = sendToSlackUserId) - } - - /** - * An interface that defines how to map each variant of [Slack] to a value of type - * [T]. - */ - interface Visitor { - - fun visitSendToSlackChannel(sendToSlackChannel: SendToSlackChannel): T - - fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail): T - - fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId): T - - /** - * Maps an unknown variant of [Slack] to a value of type [T]. - * - * An instance of [Slack] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Slack: $json") - } - } - - internal class Deserializer : BaseDeserializer(Slack::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Slack { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { Slack(sendToSlackChannel = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef())?.let { - Slack(sendToSlackEmail = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Slack(sendToSlackUserId = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // boolean). - 0 -> Slack(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Slack::class) { - - override fun serialize( - value: Slack, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.sendToSlackChannel != null -> - generator.writeObject(value.sendToSlackChannel) - value.sendToSlackEmail != null -> - generator.writeObject(value.sendToSlackEmail) - value.sendToSlackUserId != null -> - generator.writeObject(value.sendToSlackUserId) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Slack") - } - } - } - - class SendToSlackChannel - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessToken: JsonField, - private val channel: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("channel") - @ExcludeMissing - channel: JsonField = JsonMissing.of(), - ) : this(accessToken, channel, mutableMapOf()) - - fun toSlackBaseProperties(): SlackBaseProperties = - SlackBaseProperties.builder().accessToken(accessToken).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("channel") - @ExcludeMissing - fun _channel(): JsonField = channel - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToSlackChannel]. - * - * The following fields are required: - * ```java - * .accessToken() - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToSlackChannel]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var channel: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToSlackChannel: SendToSlackChannel) = apply { - accessToken = sendToSlackChannel.accessToken - channel = sendToSlackChannel.channel - additionalProperties = - sendToSlackChannel.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = - accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessToken(accessToken: JsonField) = apply { - this.accessToken = accessToken - } - - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToSlackChannel]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToSlackChannel = - SendToSlackChannel( - checkRequired("accessToken", accessToken), - checkRequired("channel", channel), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToSlackChannel = apply { - if (validated) { - return@apply - } - - accessToken() - channel() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (channel.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToSlackChannel && - accessToken == other.accessToken && - channel == other.channel && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, channel, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToSlackChannel{accessToken=$accessToken, channel=$channel, additionalProperties=$additionalProperties}" - } - - class SendToSlackEmail - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessToken: JsonField, - private val email: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - email: JsonField = JsonMissing.of(), - ) : this(accessToken, email, mutableMapOf()) - - fun toSlackBaseProperties(): SlackBaseProperties = - SlackBaseProperties.builder().accessToken(accessToken).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun email(): String = email.getRequired("email") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToSlackEmail]. - * - * The following fields are required: - * ```java - * .accessToken() - * .email() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToSlackEmail]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var email: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToSlackEmail: SendToSlackEmail) = apply { - accessToken = sendToSlackEmail.accessToken - email = sendToSlackEmail.email - additionalProperties = - sendToSlackEmail.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = - accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessToken(accessToken: JsonField) = apply { - this.accessToken = accessToken - } - - fun email(email: String) = email(JsonField.of(email)) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToSlackEmail]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * .email() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToSlackEmail = - SendToSlackEmail( - checkRequired("accessToken", accessToken), - checkRequired("email", email), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToSlackEmail = apply { - if (validated) { - return@apply - } - - accessToken() - email() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (email.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToSlackEmail && - accessToken == other.accessToken && - email == other.email && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, email, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToSlackEmail{accessToken=$accessToken, email=$email, additionalProperties=$additionalProperties}" - } - - class SendToSlackUserId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessToken: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - userId: JsonField = JsonMissing.of(), - ) : this(accessToken, userId, mutableMapOf()) - - fun toSlackBaseProperties(): SlackBaseProperties = - SlackBaseProperties.builder().accessToken(accessToken).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun userId(): String = userId.getRequired("user_id") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToSlackUserId]. - * - * The following fields are required: - * ```java - * .accessToken() - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToSlackUserId]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var userId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToSlackUserId: SendToSlackUserId) = apply { - accessToken = sendToSlackUserId.accessToken - userId = sendToSlackUserId.userId - additionalProperties = - sendToSlackUserId.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = - accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessToken(accessToken: JsonField) = apply { - this.accessToken = accessToken - } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToSlackUserId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToSlackUserId = - SendToSlackUserId( - checkRequired("accessToken", accessToken), - checkRequired("userId", userId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToSlackUserId = apply { - if (validated) { - return@apply - } - - accessToken() - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToSlackUserId && - accessToken == other.accessToken && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, userId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToSlackUserId{accessToken=$accessToken, userId=$userId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SlackRecipient && - slack == other.slack && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(slack, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SlackRecipient{slack=$slack, additionalProperties=$additionalProperties}" - } - - class MsTeamsRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val msTeams: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("ms_teams") - @ExcludeMissing - msTeams: JsonField = JsonMissing.of() - ) : this(msTeams, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun msTeams(): MsTeams = msTeams.getRequired("ms_teams") - - /** - * Returns the raw JSON value of [msTeams]. - * - * Unlike [msTeams], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ms_teams") @ExcludeMissing fun _msTeams(): JsonField = msTeams - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MsTeamsRecipient]. - * - * The following fields are required: - * ```java - * .msTeams() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MsTeamsRecipient]. */ - class Builder internal constructor() { - - private var msTeams: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(msTeamsRecipient: MsTeamsRecipient) = apply { - msTeams = msTeamsRecipient.msTeams - additionalProperties = msTeamsRecipient.additionalProperties.toMutableMap() - } - - fun msTeams(msTeams: MsTeams) = msTeams(JsonField.of(msTeams)) - - /** - * Sets [Builder.msTeams] to an arbitrary JSON value. - * - * You should usually call [Builder.msTeams] with a well-typed [MsTeams] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun msTeams(msTeams: JsonField) = apply { this.msTeams = msTeams } - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)`. - */ - fun msTeams(sendToMsTeamsUserId: MsTeams.SendToMsTeamsUserId) = - msTeams(MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)`. - */ - fun msTeams(sendToMsTeamsEmail: MsTeams.SendToMsTeamsEmail) = - msTeams(MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)`. - */ - fun msTeams(sendToMsTeamsChannelId: MsTeams.SendToMsTeamsChannelId) = - msTeams(MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)`. - */ - fun msTeams(sendToMsTeamsConversationId: MsTeams.SendToMsTeamsConversationId) = - msTeams(MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)`. - */ - fun msTeams(sendToMsTeamsChannelName: MsTeams.SendToMsTeamsChannelName) = - msTeams(MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MsTeamsRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .msTeams() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MsTeamsRecipient = - MsTeamsRecipient( - checkRequired("msTeams", msTeams), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MsTeamsRecipient = apply { - if (validated) { - return@apply - } - - msTeams().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (msTeams.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = MsTeams.Deserializer::class) - @JsonSerialize(using = MsTeams.Serializer::class) - class MsTeams - private constructor( - private val sendToMsTeamsUserId: SendToMsTeamsUserId? = null, - private val sendToMsTeamsEmail: SendToMsTeamsEmail? = null, - private val sendToMsTeamsChannelId: SendToMsTeamsChannelId? = null, - private val sendToMsTeamsConversationId: SendToMsTeamsConversationId? = null, - private val sendToMsTeamsChannelName: SendToMsTeamsChannelName? = null, - private val _json: JsonValue? = null, - ) { - - fun sendToMsTeamsUserId(): Optional = - Optional.ofNullable(sendToMsTeamsUserId) - - fun sendToMsTeamsEmail(): Optional = - Optional.ofNullable(sendToMsTeamsEmail) - - fun sendToMsTeamsChannelId(): Optional = - Optional.ofNullable(sendToMsTeamsChannelId) - - fun sendToMsTeamsConversationId(): Optional = - Optional.ofNullable(sendToMsTeamsConversationId) - - fun sendToMsTeamsChannelName(): Optional = - Optional.ofNullable(sendToMsTeamsChannelName) - - fun isSendToMsTeamsUserId(): Boolean = sendToMsTeamsUserId != null - - fun isSendToMsTeamsEmail(): Boolean = sendToMsTeamsEmail != null - - fun isSendToMsTeamsChannelId(): Boolean = sendToMsTeamsChannelId != null - - fun isSendToMsTeamsConversationId(): Boolean = sendToMsTeamsConversationId != null - - fun isSendToMsTeamsChannelName(): Boolean = sendToMsTeamsChannelName != null - - fun asSendToMsTeamsUserId(): SendToMsTeamsUserId = - sendToMsTeamsUserId.getOrThrow("sendToMsTeamsUserId") - - fun asSendToMsTeamsEmail(): SendToMsTeamsEmail = - sendToMsTeamsEmail.getOrThrow("sendToMsTeamsEmail") - - fun asSendToMsTeamsChannelId(): SendToMsTeamsChannelId = - sendToMsTeamsChannelId.getOrThrow("sendToMsTeamsChannelId") - - fun asSendToMsTeamsConversationId(): SendToMsTeamsConversationId = - sendToMsTeamsConversationId.getOrThrow("sendToMsTeamsConversationId") - - fun asSendToMsTeamsChannelName(): SendToMsTeamsChannelName = - sendToMsTeamsChannelName.getOrThrow("sendToMsTeamsChannelName") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - sendToMsTeamsUserId != null -> - visitor.visitSendToMsTeamsUserId(sendToMsTeamsUserId) - sendToMsTeamsEmail != null -> - visitor.visitSendToMsTeamsEmail(sendToMsTeamsEmail) - sendToMsTeamsChannelId != null -> - visitor.visitSendToMsTeamsChannelId(sendToMsTeamsChannelId) - sendToMsTeamsConversationId != null -> - visitor.visitSendToMsTeamsConversationId(sendToMsTeamsConversationId) - sendToMsTeamsChannelName != null -> - visitor.visitSendToMsTeamsChannelName(sendToMsTeamsChannelName) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): MsTeams = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSendToMsTeamsUserId( - sendToMsTeamsUserId: SendToMsTeamsUserId - ) { - sendToMsTeamsUserId.validate() - } - - override fun visitSendToMsTeamsEmail( - sendToMsTeamsEmail: SendToMsTeamsEmail - ) { - sendToMsTeamsEmail.validate() - } - - override fun visitSendToMsTeamsChannelId( - sendToMsTeamsChannelId: SendToMsTeamsChannelId - ) { - sendToMsTeamsChannelId.validate() - } - - override fun visitSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) { - sendToMsTeamsConversationId.validate() - } - - override fun visitSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ) { - sendToMsTeamsChannelName.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitSendToMsTeamsUserId( - sendToMsTeamsUserId: SendToMsTeamsUserId - ) = sendToMsTeamsUserId.validity() - - override fun visitSendToMsTeamsEmail( - sendToMsTeamsEmail: SendToMsTeamsEmail - ) = sendToMsTeamsEmail.validity() - - override fun visitSendToMsTeamsChannelId( - sendToMsTeamsChannelId: SendToMsTeamsChannelId - ) = sendToMsTeamsChannelId.validity() - - override fun visitSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) = sendToMsTeamsConversationId.validity() - - override fun visitSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ) = sendToMsTeamsChannelName.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MsTeams && - sendToMsTeamsUserId == other.sendToMsTeamsUserId && - sendToMsTeamsEmail == other.sendToMsTeamsEmail && - sendToMsTeamsChannelId == other.sendToMsTeamsChannelId && - sendToMsTeamsConversationId == other.sendToMsTeamsConversationId && - sendToMsTeamsChannelName == other.sendToMsTeamsChannelName - } - - override fun hashCode(): Int = - Objects.hash( - sendToMsTeamsUserId, - sendToMsTeamsEmail, - sendToMsTeamsChannelId, - sendToMsTeamsConversationId, - sendToMsTeamsChannelName, - ) - - override fun toString(): String = - when { - sendToMsTeamsUserId != null -> - "MsTeams{sendToMsTeamsUserId=$sendToMsTeamsUserId}" - sendToMsTeamsEmail != null -> - "MsTeams{sendToMsTeamsEmail=$sendToMsTeamsEmail}" - sendToMsTeamsChannelId != null -> - "MsTeams{sendToMsTeamsChannelId=$sendToMsTeamsChannelId}" - sendToMsTeamsConversationId != null -> - "MsTeams{sendToMsTeamsConversationId=$sendToMsTeamsConversationId}" - sendToMsTeamsChannelName != null -> - "MsTeams{sendToMsTeamsChannelName=$sendToMsTeamsChannelName}" - _json != null -> "MsTeams{_unknown=$_json}" - else -> throw IllegalStateException("Invalid MsTeams") - } - - companion object { - - @JvmStatic - fun ofSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId) = - MsTeams(sendToMsTeamsUserId = sendToMsTeamsUserId) - - @JvmStatic - fun ofSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail) = - MsTeams(sendToMsTeamsEmail = sendToMsTeamsEmail) - - @JvmStatic - fun ofSendToMsTeamsChannelId(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = - MsTeams(sendToMsTeamsChannelId = sendToMsTeamsChannelId) - - @JvmStatic - fun ofSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) = MsTeams(sendToMsTeamsConversationId = sendToMsTeamsConversationId) - - @JvmStatic - fun ofSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ) = MsTeams(sendToMsTeamsChannelName = sendToMsTeamsChannelName) - } - - /** - * An interface that defines how to map each variant of [MsTeams] to a value of type - * [T]. - */ - interface Visitor { - - fun visitSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId): T - - fun visitSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail): T - - fun visitSendToMsTeamsChannelId( - sendToMsTeamsChannelId: SendToMsTeamsChannelId - ): T - - fun visitSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ): T - - fun visitSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ): T - - /** - * Maps an unknown variant of [MsTeams] to a value of type [T]. - * - * An instance of [MsTeams] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown MsTeams: $json") - } - } - - internal class Deserializer : BaseDeserializer(MsTeams::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): MsTeams { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { MsTeams(sendToMsTeamsUserId = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { MsTeams(sendToMsTeamsEmail = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - MsTeams(sendToMsTeamsChannelId = it, _json = json) - }, - tryDeserialize( - node, - jacksonTypeRef(), - ) - ?.let { - MsTeams(sendToMsTeamsConversationId = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - MsTeams(sendToMsTeamsChannelName = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // boolean). - 0 -> MsTeams(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(MsTeams::class) { - - override fun serialize( - value: MsTeams, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.sendToMsTeamsUserId != null -> - generator.writeObject(value.sendToMsTeamsUserId) - value.sendToMsTeamsEmail != null -> - generator.writeObject(value.sendToMsTeamsEmail) - value.sendToMsTeamsChannelId != null -> - generator.writeObject(value.sendToMsTeamsChannelId) - value.sendToMsTeamsConversationId != null -> - generator.writeObject(value.sendToMsTeamsConversationId) - value.sendToMsTeamsChannelName != null -> - generator.writeObject(value.sendToMsTeamsChannelName) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid MsTeams") - } - } - } - - class SendToMsTeamsUserId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - userId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, userId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun userId(): String = userId.getRequired("user_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("user_id") - @ExcludeMissing - fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsUserId]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsUserId]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var userId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsUserId: SendToMsTeamsUserId) = apply { - serviceUrl = sendToMsTeamsUserId.serviceUrl - tenantId = sendToMsTeamsUserId.tenantId - userId = sendToMsTeamsUserId.userId - additionalProperties = - sendToMsTeamsUserId.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { - this.tenantId = tenantId - } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsUserId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsUserId = - SendToMsTeamsUserId( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("userId", userId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsUserId = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsUserId && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, userId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsUserId{serviceUrl=$serviceUrl, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsEmail - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val email: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - email: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, email, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun email(): String = email.getRequired("email") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsEmail]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .email() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsEmail]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var email: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsEmail: SendToMsTeamsEmail) = apply { - serviceUrl = sendToMsTeamsEmail.serviceUrl - tenantId = sendToMsTeamsEmail.tenantId - email = sendToMsTeamsEmail.email - additionalProperties = - sendToMsTeamsEmail.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { - this.tenantId = tenantId - } - - fun email(email: String) = email(JsonField.of(email)) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsEmail]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .email() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsEmail = - SendToMsTeamsEmail( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("email", email), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsEmail = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - email() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (email.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsEmail && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - email == other.email && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, email, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsEmail{serviceUrl=$serviceUrl, tenantId=$tenantId, email=$email, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsChannelId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val channelId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("channel_id") - @ExcludeMissing - channelId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, channelId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channelId(): String = channelId.getRequired("channel_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [channelId]. - * - * Unlike [channelId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("channel_id") - @ExcludeMissing - fun _channelId(): JsonField = channelId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsChannelId]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsChannelId]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var channelId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = apply { - serviceUrl = sendToMsTeamsChannelId.serviceUrl - tenantId = sendToMsTeamsChannelId.tenantId - channelId = sendToMsTeamsChannelId.channelId - additionalProperties = - sendToMsTeamsChannelId.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { - this.tenantId = tenantId - } - - fun channelId(channelId: String) = channelId(JsonField.of(channelId)) - - /** - * Sets [Builder.channelId] to an arbitrary JSON value. - * - * You should usually call [Builder.channelId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channelId(channelId: JsonField) = apply { - this.channelId = channelId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsChannelId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsChannelId = - SendToMsTeamsChannelId( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("channelId", channelId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsChannelId = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - channelId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (channelId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsChannelId && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - channelId == other.channelId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, channelId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsChannelId{serviceUrl=$serviceUrl, tenantId=$tenantId, channelId=$channelId, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsConversationId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val conversationId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("conversation_id") - @ExcludeMissing - conversationId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, conversationId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun conversationId(): String = conversationId.getRequired("conversation_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [conversationId]. - * - * Unlike [conversationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversation_id") - @ExcludeMissing - fun _conversationId(): JsonField = conversationId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsConversationId]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .conversationId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsConversationId]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var conversationId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) = apply { - serviceUrl = sendToMsTeamsConversationId.serviceUrl - tenantId = sendToMsTeamsConversationId.tenantId - conversationId = sendToMsTeamsConversationId.conversationId - additionalProperties = - sendToMsTeamsConversationId.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { - this.tenantId = tenantId - } - - fun conversationId(conversationId: String) = - conversationId(JsonField.of(conversationId)) - - /** - * Sets [Builder.conversationId] to an arbitrary JSON value. - * - * You should usually call [Builder.conversationId] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun conversationId(conversationId: JsonField) = apply { - this.conversationId = conversationId - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsConversationId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .conversationId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsConversationId = - SendToMsTeamsConversationId( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("conversationId", conversationId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsConversationId = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - conversationId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (conversationId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsConversationId && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - conversationId == other.conversationId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, conversationId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsConversationId{serviceUrl=$serviceUrl, tenantId=$tenantId, conversationId=$conversationId, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsChannelName - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val channelName: JsonField, - private val teamId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("channel_name") - @ExcludeMissing - channelName: JsonField = JsonMissing.of(), - @JsonProperty("team_id") - @ExcludeMissing - teamId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, channelName, teamId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channelName(): String = channelName.getRequired("channel_name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun teamId(): String = teamId.getRequired("team_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [channelName]. - * - * Unlike [channelName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("channel_name") - @ExcludeMissing - fun _channelName(): JsonField = channelName - - /** - * Returns the raw JSON value of [teamId]. - * - * Unlike [teamId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("team_id") - @ExcludeMissing - fun _teamId(): JsonField = teamId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsChannelName]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelName() - * .teamId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsChannelName]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var channelName: JsonField? = null - private var teamId: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsChannelName: SendToMsTeamsChannelName) = - apply { - serviceUrl = sendToMsTeamsChannelName.serviceUrl - tenantId = sendToMsTeamsChannelName.tenantId - channelName = sendToMsTeamsChannelName.channelName - teamId = sendToMsTeamsChannelName.teamId - additionalProperties = - sendToMsTeamsChannelName.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { - this.tenantId = tenantId - } - - fun channelName(channelName: String) = - channelName(JsonField.of(channelName)) - - /** - * Sets [Builder.channelName] to an arbitrary JSON value. - * - * You should usually call [Builder.channelName] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channelName(channelName: JsonField) = apply { - this.channelName = channelName - } - - fun teamId(teamId: String) = teamId(JsonField.of(teamId)) - - /** - * Sets [Builder.teamId] to an arbitrary JSON value. - * - * You should usually call [Builder.teamId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun teamId(teamId: JsonField) = apply { this.teamId = teamId } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsChannelName]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelName() - * .teamId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsChannelName = - SendToMsTeamsChannelName( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("channelName", channelName), - checkRequired("teamId", teamId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsChannelName = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - channelName() - teamId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (channelName.asKnown().isPresent) 1 else 0) + - (if (teamId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsChannelName && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - channelName == other.channelName && - teamId == other.teamId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - serviceUrl, - tenantId, - channelName, - teamId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsChannelName{serviceUrl=$serviceUrl, tenantId=$tenantId, channelName=$channelName, teamId=$teamId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MsTeamsRecipient && - msTeams == other.msTeams && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(msTeams, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MsTeamsRecipient{msTeams=$msTeams, additionalProperties=$additionalProperties}" - } - - class RecipientData - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RecipientData]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RecipientData]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(recipientData: RecipientData) = apply { - additionalProperties = recipientData.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RecipientData]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RecipientData = RecipientData(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): RecipientData = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RecipientData && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "RecipientData{additionalProperties=$additionalProperties}" - } - - class PagerdutyRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val pagerduty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("pagerduty") - @ExcludeMissing - pagerduty: JsonField = JsonMissing.of() - ) : this(pagerduty, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun pagerduty(): Pagerduty = pagerduty.getRequired("pagerduty") - - /** - * Returns the raw JSON value of [pagerduty]. - * - * Unlike [pagerduty], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pagerduty") - @ExcludeMissing - fun _pagerduty(): JsonField = pagerduty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PagerdutyRecipient]. - * - * The following fields are required: - * ```java - * .pagerduty() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PagerdutyRecipient]. */ - class Builder internal constructor() { - - private var pagerduty: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pagerdutyRecipient: PagerdutyRecipient) = apply { - pagerduty = pagerdutyRecipient.pagerduty - additionalProperties = pagerdutyRecipient.additionalProperties.toMutableMap() - } - - fun pagerduty(pagerduty: Pagerduty) = pagerduty(JsonField.of(pagerduty)) - - /** - * Sets [Builder.pagerduty] to an arbitrary JSON value. - * - * You should usually call [Builder.pagerduty] with a well-typed [Pagerduty] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun pagerduty(pagerduty: JsonField) = apply { - this.pagerduty = pagerduty - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PagerdutyRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .pagerduty() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PagerdutyRecipient = - PagerdutyRecipient( - checkRequired("pagerduty", pagerduty), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PagerdutyRecipient = apply { - if (validated) { - return@apply - } - - pagerduty().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (pagerduty.asKnown().getOrNull()?.validity() ?: 0) - - class Pagerduty - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val eventAction: JsonField, - private val routingKey: JsonField, - private val severity: JsonField, - private val source: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("event_action") - @ExcludeMissing - eventAction: JsonField = JsonMissing.of(), - @JsonProperty("routing_key") - @ExcludeMissing - routingKey: JsonField = JsonMissing.of(), - @JsonProperty("severity") - @ExcludeMissing - severity: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - source: JsonField = JsonMissing.of(), - ) : this(eventAction, routingKey, severity, source, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun eventAction(): Optional = eventAction.getOptional("event_action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun routingKey(): Optional = routingKey.getOptional("routing_key") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun severity(): Optional = severity.getOptional("severity") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * Returns the raw JSON value of [eventAction]. - * - * Unlike [eventAction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("event_action") - @ExcludeMissing - fun _eventAction(): JsonField = eventAction - - /** - * Returns the raw JSON value of [routingKey]. - * - * Unlike [routingKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("routing_key") - @ExcludeMissing - fun _routingKey(): JsonField = routingKey - - /** - * Returns the raw JSON value of [severity]. - * - * Unlike [severity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("severity") - @ExcludeMissing - fun _severity(): JsonField = severity - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Pagerduty]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Pagerduty]. */ - class Builder internal constructor() { - - private var eventAction: JsonField = JsonMissing.of() - private var routingKey: JsonField = JsonMissing.of() - private var severity: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pagerduty: Pagerduty) = apply { - eventAction = pagerduty.eventAction - routingKey = pagerduty.routingKey - severity = pagerduty.severity - source = pagerduty.source - additionalProperties = pagerduty.additionalProperties.toMutableMap() - } - - fun eventAction(eventAction: String?) = - eventAction(JsonField.ofNullable(eventAction)) - - /** Alias for calling [Builder.eventAction] with `eventAction.orElse(null)`. */ - fun eventAction(eventAction: Optional) = - eventAction(eventAction.getOrNull()) - - /** - * Sets [Builder.eventAction] to an arbitrary JSON value. - * - * You should usually call [Builder.eventAction] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun eventAction(eventAction: JsonField) = apply { - this.eventAction = eventAction - } - - fun routingKey(routingKey: String?) = - routingKey(JsonField.ofNullable(routingKey)) - - /** Alias for calling [Builder.routingKey] with `routingKey.orElse(null)`. */ - fun routingKey(routingKey: Optional) = - routingKey(routingKey.getOrNull()) - - /** - * Sets [Builder.routingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.routingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun routingKey(routingKey: JsonField) = apply { - this.routingKey = routingKey - } - - fun severity(severity: String?) = severity(JsonField.ofNullable(severity)) - - /** Alias for calling [Builder.severity] with `severity.orElse(null)`. */ - fun severity(severity: Optional) = severity(severity.getOrNull()) - - /** - * Sets [Builder.severity] to an arbitrary JSON value. - * - * You should usually call [Builder.severity] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun severity(severity: JsonField) = apply { this.severity = severity } - - fun source(source: String?) = source(JsonField.ofNullable(source)) - - /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Pagerduty]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Pagerduty = - Pagerduty( - eventAction, - routingKey, - severity, - source, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Pagerduty = apply { - if (validated) { - return@apply - } - - eventAction() - routingKey() - severity() - source() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (eventAction.asKnown().isPresent) 1 else 0) + - (if (routingKey.asKnown().isPresent) 1 else 0) + - (if (severity.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Pagerduty && - eventAction == other.eventAction && - routingKey == other.routingKey && - severity == other.severity && - source == other.source && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(eventAction, routingKey, severity, source, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Pagerduty{eventAction=$eventAction, routingKey=$routingKey, severity=$severity, source=$source, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PagerdutyRecipient && - pagerduty == other.pagerduty && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(pagerduty, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PagerdutyRecipient{pagerduty=$pagerduty, additionalProperties=$additionalProperties}" - } - - class WebhookRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val webhook: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("webhook") - @ExcludeMissing - webhook: JsonField = JsonMissing.of() - ) : this(webhook, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun webhook(): Webhook = webhook.getRequired("webhook") - - /** - * Returns the raw JSON value of [webhook]. - * - * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("webhook") @ExcludeMissing fun _webhook(): JsonField = webhook - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [WebhookRecipient]. - * - * The following fields are required: - * ```java - * .webhook() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookRecipient]. */ - class Builder internal constructor() { - - private var webhook: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webhookRecipient: WebhookRecipient) = apply { - webhook = webhookRecipient.webhook - additionalProperties = webhookRecipient.additionalProperties.toMutableMap() - } - - fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) - - /** - * Sets [Builder.webhook] to an arbitrary JSON value. - * - * You should usually call [Builder.webhook] with a well-typed [Webhook] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun webhook(webhook: JsonField) = apply { this.webhook = webhook } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [WebhookRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .webhook() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): WebhookRecipient = - WebhookRecipient( - checkRequired("webhook", webhook), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): WebhookRecipient = apply { - if (validated) { - return@apply - } - - webhook().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (webhook.asKnown().getOrNull()?.validity() ?: 0) - - class Webhook - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val url: JsonField, - private val authentication: JsonField, - private val headers: JsonField, - private val method: JsonField, - private val profile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - @JsonProperty("authentication") - @ExcludeMissing - authentication: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("method") - @ExcludeMissing - method: JsonField = JsonMissing.of(), - @JsonProperty("profile") - @ExcludeMissing - profile: JsonField = JsonMissing.of(), - ) : this(url, authentication, headers, method, profile, mutableMapOf()) - - /** - * The URL to send the webhook request to. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun url(): String = url.getRequired("url") - - /** - * Authentication configuration for the webhook request. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun authentication(): Optional = - authentication.getOptional("authentication") - - /** - * Custom headers to include in the webhook request. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * The HTTP method to use for the webhook request. Defaults to POST if not - * specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun method(): Optional = method.getOptional("method") - - /** - * Specifies what profile information is included in the request payload. Defaults - * to 'limited' if not specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun profile(): Optional = profile.getOptional("profile") - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [authentication]. - * - * Unlike [authentication], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("authentication") - @ExcludeMissing - fun _authentication(): JsonField = authentication - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("headers") - @ExcludeMissing - fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [method]. - * - * Unlike [method], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("profile") - @ExcludeMissing - fun _profile(): JsonField = profile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Webhook]. - * - * The following fields are required: - * ```java - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Webhook]. */ - class Builder internal constructor() { - - private var url: JsonField? = null - private var authentication: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var profile: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webhook: Webhook) = apply { - url = webhook.url - authentication = webhook.authentication - headers = webhook.headers - method = webhook.method - profile = webhook.profile - additionalProperties = webhook.additionalProperties.toMutableMap() - } - - /** The URL to send the webhook request to. */ - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - /** Authentication configuration for the webhook request. */ - fun authentication(authentication: Authentication?) = - authentication(JsonField.ofNullable(authentication)) - - /** - * Alias for calling [Builder.authentication] with - * `authentication.orElse(null)`. - */ - fun authentication(authentication: Optional) = - authentication(authentication.getOrNull()) - - /** - * Sets [Builder.authentication] to an arbitrary JSON value. - * - * You should usually call [Builder.authentication] with a well-typed - * [Authentication] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun authentication(authentication: JsonField) = apply { - this.authentication = authentication - } - - /** Custom headers to include in the webhook request. */ - fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) - - /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ - fun headers(headers: Optional) = headers(headers.getOrNull()) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** - * The HTTP method to use for the webhook request. Defaults to POST if not - * specified. - */ - fun method(method: Method?) = method(JsonField.ofNullable(method)) - - /** Alias for calling [Builder.method] with `method.orElse(null)`. */ - fun method(method: Optional) = method(method.getOrNull()) - - /** - * Sets [Builder.method] to an arbitrary JSON value. - * - * You should usually call [Builder.method] with a well-typed [Method] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun method(method: JsonField) = apply { this.method = method } - - /** - * Specifies what profile information is included in the request payload. - * Defaults to 'limited' if not specified. - */ - fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Webhook]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Webhook = - Webhook( - checkRequired("url", url), - authentication, - headers, - method, - profile, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Webhook = apply { - if (validated) { - return@apply - } - - url() - authentication().ifPresent { it.validate() } - headers().ifPresent { it.validate() } - method().ifPresent { it.validate() } - profile().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (url.asKnown().isPresent) 1 else 0) + - (authentication.asKnown().getOrNull()?.validity() ?: 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (method.asKnown().getOrNull()?.validity() ?: 0) + - (profile.asKnown().getOrNull()?.validity() ?: 0) - - /** Authentication configuration for the webhook request. */ - class Authentication - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val mode: JsonField, - private val token: JsonField, - private val password: JsonField, - private val username: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("mode") - @ExcludeMissing - mode: JsonField = JsonMissing.of(), - @JsonProperty("token") - @ExcludeMissing - token: JsonField = JsonMissing.of(), - @JsonProperty("password") - @ExcludeMissing - password: JsonField = JsonMissing.of(), - @JsonProperty("username") - @ExcludeMissing - username: JsonField = JsonMissing.of(), - ) : this(mode, token, password, username, mutableMapOf()) - - /** - * The authentication mode to use. Defaults to 'none' if not specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * or is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun mode(): Mode = mode.getRequired("mode") - - /** - * Token for bearer authentication. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun token(): Optional = token.getOptional("token") - - /** - * Password for basic authentication. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun password(): Optional = password.getOptional("password") - - /** - * Username for basic authentication. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun username(): Optional = username.getOptional("username") - - /** - * Returns the raw JSON value of [mode]. - * - * Unlike [mode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode - - /** - * Returns the raw JSON value of [token]. - * - * Unlike [token], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - - /** - * Returns the raw JSON value of [password]. - * - * Unlike [password], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("password") - @ExcludeMissing - fun _password(): JsonField = password - - /** - * Returns the raw JSON value of [username]. - * - * Unlike [username], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("username") - @ExcludeMissing - fun _username(): JsonField = username - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [Authentication]. - * - * The following fields are required: - * ```java - * .mode() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Authentication]. */ - class Builder internal constructor() { - - private var mode: JsonField? = null - private var token: JsonField = JsonMissing.of() - private var password: JsonField = JsonMissing.of() - private var username: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(authentication: Authentication) = apply { - mode = authentication.mode - token = authentication.token - password = authentication.password - username = authentication.username - additionalProperties = - authentication.additionalProperties.toMutableMap() - } - - /** The authentication mode to use. Defaults to 'none' if not specified. */ - fun mode(mode: Mode) = mode(JsonField.of(mode)) - - /** - * Sets [Builder.mode] to an arbitrary JSON value. - * - * You should usually call [Builder.mode] with a well-typed [Mode] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun mode(mode: JsonField) = apply { this.mode = mode } - - /** Token for bearer authentication. */ - fun token(token: String?) = token(JsonField.ofNullable(token)) - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - /** Password for basic authentication. */ - fun password(password: String?) = password(JsonField.ofNullable(password)) - - /** Alias for calling [Builder.password] with `password.orElse(null)`. */ - fun password(password: Optional) = password(password.getOrNull()) - - /** - * Sets [Builder.password] to an arbitrary JSON value. - * - * You should usually call [Builder.password] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun password(password: JsonField) = apply { - this.password = password - } - - /** Username for basic authentication. */ - fun username(username: String?) = username(JsonField.ofNullable(username)) - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - /** - * Sets [Builder.username] to an arbitrary JSON value. - * - * You should usually call [Builder.username] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun username(username: JsonField) = apply { - this.username = username - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Authentication]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .mode() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Authentication = - Authentication( - checkRequired("mode", mode), - token, - password, - username, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Authentication = apply { - if (validated) { - return@apply - } - - mode().validate() - token() - password() - username() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (mode.asKnown().getOrNull()?.validity() ?: 0) + - (if (token.asKnown().isPresent) 1 else 0) + - (if (password.asKnown().isPresent) 1 else 0) + - (if (username.asKnown().isPresent) 1 else 0) - - /** The authentication mode to use. Defaults to 'none' if not specified. */ - class Mode - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val NONE = of("none") - - @JvmField val BASIC = of("basic") - - @JvmField val BEARER = of("bearer") - - @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) - } - - /** An enum containing [Mode]'s known values. */ - enum class Known { - NONE, - BASIC, - BEARER, - } - - /** - * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Mode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - BASIC, - BEARER, - /** - * An enum member indicating that [Mode] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - BASIC -> Value.BASIC - BEARER -> Value.BEARER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - BASIC -> Known.BASIC - BEARER -> Known.BEARER - else -> throw CourierInvalidDataException("Unknown Mode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Mode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Mode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Authentication && - mode == other.mode && - token == other.token && - password == other.password && - username == other.username && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(mode, token, password, username, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Authentication{mode=$mode, token=$token, password=$password, username=$username, additionalProperties=$additionalProperties}" - } - - /** Custom headers to include in the webhook request. */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Headers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Headers{additionalProperties=$additionalProperties}" - } - - /** - * The HTTP method to use for the webhook request. Defaults to POST if not - * specified. - */ - class Method - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val POST = of("POST") - - @JvmField val PUT = of("PUT") - - @JvmStatic fun of(value: String) = Method(JsonField.of(value)) - } - - /** An enum containing [Method]'s known values. */ - enum class Known { - POST, - PUT, - } - - /** - * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Method] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - POST, - PUT, - /** - * An enum member indicating that [Method] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - POST -> Value.POST - PUT -> Value.PUT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - POST -> Known.POST - PUT -> Known.PUT - else -> throw CourierInvalidDataException("Unknown Method: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Method = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Method && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Specifies what profile information is included in the request payload. Defaults - * to 'limited' if not specified. - */ - class Profile - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val LIMITED = of("limited") - - @JvmField val EXPANDED = of("expanded") - - @JvmStatic fun of(value: String) = Profile(JsonField.of(value)) - } - - /** An enum containing [Profile]'s known values. */ - enum class Known { - LIMITED, - EXPANDED, - } - - /** - * An enum containing [Profile]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Profile] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIMITED, - EXPANDED, - /** - * An enum member indicating that [Profile] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIMITED -> Value.LIMITED - EXPANDED -> Value.EXPANDED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - LIMITED -> Known.LIMITED - EXPANDED -> Known.EXPANDED - else -> throw CourierInvalidDataException("Unknown Profile: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Webhook && - url == other.url && - authentication == other.authentication && - headers == other.headers && - method == other.method && - profile == other.profile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - url, - authentication, - headers, - method, - profile, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Webhook{url=$url, authentication=$authentication, headers=$headers, method=$method, profile=$profile, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WebhookRecipient && - webhook == other.webhook && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(webhook, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookRecipient{webhook=$webhook, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BaseMessageSendTo && - to == other.to && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(to, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BaseMessageSendTo{to=$to, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt deleted file mode 100644 index 03d4d2e2..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Content.kt +++ /dev/null @@ -1,412 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.templates.ElementalContent -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional - -/** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ -@JsonDeserialize(using = Content.Deserializer::class) -@JsonSerialize(using = Content.Serializer::class) -class Content -private constructor( - private val elemental: ElementalContent? = null, - private val elementalContentSugar: ElementalContentSugar? = null, - private val _json: JsonValue? = null, -) { - - fun elemental(): Optional = Optional.ofNullable(elemental) - - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ - fun elementalContentSugar(): Optional = - Optional.ofNullable(elementalContentSugar) - - fun isElemental(): Boolean = elemental != null - - fun isElementalContentSugar(): Boolean = elementalContentSugar != null - - fun asElemental(): ElementalContent = elemental.getOrThrow("elemental") - - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ - fun asElementalContentSugar(): ElementalContentSugar = - elementalContentSugar.getOrThrow("elementalContentSugar") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - elemental != null -> visitor.visitElemental(elemental) - elementalContentSugar != null -> - visitor.visitElementalContentSugar(elementalContentSugar) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Content = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitElemental(elemental: ElementalContent) { - elemental.validate() - } - - override fun visitElementalContentSugar( - elementalContentSugar: ElementalContentSugar - ) { - elementalContentSugar.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitElemental(elemental: ElementalContent) = elemental.validity() - - override fun visitElementalContentSugar( - elementalContentSugar: ElementalContentSugar - ) = elementalContentSugar.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Content && - elemental == other.elemental && - elementalContentSugar == other.elementalContentSugar - } - - override fun hashCode(): Int = Objects.hash(elemental, elementalContentSugar) - - override fun toString(): String = - when { - elemental != null -> "Content{elemental=$elemental}" - elementalContentSugar != null -> "Content{elementalContentSugar=$elementalContentSugar}" - _json != null -> "Content{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Content") - } - - companion object { - - @JvmStatic fun ofElemental(elemental: ElementalContent) = Content(elemental = elemental) - - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ - @JvmStatic - fun ofElementalContentSugar(elementalContentSugar: ElementalContentSugar) = - Content(elementalContentSugar = elementalContentSugar) - } - - /** An interface that defines how to map each variant of [Content] to a value of type [T]. */ - interface Visitor { - - fun visitElemental(elemental: ElementalContent): T - - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ - fun visitElementalContentSugar(elementalContentSugar: ElementalContentSugar): T - - /** - * Maps an unknown variant of [Content] to a value of type [T]. - * - * An instance of [Content] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Content: $json") - } - } - - internal class Deserializer : BaseDeserializer(Content::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Content { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Content(elemental = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Content(elementalContentSugar = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> Content(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Content::class) { - - override fun serialize( - value: Content, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.elemental != null -> generator.writeObject(value.elemental) - value.elementalContentSugar != null -> - generator.writeObject(value.elementalContentSugar) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Content") - } - } - } - - /** Syntatic Sugar to provide a fast shorthand for Courier Elemental Blocks. */ - class ElementalContentSugar - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val body: JsonField, - private val title: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), - @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - ) : this(body, title, mutableMapOf()) - - /** - * The text content displayed in the notification. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun body(): String = body.getRequired("body") - - /** - * The title to be displayed by supported channels i.e. push, email (as subject) - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun title(): String = title.getRequired("title") - - /** - * Returns the raw JSON value of [body]. - * - * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - - /** - * Returns the raw JSON value of [title]. - * - * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalContentSugar]. - * - * The following fields are required: - * ```java - * .body() - * .title() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalContentSugar]. */ - class Builder internal constructor() { - - private var body: JsonField? = null - private var title: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalContentSugar: ElementalContentSugar) = apply { - body = elementalContentSugar.body - title = elementalContentSugar.title - additionalProperties = elementalContentSugar.additionalProperties.toMutableMap() - } - - /** The text content displayed in the notification. */ - fun body(body: String) = body(JsonField.of(body)) - - /** - * Sets [Builder.body] to an arbitrary JSON value. - * - * You should usually call [Builder.body] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun body(body: JsonField) = apply { this.body = body } - - /** The title to be displayed by supported channels i.e. push, email (as subject) */ - fun title(title: String) = title(JsonField.of(title)) - - /** - * Sets [Builder.title] to an arbitrary JSON value. - * - * You should usually call [Builder.title] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun title(title: JsonField) = apply { this.title = title } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalContentSugar]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .body() - * .title() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalContentSugar = - ElementalContentSugar( - checkRequired("body", body), - checkRequired("title", title), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalContentSugar = apply { - if (validated) { - return@apply - } - - body() - title() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (body.asKnown().isPresent) 1 else 0) + (if (title.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalContentSugar && - body == other.body && - title == other.title && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(body, title, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalContentSugar{body=$body, title=$title, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt deleted file mode 100644 index 50851d78..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Message.kt +++ /dev/null @@ -1,1873 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.bulk.UserRecipient -import com.courier.api.models.tenants.templates.ElementalContent -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Describes the content of the message in a way that will work for email, push, chat, or any - * channel. - */ -@JsonDeserialize(using = Message.Deserializer::class) -@JsonSerialize(using = Message.Serializer::class) -class Message -private constructor( - private val content: ContentMessage? = null, - private val template: TemplateMessage? = null, - private val _json: JsonValue? = null, -) { - - /** - * Describes the content of the message in a way that will work for email, push, chat, or any - * channel. - */ - fun content(): Optional = Optional.ofNullable(content) - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - fun template(): Optional = Optional.ofNullable(template) - - fun isContent(): Boolean = content != null - - fun isTemplate(): Boolean = template != null - - /** - * Describes the content of the message in a way that will work for email, push, chat, or any - * channel. - */ - fun asContent(): ContentMessage = content.getOrThrow("content") - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - fun asTemplate(): TemplateMessage = template.getOrThrow("template") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - content != null -> visitor.visitContent(content) - template != null -> visitor.visitTemplate(template) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Message = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitContent(content: ContentMessage) { - content.validate() - } - - override fun visitTemplate(template: TemplateMessage) { - template.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitContent(content: ContentMessage) = content.validity() - - override fun visitTemplate(template: TemplateMessage) = template.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Message && content == other.content && template == other.template - } - - override fun hashCode(): Int = Objects.hash(content, template) - - override fun toString(): String = - when { - content != null -> "Message{content=$content}" - template != null -> "Message{template=$template}" - _json != null -> "Message{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Message") - } - - companion object { - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. - */ - @JvmStatic fun ofContent(content: ContentMessage) = Message(content = content) - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - @JvmStatic fun ofTemplate(template: TemplateMessage) = Message(template = template) - } - - /** An interface that defines how to map each variant of [Message] to a value of type [T]. */ - interface Visitor { - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. - */ - fun visitContent(content: ContentMessage): T - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - fun visitTemplate(template: TemplateMessage): T - - /** - * Maps an unknown variant of [Message] to a value of type [T]. - * - * An instance of [Message] can contain an unknown variant if it was deserialized from data - * that doesn't match any known variant. For example, if the SDK is on an older version than - * the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Message: $json") - } - } - - internal class Deserializer : BaseDeserializer(Message::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Message { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Message(content = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Message(template = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> Message(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Message::class) { - - override fun serialize( - value: Message, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.content != null -> generator.writeObject(value.content) - value.template != null -> generator.writeObject(value.template) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Message") - } - } - } - - /** - * Describes the content of the message in a way that will work for email, push, chat, or any - * channel. - */ - class ContentMessage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val brandId: JsonField, - private val channels: JsonField, - private val context: JsonField, - private val data: JsonField, - private val delay: JsonField, - private val expiry: JsonField, - private val metadata: JsonField, - private val preferences: JsonField, - private val providers: JsonField, - private val routing: JsonField, - private val timeout: JsonField, - private val to: JsonField, - private val content: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - context: JsonField = JsonMissing.of(), - @JsonProperty("data") - @ExcludeMissing - data: JsonField = JsonMissing.of(), - @JsonProperty("delay") - @ExcludeMissing - delay: JsonField = JsonMissing.of(), - @JsonProperty("expiry") - @ExcludeMissing - expiry: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField = JsonMissing.of(), - @JsonProperty("routing") - @ExcludeMissing - routing: JsonField = JsonMissing.of(), - @JsonProperty("timeout") - @ExcludeMissing - timeout: JsonField = JsonMissing.of(), - @JsonProperty("to") - @ExcludeMissing - to: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - ) : this( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - to, - content, - mutableMapOf(), - ) - - fun toBaseMessage(): BaseMessage = - BaseMessage.builder() - .brandId(brandId) - .channels(channels) - .context(context) - .data(data) - .delay(delay) - .expiry(expiry) - .metadata(metadata) - .preferences(preferences) - .providers(providers) - .routing(routing) - .timeout(timeout) - .build() - - fun toBaseMessageSendTo(): BaseMessageSendTo = BaseMessageSendTo.builder().to(to).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * "Define run-time configuration for one or more channels. If you don't specify channels, - * the default configuration for each channel will be used. Valid ChannelId's are: email, - * sms, push, inbox, direct_message, banner, and webhook." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional = channels.getOptional("channels") - - /** - * Context to load with this recipient. Will override any context set on message.context. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * An arbitrary object that includes any data you want to pass to the message. The data will - * populate the corresponding template or elements variables. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an ISO - * 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap - * opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun delay(): Optional = delay.getOptional("delay") - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. Note: - * This is only valid for the Courier Inbox channel as of 12-08-2022." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiry(): Optional = expiry.getOptional("expiry") - - /** - * Metadata such as utm tracking attached with the notification through this channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = - preferences.getOptional("preferences") - - /** - * An object whose keys are valid provider identifiers which map to an object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun providers(): Optional = providers.getOptional("providers") - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the message. If - * no routing key is specified, Courier will use the default routing configuration or - * routing defined by the template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun routing(): Optional = routing.getOptional("routing") - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun timeout(): Optional = timeout.getOptional("timeout") - - /** - * The recipient or a list of recipients of the message - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * Describes the content of the message in a way that will work for email, push, chat, or - * any channel. Either this or template must be specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun content(): Content = content.getRequired("content") - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField = channels - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [delay]. - * - * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay - - /** - * Returns the raw JSON value of [expiry]. - * - * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry") - @ExcludeMissing - fun _expiry(): JsonField = expiry - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("providers") - @ExcludeMissing - fun _providers(): JsonField = providers - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") - @ExcludeMissing - fun _routing(): JsonField = routing - - /** - * Returns the raw JSON value of [timeout]. - * - * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timeout") - @ExcludeMissing - fun _timeout(): JsonField = timeout - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ContentMessage]. - * - * The following fields are required: - * ```java - * .content() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ContentMessage]. */ - class Builder internal constructor() { - - private var brandId: JsonField = JsonMissing.of() - private var channels: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var delay: JsonField = JsonMissing.of() - private var expiry: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var providers: JsonField = JsonMissing.of() - private var routing: JsonField = JsonMissing.of() - private var timeout: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var content: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(contentMessage: ContentMessage) = apply { - brandId = contentMessage.brandId - channels = contentMessage.channels - context = contentMessage.context - data = contentMessage.data - delay = contentMessage.delay - expiry = contentMessage.expiry - metadata = contentMessage.metadata - preferences = contentMessage.preferences - providers = contentMessage.providers - routing = contentMessage.routing - timeout = contentMessage.timeout - to = contentMessage.to - content = contentMessage.content - additionalProperties = contentMessage.additionalProperties.toMutableMap() - } - - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * "Define run-time configuration for one or more channels. If you don't specify - * channels, the default configuration for each channel will be used. Valid ChannelId's - * are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - fun channels(channels: BaseMessage.Channels?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed [BaseMessage.Channels] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun channels(channels: JsonField) = apply { - this.channels = channels - } - - /** - * Context to load with this recipient. Will override any context set on - * message.context. - */ - fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [MessageContext] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - /** - * An arbitrary object that includes any data you want to pass to the message. The data - * will populate the corresponding template or elements variables. - */ - fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an - * ISO 8601 timestamp that specifies when it should be delivered. Until with an - * OpenStreetMap opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) - - /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ - fun delay(delay: Optional) = delay(delay.getOrNull()) - - /** - * Sets [Builder.delay] to an arbitrary JSON value. - * - * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun delay(delay: JsonField) = apply { this.delay = delay } - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) - - /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ - fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) - - /** - * Sets [Builder.expiry] to an arbitrary JSON value. - * - * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiry(expiry: JsonField) = apply { this.expiry = expiry } - - /** - * Metadata such as utm tracking attached with the notification through this channel. - */ - fun metadata(metadata: BaseMessage.Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [BaseMessage.Metadata] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun preferences(preferences: BaseMessage.Preferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [BaseMessage.Preferences] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** An object whose keys are valid provider identifiers which map to an object. */ - fun providers(providers: BaseMessage.Providers?) = - providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional) = - providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed [BaseMessage.Providers] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun providers(providers: JsonField) = apply { - this.providers = providers - } - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the - * message. If no routing key is specified, Courier will use the default routing - * configuration or routing defined by the template. - */ - fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) - - /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ - fun routing(routing: Optional) = routing(routing.getOrNull()) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun routing(routing: JsonField) = apply { this.routing = routing } - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - */ - fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) - - /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ - fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) - - /** - * Sets [Builder.timeout] to an arbitrary JSON value. - * - * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun timeout(timeout: JsonField) = apply { this.timeout = timeout } - - /** The recipient or a list of recipients of the message */ - fun to(to: BaseMessageSendTo.To?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [BaseMessageSendTo.To] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun to(to: JsonField) = apply { this.to = to } - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)`. - */ - fun to(audienceRecipient: BaseMessageSendTo.To.AudienceRecipient) = - to(BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)) - - /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember1(unionMember1)`. */ - fun to(unionMember1: BaseMessageSendTo.To.UnionMember1) = - to(BaseMessageSendTo.To.ofUnionMember1(unionMember1)) - - /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember2(unionMember2)`. */ - fun to(unionMember2: BaseMessageSendTo.To.UnionMember2) = - to(BaseMessageSendTo.To.ofUnionMember2(unionMember2)) - - /** - * Alias for calling [to] with `BaseMessageSendTo.To.ofUserRecipient(userRecipient)`. - */ - fun to(userRecipient: UserRecipient) = - to(BaseMessageSendTo.To.ofUserRecipient(userRecipient)) - - /** - * Alias for calling [to] with `BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)`. - */ - fun to(slackRecipient: BaseMessageSendTo.To.SlackRecipient) = - to(BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)) - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)`. - */ - fun to(msTeamsRecipient: BaseMessageSendTo.To.MsTeamsRecipient) = - to(BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)) - - /** - * Alias for calling [to] with `BaseMessageSendTo.To.ofRecipientData(recipientData)`. - */ - fun to(recipientData: BaseMessageSendTo.To.RecipientData) = - to(BaseMessageSendTo.To.ofRecipientData(recipientData)) - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)`. - */ - fun to(pagerdutyRecipient: BaseMessageSendTo.To.PagerdutyRecipient) = - to(BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)) - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)`. - */ - fun to(webhookRecipient: BaseMessageSendTo.To.WebhookRecipient) = - to(BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)) - - /** Alias for calling [to] with `BaseMessageSendTo.To.ofRecipients(recipients)`. */ - fun toOfRecipients(recipients: List) = - to(BaseMessageSendTo.To.ofRecipients(recipients)) - - /** - * Describes the content of the message in a way that will work for email, push, chat, - * or any channel. Either this or template must be specified. - */ - fun content(content: Content) = content(JsonField.of(content)) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [Content] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - /** Alias for calling [content] with `Content.ofElemental(elemental)`. */ - fun content(elemental: ElementalContent) = content(Content.ofElemental(elemental)) - - /** - * Alias for calling [content] with - * `Content.ofElementalContentSugar(elementalContentSugar)`. - */ - fun content(elementalContentSugar: Content.ElementalContentSugar) = - content(Content.ofElementalContentSugar(elementalContentSugar)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ContentMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .content() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ContentMessage = - ContentMessage( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - to, - checkRequired("content", content), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ContentMessage = apply { - if (validated) { - return@apply - } - - brandId() - channels().ifPresent { it.validate() } - context().ifPresent { it.validate() } - data().ifPresent { it.validate() } - delay().ifPresent { it.validate() } - expiry().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - preferences().ifPresent { it.validate() } - providers().ifPresent { it.validate() } - routing().ifPresent { it.validate() } - timeout().ifPresent { it.validate() } - to().ifPresent { it.validate() } - content().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brandId.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.validity() ?: 0) + - (context.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (delay.asKnown().getOrNull()?.validity() ?: 0) + - (expiry.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.validity() ?: 0) + - (routing.asKnown().getOrNull()?.validity() ?: 0) + - (timeout.asKnown().getOrNull()?.validity() ?: 0) + - (to.asKnown().getOrNull()?.validity() ?: 0) + - (content.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ContentMessage && - brandId == other.brandId && - channels == other.channels && - context == other.context && - data == other.data && - delay == other.delay && - expiry == other.expiry && - metadata == other.metadata && - preferences == other.preferences && - providers == other.providers && - routing == other.routing && - timeout == other.timeout && - to == other.to && - content == other.content && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - to, - content, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ContentMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, to=$to, content=$content, additionalProperties=$additionalProperties}" - } - - /** - * A template for a type of message that can be sent more than once. For example, you might - * create an "Appointment Reminder" Notification or “Reset Password” Notifications. - */ - class TemplateMessage - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val brandId: JsonField, - private val channels: JsonField, - private val context: JsonField, - private val data: JsonField, - private val delay: JsonField, - private val expiry: JsonField, - private val metadata: JsonField, - private val preferences: JsonField, - private val providers: JsonField, - private val routing: JsonField, - private val timeout: JsonField, - private val to: JsonField, - private val template: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField = JsonMissing.of(), - @JsonProperty("context") - @ExcludeMissing - context: JsonField = JsonMissing.of(), - @JsonProperty("data") - @ExcludeMissing - data: JsonField = JsonMissing.of(), - @JsonProperty("delay") - @ExcludeMissing - delay: JsonField = JsonMissing.of(), - @JsonProperty("expiry") - @ExcludeMissing - expiry: JsonField = JsonMissing.of(), - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of(), - @JsonProperty("preferences") - @ExcludeMissing - preferences: JsonField = JsonMissing.of(), - @JsonProperty("providers") - @ExcludeMissing - providers: JsonField = JsonMissing.of(), - @JsonProperty("routing") - @ExcludeMissing - routing: JsonField = JsonMissing.of(), - @JsonProperty("timeout") - @ExcludeMissing - timeout: JsonField = JsonMissing.of(), - @JsonProperty("to") - @ExcludeMissing - to: JsonField = JsonMissing.of(), - @JsonProperty("template") @ExcludeMissing template: JsonField = JsonMissing.of(), - ) : this( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - to, - template, - mutableMapOf(), - ) - - fun toBaseMessage(): BaseMessage = - BaseMessage.builder() - .brandId(brandId) - .channels(channels) - .context(context) - .data(data) - .delay(delay) - .expiry(expiry) - .metadata(metadata) - .preferences(preferences) - .providers(providers) - .routing(routing) - .timeout(timeout) - .build() - - fun toBaseMessageSendTo(): BaseMessageSendTo = BaseMessageSendTo.builder().to(to).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * "Define run-time configuration for one or more channels. If you don't specify channels, - * the default configuration for each channel will be used. Valid ChannelId's are: email, - * sms, push, inbox, direct_message, banner, and webhook." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional = channels.getOptional("channels") - - /** - * Context to load with this recipient. Will override any context set on message.context. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun context(): Optional = context.getOptional("context") - - /** - * An arbitrary object that includes any data you want to pass to the message. The data will - * populate the corresponding template or elements variables. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an ISO - * 8601 timestamp that specifies when it should be delivered. Until with an OpenStreetMap - * opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun delay(): Optional = delay.getOptional("delay") - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. Note: - * This is only valid for the Courier Inbox channel as of 12-08-2022." - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiry(): Optional = expiry.getOptional("expiry") - - /** - * Metadata such as utm tracking attached with the notification through this channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preferences(): Optional = - preferences.getOptional("preferences") - - /** - * An object whose keys are valid provider identifiers which map to an object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun providers(): Optional = providers.getOptional("providers") - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the message. If - * no routing key is specified, Courier will use the default routing configuration or - * routing defined by the template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun routing(): Optional = routing.getOptional("routing") - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun timeout(): Optional = timeout.getOptional("timeout") - - /** - * The recipient or a list of recipients of the message - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * The id of the notification template to be rendered and sent to the recipient(s). This - * field or the content field must be supplied. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun template(): String = template.getRequired("template") - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField = channels - - /** - * Returns the raw JSON value of [context]. - * - * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [delay]. - * - * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay - - /** - * Returns the raw JSON value of [expiry]. - * - * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry") - @ExcludeMissing - fun _expiry(): JsonField = expiry - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - /** - * Returns the raw JSON value of [preferences]. - * - * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("preferences") - @ExcludeMissing - fun _preferences(): JsonField = preferences - - /** - * Returns the raw JSON value of [providers]. - * - * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("providers") - @ExcludeMissing - fun _providers(): JsonField = providers - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") - @ExcludeMissing - fun _routing(): JsonField = routing - - /** - * Returns the raw JSON value of [timeout]. - * - * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("timeout") - @ExcludeMissing - fun _timeout(): JsonField = timeout - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - /** - * Returns the raw JSON value of [template]. - * - * Unlike [template], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("template") @ExcludeMissing fun _template(): JsonField = template - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TemplateMessage]. - * - * The following fields are required: - * ```java - * .template() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TemplateMessage]. */ - class Builder internal constructor() { - - private var brandId: JsonField = JsonMissing.of() - private var channels: JsonField = JsonMissing.of() - private var context: JsonField = JsonMissing.of() - private var data: JsonField = JsonMissing.of() - private var delay: JsonField = JsonMissing.of() - private var expiry: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var preferences: JsonField = JsonMissing.of() - private var providers: JsonField = JsonMissing.of() - private var routing: JsonField = JsonMissing.of() - private var timeout: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var template: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(templateMessage: TemplateMessage) = apply { - brandId = templateMessage.brandId - channels = templateMessage.channels - context = templateMessage.context - data = templateMessage.data - delay = templateMessage.delay - expiry = templateMessage.expiry - metadata = templateMessage.metadata - preferences = templateMessage.preferences - providers = templateMessage.providers - routing = templateMessage.routing - timeout = templateMessage.timeout - to = templateMessage.to - template = templateMessage.template - additionalProperties = templateMessage.additionalProperties.toMutableMap() - } - - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * "Define run-time configuration for one or more channels. If you don't specify - * channels, the default configuration for each channel will be used. Valid ChannelId's - * are: email, sms, push, inbox, direct_message, banner, and webhook." - */ - fun channels(channels: BaseMessage.Channels?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed [BaseMessage.Channels] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun channels(channels: JsonField) = apply { - this.channels = channels - } - - /** - * Context to load with this recipient. Will override any context set on - * message.context. - */ - fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - - /** Alias for calling [Builder.context] with `context.orElse(null)`. */ - fun context(context: Optional) = context(context.getOrNull()) - - /** - * Sets [Builder.context] to an arbitrary JSON value. - * - * You should usually call [Builder.context] with a well-typed [MessageContext] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun context(context: JsonField) = apply { this.context = context } - - /** - * An arbitrary object that includes any data you want to pass to the message. The data - * will populate the corresponding template or elements variables. - */ - fun data(data: BaseMessage.Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [BaseMessage.Data] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun data(data: JsonField) = apply { this.data = data } - - /** - * Defines the time to wait before delivering the message. You can specify one of the - * following options. Duration with the number of milliseconds to delay. Until with an - * ISO 8601 timestamp that specifies when it should be delivered. Until with an - * OpenStreetMap opening_hours-like format that specifies the - * [Delivery Window](https://www.courier.com/docs/platform/sending/failover/#delivery-window) - * (e.g., 'Mo-Fr 08:00-18:00pm') - */ - fun delay(delay: BaseMessage.Delay?) = delay(JsonField.ofNullable(delay)) - - /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ - fun delay(delay: Optional) = delay(delay.getOrNull()) - - /** - * Sets [Builder.delay] to an arbitrary JSON value. - * - * You should usually call [Builder.delay] with a well-typed [BaseMessage.Delay] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun delay(delay: JsonField) = apply { this.delay = delay } - - /** - * "Expiry allows you to set an absolute or relative time in which a message expires. - * Note: This is only valid for the Courier Inbox channel as of 12-08-2022." - */ - fun expiry(expiry: BaseMessage.Expiry?) = expiry(JsonField.ofNullable(expiry)) - - /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ - fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) - - /** - * Sets [Builder.expiry] to an arbitrary JSON value. - * - * You should usually call [Builder.expiry] with a well-typed [BaseMessage.Expiry] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiry(expiry: JsonField) = apply { this.expiry = expiry } - - /** - * Metadata such as utm tracking attached with the notification through this channel. - */ - fun metadata(metadata: BaseMessage.Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [BaseMessage.Metadata] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun preferences(preferences: BaseMessage.Preferences?) = - preferences(JsonField.ofNullable(preferences)) - - /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ - fun preferences(preferences: Optional) = - preferences(preferences.getOrNull()) - - /** - * Sets [Builder.preferences] to an arbitrary JSON value. - * - * You should usually call [Builder.preferences] with a well-typed - * [BaseMessage.Preferences] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun preferences(preferences: JsonField) = apply { - this.preferences = preferences - } - - /** An object whose keys are valid provider identifiers which map to an object. */ - fun providers(providers: BaseMessage.Providers?) = - providers(JsonField.ofNullable(providers)) - - /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ - fun providers(providers: Optional) = - providers(providers.getOrNull()) - - /** - * Sets [Builder.providers] to an arbitrary JSON value. - * - * You should usually call [Builder.providers] with a well-typed [BaseMessage.Providers] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun providers(providers: JsonField) = apply { - this.providers = providers - } - - /** - * Allows you to customize which channel(s) Courier will potentially deliver the - * message. If no routing key is specified, Courier will use the default routing - * configuration or routing defined by the template. - */ - fun routing(routing: BaseMessage.Routing?) = routing(JsonField.ofNullable(routing)) - - /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ - fun routing(routing: Optional) = routing(routing.getOrNull()) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [BaseMessage.Routing] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun routing(routing: JsonField) = apply { this.routing = routing } - - /** - * Time in ms to attempt the channel before failing over to the next available channel. - */ - fun timeout(timeout: BaseMessage.Timeout?) = timeout(JsonField.ofNullable(timeout)) - - /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ - fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) - - /** - * Sets [Builder.timeout] to an arbitrary JSON value. - * - * You should usually call [Builder.timeout] with a well-typed [BaseMessage.Timeout] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun timeout(timeout: JsonField) = apply { this.timeout = timeout } - - /** The recipient or a list of recipients of the message */ - fun to(to: BaseMessageSendTo.To?) = to(JsonField.ofNullable(to)) - - /** Alias for calling [Builder.to] with `to.orElse(null)`. */ - fun to(to: Optional) = to(to.getOrNull()) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [BaseMessageSendTo.To] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun to(to: JsonField) = apply { this.to = to } - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)`. - */ - fun to(audienceRecipient: BaseMessageSendTo.To.AudienceRecipient) = - to(BaseMessageSendTo.To.ofAudienceRecipient(audienceRecipient)) - - /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember1(unionMember1)`. */ - fun to(unionMember1: BaseMessageSendTo.To.UnionMember1) = - to(BaseMessageSendTo.To.ofUnionMember1(unionMember1)) - - /** Alias for calling [to] with `BaseMessageSendTo.To.ofUnionMember2(unionMember2)`. */ - fun to(unionMember2: BaseMessageSendTo.To.UnionMember2) = - to(BaseMessageSendTo.To.ofUnionMember2(unionMember2)) - - /** - * Alias for calling [to] with `BaseMessageSendTo.To.ofUserRecipient(userRecipient)`. - */ - fun to(userRecipient: UserRecipient) = - to(BaseMessageSendTo.To.ofUserRecipient(userRecipient)) - - /** - * Alias for calling [to] with `BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)`. - */ - fun to(slackRecipient: BaseMessageSendTo.To.SlackRecipient) = - to(BaseMessageSendTo.To.ofSlackRecipient(slackRecipient)) - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)`. - */ - fun to(msTeamsRecipient: BaseMessageSendTo.To.MsTeamsRecipient) = - to(BaseMessageSendTo.To.ofMsTeamsRecipient(msTeamsRecipient)) - - /** - * Alias for calling [to] with `BaseMessageSendTo.To.ofRecipientData(recipientData)`. - */ - fun to(recipientData: BaseMessageSendTo.To.RecipientData) = - to(BaseMessageSendTo.To.ofRecipientData(recipientData)) - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)`. - */ - fun to(pagerdutyRecipient: BaseMessageSendTo.To.PagerdutyRecipient) = - to(BaseMessageSendTo.To.ofPagerdutyRecipient(pagerdutyRecipient)) - - /** - * Alias for calling [to] with - * `BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)`. - */ - fun to(webhookRecipient: BaseMessageSendTo.To.WebhookRecipient) = - to(BaseMessageSendTo.To.ofWebhookRecipient(webhookRecipient)) - - /** Alias for calling [to] with `BaseMessageSendTo.To.ofRecipients(recipients)`. */ - fun toOfRecipients(recipients: List) = - to(BaseMessageSendTo.To.ofRecipients(recipients)) - - /** - * The id of the notification template to be rendered and sent to the recipient(s). This - * field or the content field must be supplied. - */ - fun template(template: String) = template(JsonField.of(template)) - - /** - * Sets [Builder.template] to an arbitrary JSON value. - * - * You should usually call [Builder.template] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun template(template: JsonField) = apply { this.template = template } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TemplateMessage]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .template() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TemplateMessage = - TemplateMessage( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - to, - checkRequired("template", template), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TemplateMessage = apply { - if (validated) { - return@apply - } - - brandId() - channels().ifPresent { it.validate() } - context().ifPresent { it.validate() } - data().ifPresent { it.validate() } - delay().ifPresent { it.validate() } - expiry().ifPresent { it.validate() } - metadata().ifPresent { it.validate() } - preferences().ifPresent { it.validate() } - providers().ifPresent { it.validate() } - routing().ifPresent { it.validate() } - timeout().ifPresent { it.validate() } - to().ifPresent { it.validate() } - template() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (brandId.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.validity() ?: 0) + - (context.asKnown().getOrNull()?.validity() ?: 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (delay.asKnown().getOrNull()?.validity() ?: 0) + - (expiry.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + - (preferences.asKnown().getOrNull()?.validity() ?: 0) + - (providers.asKnown().getOrNull()?.validity() ?: 0) + - (routing.asKnown().getOrNull()?.validity() ?: 0) + - (timeout.asKnown().getOrNull()?.validity() ?: 0) + - (to.asKnown().getOrNull()?.validity() ?: 0) + - (if (template.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TemplateMessage && - brandId == other.brandId && - channels == other.channels && - context == other.context && - data == other.data && - delay == other.delay && - expiry == other.expiry && - metadata == other.metadata && - preferences == other.preferences && - providers == other.providers && - routing == other.routing && - timeout == other.timeout && - to == other.to && - template == other.template && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - brandId, - channels, - context, - data, - delay, - expiry, - metadata, - preferences, - providers, - routing, - timeout, - to, - template, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TemplateMessage{brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, to=$to, template=$template, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt index aeee3dbe..4420813d 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageContext.kt @@ -29,9 +29,7 @@ private constructor( ) : this(tenantId, mutableMapOf()) /** - * An id of a tenant, see [tenants api docs](https://www.courier.com/docs/reference/tenants/). - * Will load brand, default preferences and any other base context data associated with this - * tenant. + * Tenant id used to load brand/default preferences/context. * * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -75,11 +73,7 @@ private constructor( additionalProperties = messageContext.additionalProperties.toMutableMap() } - /** - * An id of a tenant, see - * [tenants api docs](https://www.courier.com/docs/reference/tenants/). Will load brand, - * default preferences and any other base context data associated with this tenant. - */ + /** Tenant id used to load brand/default preferences/context. */ fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageRouting.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageRouting.kt index 22f1008f..f4744708 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRouting.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageRouting.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.notifications +package com.courier.api.models.send import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageRoutingChannel.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageRoutingChannel.kt index 969cc112..937dcf9e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/notifications/MessageRoutingChannel.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MessageRoutingChannel.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.notifications +package com.courier.api.models.send import com.courier.api.core.BaseDeserializer import com.courier.api.core.BaseSerializer diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt deleted file mode 100644 index 80a88a0f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/MsTeamsBaseProperties.kt +++ /dev/null @@ -1,208 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class MsTeamsBaseProperties -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("service_url") @ExcludeMissing fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MsTeamsBaseProperties]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MsTeamsBaseProperties]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(msTeamsBaseProperties: MsTeamsBaseProperties) = apply { - serviceUrl = msTeamsBaseProperties.serviceUrl - tenantId = msTeamsBaseProperties.tenantId - additionalProperties = msTeamsBaseProperties.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { this.serviceUrl = serviceUrl } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MsTeamsBaseProperties]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MsTeamsBaseProperties = - MsTeamsBaseProperties( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MsTeamsBaseProperties = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MsTeamsBaseProperties && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(serviceUrl, tenantId, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MsTeamsBaseProperties{serviceUrl=$serviceUrl, tenantId=$tenantId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt index 4c0a61b7..a4d3115a 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Recipient.kt @@ -2,449 +2,618 @@ package com.courier.api.models.send -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum import com.courier.api.core.ExcludeMissing import com.courier.api.core.JsonField import com.courier.api.core.JsonMissing import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow import com.courier.api.core.toImmutable import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.bulk.UserRecipient import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.util.Collections import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -@JsonDeserialize(using = Recipient.Deserializer::class) -@JsonSerialize(using = Recipient.Serializer::class) class Recipient +@JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val audience: AudienceRecipient? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val user: UserRecipient? = null, - private val slack: SlackRecipient? = null, - private val msTeams: MsTeamsRecipient? = null, - private val data: RecipientData? = null, - private val pagerduty: PagerdutyRecipient? = null, - private val webhook: WebhookRecipient? = null, - private val _json: JsonValue? = null, + private val accountId: JsonField, + private val context: JsonField, + private val data: JsonField, + private val email: JsonField, + private val locale: JsonField, + private val phoneNumber: JsonField, + private val preferences: JsonField, + private val tenantId: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, ) { - fun audience(): Optional = Optional.ofNullable(audience) + @JsonCreator + private constructor( + @JsonProperty("account_id") @ExcludeMissing accountId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("locale") @ExcludeMissing locale: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + ) : this( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + mutableMapOf(), + ) - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + /** + * Use `tenant_id` instead. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accountId(): Optional = accountId.getOptional("account_id") - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + /** + * Context such as tenant_id to send the notification with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") - fun user(): Optional = Optional.ofNullable(user) + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") - fun slack(): Optional = Optional.ofNullable(slack) + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") - fun msTeams(): Optional = Optional.ofNullable(msTeams) + /** + * The user's preferred ISO 639-1 language code. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun locale(): Optional = locale.getOptional("locale") - fun data(): Optional = Optional.ofNullable(data) + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") - fun pagerduty(): Optional = Optional.ofNullable(pagerduty) + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") - fun webhook(): Optional = Optional.ofNullable(webhook) + /** + * Tenant id. Will load brand, default preferences and base context data. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tenantId(): Optional = tenantId.getOptional("tenant_id") - fun isAudience(): Boolean = audience != null + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("user_id") - fun isUnionMember1(): Boolean = unionMember1 != null + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId - fun isUnionMember2(): Boolean = unionMember2 != null + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context - fun isUser(): Boolean = user != null + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - fun isSlack(): Boolean = slack != null + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - fun isMsTeams(): Boolean = msTeams != null + /** + * Returns the raw JSON value of [locale]. + * + * Unlike [locale], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale - fun isData(): Boolean = data != null + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber - fun isPagerduty(): Boolean = pagerduty != null + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences - fun isWebhook(): Boolean = webhook != null + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId - fun asAudience(): AudienceRecipient = audience.getOrThrow("audience") + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asUser(): UserRecipient = user.getOrThrow("user") + fun toBuilder() = Builder().from(this) - fun asSlack(): SlackRecipient = slack.getOrThrow("slack") + companion object { - fun asMsTeams(): MsTeamsRecipient = msTeams.getOrThrow("msTeams") + /** Returns a mutable builder for constructing an instance of [Recipient]. */ + @JvmStatic fun builder() = Builder() + } - fun asData(): RecipientData = data.getOrThrow("data") + /** A builder for [Recipient]. */ + class Builder internal constructor() { - fun asPagerduty(): PagerdutyRecipient = pagerduty.getOrThrow("pagerduty") + private var accountId: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var locale: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var tenantId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun asWebhook(): WebhookRecipient = webhook.getOrThrow("webhook") + @JvmSynthetic + internal fun from(recipient: Recipient) = apply { + accountId = recipient.accountId + context = recipient.context + data = recipient.data + email = recipient.email + locale = recipient.locale + phoneNumber = recipient.phoneNumber + preferences = recipient.preferences + tenantId = recipient.tenantId + userId = recipient.userId + additionalProperties = recipient.additionalProperties.toMutableMap() + } - fun _json(): Optional = Optional.ofNullable(_json) + /** Use `tenant_id` instead. */ + fun accountId(accountId: String?) = accountId(JsonField.ofNullable(accountId)) - fun accept(visitor: Visitor): T = - when { - audience != null -> visitor.visitAudience(audience) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - user != null -> visitor.visitUser(user) - slack != null -> visitor.visitSlack(slack) - msTeams != null -> visitor.visitMsTeams(msTeams) - data != null -> visitor.visitData(data) - pagerduty != null -> visitor.visitPagerduty(pagerduty) - webhook != null -> visitor.visitWebhook(webhook) - else -> visitor.unknown(_json) - } + /** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */ + fun accountId(accountId: Optional) = accountId(accountId.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accountId(accountId: JsonField) = apply { this.accountId = accountId } - fun validate(): Recipient = apply { - if (validated) { - return@apply - } + /** Context such as tenant_id to send the notification with. */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) - accept( - object : Visitor { - override fun visitAudience(audience: AudienceRecipient) { - audience.validate() - } + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() - } + fun data(data: Data?) = data(JsonField.ofNullable(data)) - override fun visitUser(user: UserRecipient) { - user.validate() - } + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) - override fun visitSlack(slack: SlackRecipient) { - slack.validate() - } + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } - override fun visitMsTeams(msTeams: MsTeamsRecipient) { - msTeams.validate() - } + fun email(email: String?) = email(JsonField.ofNullable(email)) - override fun visitData(data: RecipientData) { - data.validate() - } + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional) = email(email.getOrNull()) - override fun visitPagerduty(pagerduty: PagerdutyRecipient) { - pagerduty.validate() - } + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } - override fun visitWebhook(webhook: WebhookRecipient) { - webhook.validate() - } - } - ) - validated = true - } + /** The user's preferred ISO 639-1 language code. */ + fun locale(locale: String?) = locale(JsonField.ofNullable(locale)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false + /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ + fun locale(locale: Optional) = locale(locale.getOrNull()) + + /** + * Sets [Builder.locale] to an arbitrary JSON value. + * + * You should usually call [Builder.locale] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun locale(locale: JsonField) = apply { this.locale = locale } + + fun phoneNumber(phoneNumber: String?) = phoneNumber(JsonField.ofNullable(phoneNumber)) + + /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ + fun phoneNumber(phoneNumber: Optional) = phoneNumber(phoneNumber.getOrNull()) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { this.phoneNumber = phoneNumber } + + fun preferences(preferences: Preferences?) = preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [Preferences] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences } - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitAudience(audience: AudienceRecipient) = audience.validity() + /** Tenant id. Will load brand, default preferences and base context data. */ + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) - override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - override fun visitUser(user: UserRecipient) = user.validity() + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - override fun visitSlack(slack: SlackRecipient) = slack.validity() + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) - override fun visitMsTeams(msTeams: MsTeamsRecipient) = msTeams.validity() + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } - override fun visitData(data: RecipientData) = data.validity() + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - override fun visitPagerduty(pagerduty: PagerdutyRecipient) = pagerduty.validity() + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun visitWebhook(webhook: WebhookRecipient) = webhook.validity() + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - override fun unknown(json: JsonValue?) = 0 - } - ) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - return other is Recipient && - audience == other.audience && - unionMember1 == other.unionMember1 && - unionMember2 == other.unionMember2 && - user == other.user && - slack == other.slack && - msTeams == other.msTeams && - data == other.data && - pagerduty == other.pagerduty && - webhook == other.webhook + /** + * Returns an immutable instance of [Recipient]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Recipient = + Recipient( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + additionalProperties.toMutableMap(), + ) } - override fun hashCode(): Int = - Objects.hash( - audience, - unionMember1, - unionMember2, - user, - slack, - msTeams, - data, - pagerduty, - webhook, - ) + private var validated: Boolean = false - override fun toString(): String = - when { - audience != null -> "Recipient{audience=$audience}" - unionMember1 != null -> "Recipient{unionMember1=$unionMember1}" - unionMember2 != null -> "Recipient{unionMember2=$unionMember2}" - user != null -> "Recipient{user=$user}" - slack != null -> "Recipient{slack=$slack}" - msTeams != null -> "Recipient{msTeams=$msTeams}" - data != null -> "Recipient{data=$data}" - pagerduty != null -> "Recipient{pagerduty=$pagerduty}" - webhook != null -> "Recipient{webhook=$webhook}" - _json != null -> "Recipient{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Recipient") + fun validate(): Recipient = apply { + if (validated) { + return@apply } - companion object { + accountId() + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + email() + locale() + phoneNumber() + preferences().ifPresent { it.validate() } + tenantId() + userId() + validated = true + } - @JvmStatic fun ofAudience(audience: AudienceRecipient) = Recipient(audience = audience) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = Recipient(unionMember1 = unionMember1) + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountId.asKnown().isPresent) 1 else 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (locale.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = Recipient(unionMember2 = unionMember2) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties - @JvmStatic fun ofUser(user: UserRecipient) = Recipient(user = user) + fun toBuilder() = Builder().from(this) - @JvmStatic fun ofSlack(slack: SlackRecipient) = Recipient(slack = slack) + companion object { - @JvmStatic fun ofMsTeams(msTeams: MsTeamsRecipient) = Recipient(msTeams = msTeams) + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun ofData(data: RecipientData) = Recipient(data = data) + /** A builder for [Data]. */ + class Builder internal constructor() { - @JvmStatic fun ofPagerduty(pagerduty: PagerdutyRecipient) = Recipient(pagerduty = pagerduty) + private var additionalProperties: MutableMap = mutableMapOf() - @JvmStatic fun ofWebhook(webhook: WebhookRecipient) = Recipient(webhook = webhook) - } + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } - /** An interface that defines how to map each variant of [Recipient] to a value of type [T]. */ - interface Visitor { + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun visitAudience(audience: AudienceRecipient): T + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitUnionMember1(unionMember1: UnionMember1): T + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitUnionMember2(unionMember2: UnionMember2): T + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun visitUser(user: UserRecipient): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun visitSlack(slack: SlackRecipient): T + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } - fun visitMsTeams(msTeams: MsTeamsRecipient): T + private var validated: Boolean = false - fun visitData(data: RecipientData): T + fun validate(): Data = apply { + if (validated) { + return@apply + } - fun visitPagerduty(pagerduty: PagerdutyRecipient): T + validated = true + } - fun visitWebhook(webhook: WebhookRecipient): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } /** - * Maps an unknown variant of [Recipient] to a value of type [T]. - * - * An instance of [Recipient] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws CourierInvalidDataException in the default implementation. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Recipient: $json") - } - } + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - internal class Deserializer : BaseDeserializer(Recipient::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Recipient { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(audience = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(unionMember2 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(user = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(slack = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(msTeams = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(data = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(pagerduty = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Recipient(webhook = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> Recipient(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Data && additionalProperties == other.additionalProperties } - } - internal class Serializer : BaseSerializer(Recipient::class) { + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - override fun serialize( - value: Recipient, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.audience != null -> generator.writeObject(value.audience) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.user != null -> generator.writeObject(value.user) - value.slack != null -> generator.writeObject(value.slack) - value.msTeams != null -> generator.writeObject(value.msTeams) - value.data != null -> generator.writeObject(value.data) - value.pagerduty != null -> generator.writeObject(value.pagerduty) - value.webhook != null -> generator.writeObject(value.webhook) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Recipient") - } - } + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" } - class AudienceRecipient + class Preferences @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val audienceId: JsonField, - private val data: JsonField, - private val filters: JsonField>, + private val notifications: JsonField, + private val categories: JsonField, + private val templateId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("audience_id") + @JsonProperty("notifications") + @ExcludeMissing + notifications: JsonField = JsonMissing.of(), + @JsonProperty("categories") @ExcludeMissing - audienceId: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("filters") + categories: JsonField = JsonMissing.of(), + @JsonProperty("templateId") @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - ) : this(audienceId, data, filters, mutableMapOf()) + templateId: JsonField = JsonMissing.of(), + ) : this(notifications, categories, templateId, mutableMapOf()) /** - * A unique identifier associated with an Audience. A message will be sent to each user in - * the audience. - * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun audienceId(): String = audienceId.getRequired("audience_id") + fun notifications(): Notifications = notifications.getRequired("notifications") /** * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun data(): Optional = data.getOptional("data") + fun categories(): Optional = categories.getOptional("categories") /** * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun filters(): Optional> = filters.getOptional("filters") + fun templateId(): Optional = templateId.getOptional("templateId") /** - * Returns the raw JSON value of [audienceId]. + * Returns the raw JSON value of [notifications]. * - * Unlike [audienceId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [notifications], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("audience_id") + @JsonProperty("notifications") @ExcludeMissing - fun _audienceId(): JsonField = audienceId + fun _notifications(): JsonField = notifications /** - * Returns the raw JSON value of [data]. + * Returns the raw JSON value of [categories]. * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories /** - * Returns the raw JSON value of [filters]. + * Returns the raw JSON value of [templateId]. * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [templateId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters + @JsonProperty("templateId") + @ExcludeMissing + fun _templateId(): JsonField = templateId @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -461,88 +630,75 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [AudienceRecipient]. + * Returns a mutable builder for constructing an instance of [Preferences]. * * The following fields are required: * ```java - * .audienceId() + * .notifications() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [AudienceRecipient]. */ + /** A builder for [Preferences]. */ class Builder internal constructor() { - private var audienceId: JsonField? = null - private var data: JsonField = JsonMissing.of() - private var filters: JsonField>? = null + private var notifications: JsonField? = null + private var categories: JsonField = JsonMissing.of() + private var templateId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(audienceRecipient: AudienceRecipient) = apply { - audienceId = audienceRecipient.audienceId - data = audienceRecipient.data - filters = audienceRecipient.filters.map { it.toMutableList() } - additionalProperties = audienceRecipient.additionalProperties.toMutableMap() + internal fun from(preferences: Preferences) = apply { + notifications = preferences.notifications + categories = preferences.categories + templateId = preferences.templateId + additionalProperties = preferences.additionalProperties.toMutableMap() } - /** - * A unique identifier associated with an Audience. A message will be sent to each user - * in the audience. - */ - fun audienceId(audienceId: String) = audienceId(JsonField.of(audienceId)) + fun notifications(notifications: Notifications) = + notifications(JsonField.of(notifications)) /** - * Sets [Builder.audienceId] to an arbitrary JSON value. + * Sets [Builder.notifications] to an arbitrary JSON value. * - * You should usually call [Builder.audienceId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.notifications] with a well-typed [Notifications] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun audienceId(audienceId: JsonField) = apply { this.audienceId = audienceId } + fun notifications(notifications: JsonField) = apply { + this.notifications = notifications + } - fun data(data: Data?) = data(JsonField.ofNullable(data)) + fun categories(categories: Categories?) = categories(JsonField.ofNullable(categories)) - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) + /** Alias for calling [Builder.categories] with `categories.orElse(null)`. */ + fun categories(categories: Optional) = categories(categories.getOrNull()) /** - * Sets [Builder.data] to an arbitrary JSON value. + * Sets [Builder.categories] to an arbitrary JSON value. * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.categories] with a well-typed [Categories] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun data(data: JsonField) = apply { this.data = data } + fun categories(categories: JsonField) = apply { + this.categories = categories + } - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) + fun templateId(templateId: String?) = templateId(JsonField.ofNullable(templateId)) - /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ - fun filters(filters: Optional>) = filters(filters.getOrNull()) + /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ + fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) /** - * Sets [Builder.filters] to an arbitrary JSON value. + * Sets [Builder.templateId] to an arbitrary JSON value. * - * You should usually call [Builder.filters] with a well-typed `List` value + * You should usually call [Builder.templateId] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } - - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } + fun templateId(templateId: JsonField) = apply { this.templateId = templateId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -564,36 +720,36 @@ private constructor( } /** - * Returns an immutable instance of [AudienceRecipient]. + * Returns an immutable instance of [Preferences]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .audienceId() + * .notifications() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): AudienceRecipient = - AudienceRecipient( - checkRequired("audienceId", audienceId), - data, - (filters ?: JsonMissing.of()).map { it.toImmutable() }, + fun build(): Preferences = + Preferences( + checkRequired("notifications", notifications), + categories, + templateId, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): AudienceRecipient = apply { + fun validate(): Preferences = apply { if (validated) { return@apply } - audienceId() - data().ifPresent { it.validate() } - filters().ifPresent { it.forEach { it.validate() } } + notifications().validate() + categories().ifPresent { it.validate() } + templateId() validated = true } @@ -613,11 +769,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (audienceId.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (notifications.asKnown().getOrNull()?.validity() ?: 0) + + (categories.asKnown().getOrNull()?.validity() ?: 0) + + (if (templateId.asKnown().isPresent) 1 else 0) - class Data + class Notifications @JsonCreator private constructor( @com.fasterxml.jackson.annotation.JsonValue @@ -632,18 +788,18 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Data]. */ + /** Returns a mutable builder for constructing an instance of [Notifications]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Data]. */ + /** A builder for [Notifications]. */ class Builder internal constructor() { private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() + internal fun from(notifications: Notifications) = apply { + additionalProperties = notifications.additionalProperties.toMutableMap() } fun additionalProperties(additionalProperties: Map) = apply { @@ -669,16 +825,16 @@ private constructor( } /** - * Returns an immutable instance of [Data]. + * Returns an immutable instance of [Notifications]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Data = Data(additionalProperties.toImmutable()) + fun build(): Notifications = Notifications(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): Data = apply { + fun validate(): Notifications = apply { if (validated) { return@apply } @@ -709,158 +865,45 @@ private constructor( return true } - return other is Data && additionalProperties == other.additionalProperties + return other is Notifications && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = "Data{additionalProperties=$additionalProperties}" + override fun toString() = "Notifications{additionalProperties=$additionalProperties}" } - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) + class Categories + @JsonCreator private constructor( - private val operator: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map ) { - @JsonCreator - private constructor( - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(operator, path, value, mutableMapOf()) - - /** - * Send to users only if they are member of the account - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun path(): Path = path.getRequired("path") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("operator") - @ExcludeMissing - fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - @JsonAnyGetter @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun _additionalProperties(): Map = additionalProperties fun toBuilder() = Builder().from(this) companion object { - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - */ + /** Returns a mutable builder for constructing an instance of [Categories]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Filter]. */ + /** A builder for [Categories]. */ class Builder internal constructor() { - private var operator: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(filter: Filter) = apply { - operator = filter.operator - path = filter.path - value = filter.value - additionalProperties = filter.additionalProperties.toMutableMap() + internal fun from(categories: Categories) = apply { + additionalProperties = categories.additionalProperties.toMutableMap() } - /** Send to users only if they are member of the account */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - fun path(path: Path) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [Path] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun path(path: JsonField) = apply { this.path = path } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -884,38 +927,20 @@ private constructor( } /** - * Returns an immutable instance of [Filter]. + * Returns an immutable instance of [Categories]. * * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. */ - fun build(): Filter = - Filter( - checkRequired("operator", operator), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) + fun build(): Categories = Categories(additionalProperties.toImmutable()) } private var validated: Boolean = false - fun validate(): Filter = apply { + fun validate(): Categories = apply { if (validated) { return@apply } - operator().validate() - path().validate() - value() validated = true } @@ -935,280 +960,21 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (path.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Send to users only if they are member of the account */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MEMBER_OF = of("MEMBER_OF") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - MEMBER_OF - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MEMBER_OF, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MEMBER_OF -> Value.MEMBER_OF - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MEMBER_OF -> Known.MEMBER_OF - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Path @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACCOUNT_ID = of("account_id") - - @JvmStatic fun of(value: String) = Path(JsonField.of(value)) - } - - /** An enum containing [Path]'s known values. */ - enum class Known { - ACCOUNT_ID - } - - /** - * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Path] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACCOUNT_ID, - /** - * An enum member indicating that [Path] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACCOUNT_ID -> Value.ACCOUNT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ACCOUNT_ID -> Known.ACCOUNT_ID - else -> throw CourierInvalidDataException("Unknown Path: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Path = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Path && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Filter && - operator == other.operator && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties + return other is Categories && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { - Objects.hash(operator, path, value, additionalProperties) - } + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } override fun hashCode(): Int = hashCode - override fun toString() = - "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" + override fun toString() = "Categories{additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -1216,5849 +982,58 @@ private constructor( return true } - return other is AudienceRecipient && - audienceId == other.audienceId && - data == other.data && - filters == other.filters && + return other is Preferences && + notifications == other.notifications && + categories == other.categories && + templateId == other.templateId && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(audienceId, data, filters, additionalProperties) + Objects.hash(notifications, categories, templateId, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "AudienceRecipient{audienceId=$audienceId, data=$data, filters=$filters, additionalProperties=$additionalProperties}" + "Preferences{notifications=$notifications, categories=$categories, templateId=$templateId, additionalProperties=$additionalProperties}" } - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonField, - private val filters: JsonField>, - private val listId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("filters") - @ExcludeMissing - filters: JsonField> = JsonMissing.of(), - @JsonProperty("list_id") @ExcludeMissing listId: JsonField = JsonMissing.of(), - ) : this(data, filters, listId, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun filters(): Optional> = filters.getOptional("filters") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun listId(): Optional = listId.getOptional("list_id") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [filters]. - * - * Unlike [filters], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("filters") @ExcludeMissing fun _filters(): JsonField> = filters - - /** - * Returns the raw JSON value of [listId]. - * - * Unlike [listId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("list_id") @ExcludeMissing fun _listId(): JsonField = listId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var data: JsonField = JsonMissing.of() - private var filters: JsonField>? = null - private var listId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - data = unionMember1.data - filters = unionMember1.filters.map { it.toMutableList() } - listId = unionMember1.listId - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun filters(filters: List?) = filters(JsonField.ofNullable(filters)) - - /** Alias for calling [Builder.filters] with `filters.orElse(null)`. */ - fun filters(filters: Optional>) = filters(filters.getOrNull()) - - /** - * Sets [Builder.filters] to an arbitrary JSON value. - * - * You should usually call [Builder.filters] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun filters(filters: JsonField>) = apply { - this.filters = filters.map { it.toMutableList() } - } - - /** - * Adds a single [Filter] to [filters]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFilter(filter: Filter) = apply { - filters = - (filters ?: JsonField.of(mutableListOf())).also { - checkKnown("filters", it).add(filter) - } - } - - fun listId(listId: String?) = listId(JsonField.ofNullable(listId)) - - /** Alias for calling [Builder.listId] with `listId.orElse(null)`. */ - fun listId(listId: Optional) = listId(listId.getOrNull()) - - /** - * Sets [Builder.listId] to an arbitrary JSON value. - * - * You should usually call [Builder.listId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun listId(listId: JsonField) = apply { this.listId = listId } + return other is Recipient && + accountId == other.accountId && + context == other.context && + data == other.data && + email == other.email && + locale == other.locale && + phoneNumber == other.phoneNumber && + preferences == other.preferences && + tenantId == other.tenantId && + userId == other.userId && + additionalProperties == other.additionalProperties + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private val hashCode: Int by lazy { + Objects.hash( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + additionalProperties, + ) + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + override fun hashCode(): Int = hashCode - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - data, - (filters ?: JsonMissing.of()).map { it.toImmutable() }, - listId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - data().ifPresent { it.validate() } - filters().ifPresent { it.forEach { it.validate() } } - listId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (data.asKnown().getOrNull()?.validity() ?: 0) + - (filters.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (listId.asKnown().isPresent) 1 else 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - class Filter - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val operator: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("operator") - @ExcludeMissing - operator: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(operator, path, value, mutableMapOf()) - - /** - * Send to users only if they are member of the account - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun operator(): Operator = operator.getRequired("operator") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun path(): Path = path.getRequired("path") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun value(): String = value.getRequired("value") - - /** - * Returns the raw JSON value of [operator]. - * - * Unlike [operator], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("operator") - @ExcludeMissing - fun _operator(): JsonField = operator - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Filter]. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Filter]. */ - class Builder internal constructor() { - - private var operator: JsonField? = null - private var path: JsonField? = null - private var value: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(filter: Filter) = apply { - operator = filter.operator - path = filter.path - value = filter.value - additionalProperties = filter.additionalProperties.toMutableMap() - } - - /** Send to users only if they are member of the account */ - fun operator(operator: Operator) = operator(JsonField.of(operator)) - - /** - * Sets [Builder.operator] to an arbitrary JSON value. - * - * You should usually call [Builder.operator] with a well-typed [Operator] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun operator(operator: JsonField) = apply { this.operator = operator } - - fun path(path: Path) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [Path] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun path(path: JsonField) = apply { this.path = path } - - fun value(value: String) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Filter]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .operator() - * .path() - * .value() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Filter = - Filter( - checkRequired("operator", operator), - checkRequired("path", path), - checkRequired("value", value), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Filter = apply { - if (validated) { - return@apply - } - - operator().validate() - path().validate() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (operator.asKnown().getOrNull()?.validity() ?: 0) + - (path.asKnown().getOrNull()?.validity() ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Send to users only if they are member of the account */ - class Operator @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val MEMBER_OF = of("MEMBER_OF") - - @JvmStatic fun of(value: String) = Operator(JsonField.of(value)) - } - - /** An enum containing [Operator]'s known values. */ - enum class Known { - MEMBER_OF - } - - /** - * An enum containing [Operator]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Operator] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - MEMBER_OF, - /** - * An enum member indicating that [Operator] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - MEMBER_OF -> Value.MEMBER_OF - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - MEMBER_OF -> Known.MEMBER_OF - else -> throw CourierInvalidDataException("Unknown Operator: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Operator = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Operator && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Path @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACCOUNT_ID = of("account_id") - - @JvmStatic fun of(value: String) = Path(JsonField.of(value)) - } - - /** An enum containing [Path]'s known values. */ - enum class Known { - ACCOUNT_ID - } - - /** - * An enum containing [Path]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Path] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACCOUNT_ID, - /** - * An enum member indicating that [Path] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACCOUNT_ID -> Value.ACCOUNT_ID - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - ACCOUNT_ID -> Known.ACCOUNT_ID - else -> throw CourierInvalidDataException("Unknown Path: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Path = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Path && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Filter && - operator == other.operator && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(operator, path, value, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Filter{operator=$operator, path=$path, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - data == other.data && - filters == other.filters && - listId == other.listId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(data, filters, listId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{data=$data, filters=$filters, listId=$listId, additionalProperties=$additionalProperties}" - } - - class UnionMember2 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val data: JsonField, - private val listPattern: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - @JsonProperty("list_pattern") - @ExcludeMissing - listPattern: JsonField = JsonMissing.of(), - ) : this(data, listPattern, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun data(): Optional = data.getOptional("data") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun listPattern(): Optional = listPattern.getOptional("list_pattern") - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - /** - * Returns the raw JSON value of [listPattern]. - * - * Unlike [listPattern], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("list_pattern") - @ExcludeMissing - fun _listPattern(): JsonField = listPattern - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember2]. */ - class Builder internal constructor() { - - private var data: JsonField = JsonMissing.of() - private var listPattern: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - data = unionMember2.data - listPattern = unionMember2.listPattern - additionalProperties = unionMember2.additionalProperties.toMutableMap() - } - - fun data(data: Data?) = data(JsonField.ofNullable(data)) - - /** Alias for calling [Builder.data] with `data.orElse(null)`. */ - fun data(data: Optional) = data(data.getOrNull()) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun listPattern(listPattern: String?) = listPattern(JsonField.ofNullable(listPattern)) - - /** Alias for calling [Builder.listPattern] with `listPattern.orElse(null)`. */ - fun listPattern(listPattern: Optional) = listPattern(listPattern.getOrNull()) - - /** - * Sets [Builder.listPattern] to an arbitrary JSON value. - * - * You should usually call [Builder.listPattern] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun listPattern(listPattern: JsonField) = apply { - this.listPattern = listPattern - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember2]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember2 = - UnionMember2(data, listPattern, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): UnionMember2 = apply { - if (validated) { - return@apply - } - - data().ifPresent { it.validate() } - listPattern() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (data.asKnown().getOrNull()?.validity() ?: 0) + - (if (listPattern.asKnown().isPresent) 1 else 0) - - class Data - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Data]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Data = Data(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Data{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - data == other.data && - listPattern == other.listPattern && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(data, listPattern, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember2{data=$data, listPattern=$listPattern, additionalProperties=$additionalProperties}" - } - - class SlackRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val slack: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("slack") @ExcludeMissing slack: JsonField = JsonMissing.of() - ) : this(slack, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun slack(): Slack = slack.getRequired("slack") - - /** - * Returns the raw JSON value of [slack]. - * - * Unlike [slack], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("slack") @ExcludeMissing fun _slack(): JsonField = slack - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SlackRecipient]. - * - * The following fields are required: - * ```java - * .slack() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SlackRecipient]. */ - class Builder internal constructor() { - - private var slack: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(slackRecipient: SlackRecipient) = apply { - slack = slackRecipient.slack - additionalProperties = slackRecipient.additionalProperties.toMutableMap() - } - - fun slack(slack: Slack) = slack(JsonField.of(slack)) - - /** - * Sets [Builder.slack] to an arbitrary JSON value. - * - * You should usually call [Builder.slack] with a well-typed [Slack] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun slack(slack: JsonField) = apply { this.slack = slack } - - /** Alias for calling [slack] with `Slack.ofSendToSlackChannel(sendToSlackChannel)`. */ - fun slack(sendToSlackChannel: Slack.SendToSlackChannel) = - slack(Slack.ofSendToSlackChannel(sendToSlackChannel)) - - /** Alias for calling [slack] with `Slack.ofSendToSlackEmail(sendToSlackEmail)`. */ - fun slack(sendToSlackEmail: Slack.SendToSlackEmail) = - slack(Slack.ofSendToSlackEmail(sendToSlackEmail)) - - /** Alias for calling [slack] with `Slack.ofSendToSlackUserId(sendToSlackUserId)`. */ - fun slack(sendToSlackUserId: Slack.SendToSlackUserId) = - slack(Slack.ofSendToSlackUserId(sendToSlackUserId)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SlackRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .slack() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SlackRecipient = - SlackRecipient(checkRequired("slack", slack), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): SlackRecipient = apply { - if (validated) { - return@apply - } - - slack().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (slack.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = Slack.Deserializer::class) - @JsonSerialize(using = Slack.Serializer::class) - class Slack - private constructor( - private val sendToSlackChannel: SendToSlackChannel? = null, - private val sendToSlackEmail: SendToSlackEmail? = null, - private val sendToSlackUserId: SendToSlackUserId? = null, - private val _json: JsonValue? = null, - ) { - - fun sendToSlackChannel(): Optional = - Optional.ofNullable(sendToSlackChannel) - - fun sendToSlackEmail(): Optional = - Optional.ofNullable(sendToSlackEmail) - - fun sendToSlackUserId(): Optional = - Optional.ofNullable(sendToSlackUserId) - - fun isSendToSlackChannel(): Boolean = sendToSlackChannel != null - - fun isSendToSlackEmail(): Boolean = sendToSlackEmail != null - - fun isSendToSlackUserId(): Boolean = sendToSlackUserId != null - - fun asSendToSlackChannel(): SendToSlackChannel = - sendToSlackChannel.getOrThrow("sendToSlackChannel") - - fun asSendToSlackEmail(): SendToSlackEmail = - sendToSlackEmail.getOrThrow("sendToSlackEmail") - - fun asSendToSlackUserId(): SendToSlackUserId = - sendToSlackUserId.getOrThrow("sendToSlackUserId") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - sendToSlackChannel != null -> - visitor.visitSendToSlackChannel(sendToSlackChannel) - sendToSlackEmail != null -> visitor.visitSendToSlackEmail(sendToSlackEmail) - sendToSlackUserId != null -> visitor.visitSendToSlackUserId(sendToSlackUserId) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Slack = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSendToSlackChannel( - sendToSlackChannel: SendToSlackChannel - ) { - sendToSlackChannel.validate() - } - - override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) { - sendToSlackEmail.validate() - } - - override fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) { - sendToSlackUserId.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitSendToSlackChannel( - sendToSlackChannel: SendToSlackChannel - ) = sendToSlackChannel.validity() - - override fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = - sendToSlackEmail.validity() - - override fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) = - sendToSlackUserId.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Slack && - sendToSlackChannel == other.sendToSlackChannel && - sendToSlackEmail == other.sendToSlackEmail && - sendToSlackUserId == other.sendToSlackUserId - } - - override fun hashCode(): Int = - Objects.hash(sendToSlackChannel, sendToSlackEmail, sendToSlackUserId) - - override fun toString(): String = - when { - sendToSlackChannel != null -> "Slack{sendToSlackChannel=$sendToSlackChannel}" - sendToSlackEmail != null -> "Slack{sendToSlackEmail=$sendToSlackEmail}" - sendToSlackUserId != null -> "Slack{sendToSlackUserId=$sendToSlackUserId}" - _json != null -> "Slack{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Slack") - } - - companion object { - - @JvmStatic - fun ofSendToSlackChannel(sendToSlackChannel: SendToSlackChannel) = - Slack(sendToSlackChannel = sendToSlackChannel) - - @JvmStatic - fun ofSendToSlackEmail(sendToSlackEmail: SendToSlackEmail) = - Slack(sendToSlackEmail = sendToSlackEmail) - - @JvmStatic - fun ofSendToSlackUserId(sendToSlackUserId: SendToSlackUserId) = - Slack(sendToSlackUserId = sendToSlackUserId) - } - - /** - * An interface that defines how to map each variant of [Slack] to a value of type [T]. - */ - interface Visitor { - - fun visitSendToSlackChannel(sendToSlackChannel: SendToSlackChannel): T - - fun visitSendToSlackEmail(sendToSlackEmail: SendToSlackEmail): T - - fun visitSendToSlackUserId(sendToSlackUserId: SendToSlackUserId): T - - /** - * Maps an unknown variant of [Slack] to a value of type [T]. - * - * An instance of [Slack] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown Slack: $json") - } - } - - internal class Deserializer : BaseDeserializer(Slack::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Slack { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Slack(sendToSlackChannel = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Slack(sendToSlackEmail = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Slack(sendToSlackUserId = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> Slack(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Slack::class) { - - override fun serialize( - value: Slack, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.sendToSlackChannel != null -> - generator.writeObject(value.sendToSlackChannel) - value.sendToSlackEmail != null -> - generator.writeObject(value.sendToSlackEmail) - value.sendToSlackUserId != null -> - generator.writeObject(value.sendToSlackUserId) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Slack") - } - } - } - - class SendToSlackChannel - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessToken: JsonField, - private val channel: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("channel") - @ExcludeMissing - channel: JsonField = JsonMissing.of(), - ) : this(accessToken, channel, mutableMapOf()) - - fun toSlackBaseProperties(): SlackBaseProperties = - SlackBaseProperties.builder().accessToken(accessToken).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToSlackChannel]. - * - * The following fields are required: - * ```java - * .accessToken() - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToSlackChannel]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var channel: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToSlackChannel: SendToSlackChannel) = apply { - accessToken = sendToSlackChannel.accessToken - channel = sendToSlackChannel.channel - additionalProperties = - sendToSlackChannel.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessToken(accessToken: JsonField) = apply { - this.accessToken = accessToken - } - - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToSlackChannel]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToSlackChannel = - SendToSlackChannel( - checkRequired("accessToken", accessToken), - checkRequired("channel", channel), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToSlackChannel = apply { - if (validated) { - return@apply - } - - accessToken() - channel() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (channel.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToSlackChannel && - accessToken == other.accessToken && - channel == other.channel && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, channel, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToSlackChannel{accessToken=$accessToken, channel=$channel, additionalProperties=$additionalProperties}" - } - - class SendToSlackEmail - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessToken: JsonField, - private val email: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - email: JsonField = JsonMissing.of(), - ) : this(accessToken, email, mutableMapOf()) - - fun toSlackBaseProperties(): SlackBaseProperties = - SlackBaseProperties.builder().accessToken(accessToken).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun email(): String = email.getRequired("email") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SendToSlackEmail]. - * - * The following fields are required: - * ```java - * .accessToken() - * .email() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToSlackEmail]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var email: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToSlackEmail: SendToSlackEmail) = apply { - accessToken = sendToSlackEmail.accessToken - email = sendToSlackEmail.email - additionalProperties = sendToSlackEmail.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessToken(accessToken: JsonField) = apply { - this.accessToken = accessToken - } - - fun email(email: String) = email(JsonField.of(email)) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToSlackEmail]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * .email() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToSlackEmail = - SendToSlackEmail( - checkRequired("accessToken", accessToken), - checkRequired("email", email), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToSlackEmail = apply { - if (validated) { - return@apply - } - - accessToken() - email() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (email.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToSlackEmail && - accessToken == other.accessToken && - email == other.email && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, email, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToSlackEmail{accessToken=$accessToken, email=$email, additionalProperties=$additionalProperties}" - } - - class SendToSlackUserId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val accessToken: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - userId: JsonField = JsonMissing.of(), - ) : this(accessToken, userId, mutableMapOf()) - - fun toSlackBaseProperties(): SlackBaseProperties = - SlackBaseProperties.builder().accessToken(accessToken).build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun userId(): String = userId.getRequired("user_id") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToSlackUserId]. - * - * The following fields are required: - * ```java - * .accessToken() - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToSlackUserId]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var userId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToSlackUserId: SendToSlackUserId) = apply { - accessToken = sendToSlackUserId.accessToken - userId = sendToSlackUserId.userId - additionalProperties = sendToSlackUserId.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun accessToken(accessToken: JsonField) = apply { - this.accessToken = accessToken - } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToSlackUserId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToSlackUserId = - SendToSlackUserId( - checkRequired("accessToken", accessToken), - checkRequired("userId", userId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToSlackUserId = apply { - if (validated) { - return@apply - } - - accessToken() - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (accessToken.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToSlackUserId && - accessToken == other.accessToken && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(accessToken, userId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToSlackUserId{accessToken=$accessToken, userId=$userId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SlackRecipient && - slack == other.slack && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(slack, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SlackRecipient{slack=$slack, additionalProperties=$additionalProperties}" - } - - class MsTeamsRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val msTeams: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("ms_teams") @ExcludeMissing msTeams: JsonField = JsonMissing.of() - ) : this(msTeams, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun msTeams(): MsTeams = msTeams.getRequired("ms_teams") - - /** - * Returns the raw JSON value of [msTeams]. - * - * Unlike [msTeams], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ms_teams") @ExcludeMissing fun _msTeams(): JsonField = msTeams - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [MsTeamsRecipient]. - * - * The following fields are required: - * ```java - * .msTeams() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MsTeamsRecipient]. */ - class Builder internal constructor() { - - private var msTeams: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(msTeamsRecipient: MsTeamsRecipient) = apply { - msTeams = msTeamsRecipient.msTeams - additionalProperties = msTeamsRecipient.additionalProperties.toMutableMap() - } - - fun msTeams(msTeams: MsTeams) = msTeams(JsonField.of(msTeams)) - - /** - * Sets [Builder.msTeams] to an arbitrary JSON value. - * - * You should usually call [Builder.msTeams] with a well-typed [MsTeams] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun msTeams(msTeams: JsonField) = apply { this.msTeams = msTeams } - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)`. - */ - fun msTeams(sendToMsTeamsUserId: MsTeams.SendToMsTeamsUserId) = - msTeams(MsTeams.ofSendToMsTeamsUserId(sendToMsTeamsUserId)) - - /** - * Alias for calling [msTeams] with `MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)`. - */ - fun msTeams(sendToMsTeamsEmail: MsTeams.SendToMsTeamsEmail) = - msTeams(MsTeams.ofSendToMsTeamsEmail(sendToMsTeamsEmail)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)`. - */ - fun msTeams(sendToMsTeamsChannelId: MsTeams.SendToMsTeamsChannelId) = - msTeams(MsTeams.ofSendToMsTeamsChannelId(sendToMsTeamsChannelId)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)`. - */ - fun msTeams(sendToMsTeamsConversationId: MsTeams.SendToMsTeamsConversationId) = - msTeams(MsTeams.ofSendToMsTeamsConversationId(sendToMsTeamsConversationId)) - - /** - * Alias for calling [msTeams] with - * `MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)`. - */ - fun msTeams(sendToMsTeamsChannelName: MsTeams.SendToMsTeamsChannelName) = - msTeams(MsTeams.ofSendToMsTeamsChannelName(sendToMsTeamsChannelName)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MsTeamsRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .msTeams() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): MsTeamsRecipient = - MsTeamsRecipient( - checkRequired("msTeams", msTeams), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): MsTeamsRecipient = apply { - if (validated) { - return@apply - } - - msTeams().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (msTeams.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = MsTeams.Deserializer::class) - @JsonSerialize(using = MsTeams.Serializer::class) - class MsTeams - private constructor( - private val sendToMsTeamsUserId: SendToMsTeamsUserId? = null, - private val sendToMsTeamsEmail: SendToMsTeamsEmail? = null, - private val sendToMsTeamsChannelId: SendToMsTeamsChannelId? = null, - private val sendToMsTeamsConversationId: SendToMsTeamsConversationId? = null, - private val sendToMsTeamsChannelName: SendToMsTeamsChannelName? = null, - private val _json: JsonValue? = null, - ) { - - fun sendToMsTeamsUserId(): Optional = - Optional.ofNullable(sendToMsTeamsUserId) - - fun sendToMsTeamsEmail(): Optional = - Optional.ofNullable(sendToMsTeamsEmail) - - fun sendToMsTeamsChannelId(): Optional = - Optional.ofNullable(sendToMsTeamsChannelId) - - fun sendToMsTeamsConversationId(): Optional = - Optional.ofNullable(sendToMsTeamsConversationId) - - fun sendToMsTeamsChannelName(): Optional = - Optional.ofNullable(sendToMsTeamsChannelName) - - fun isSendToMsTeamsUserId(): Boolean = sendToMsTeamsUserId != null - - fun isSendToMsTeamsEmail(): Boolean = sendToMsTeamsEmail != null - - fun isSendToMsTeamsChannelId(): Boolean = sendToMsTeamsChannelId != null - - fun isSendToMsTeamsConversationId(): Boolean = sendToMsTeamsConversationId != null - - fun isSendToMsTeamsChannelName(): Boolean = sendToMsTeamsChannelName != null - - fun asSendToMsTeamsUserId(): SendToMsTeamsUserId = - sendToMsTeamsUserId.getOrThrow("sendToMsTeamsUserId") - - fun asSendToMsTeamsEmail(): SendToMsTeamsEmail = - sendToMsTeamsEmail.getOrThrow("sendToMsTeamsEmail") - - fun asSendToMsTeamsChannelId(): SendToMsTeamsChannelId = - sendToMsTeamsChannelId.getOrThrow("sendToMsTeamsChannelId") - - fun asSendToMsTeamsConversationId(): SendToMsTeamsConversationId = - sendToMsTeamsConversationId.getOrThrow("sendToMsTeamsConversationId") - - fun asSendToMsTeamsChannelName(): SendToMsTeamsChannelName = - sendToMsTeamsChannelName.getOrThrow("sendToMsTeamsChannelName") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - sendToMsTeamsUserId != null -> - visitor.visitSendToMsTeamsUserId(sendToMsTeamsUserId) - sendToMsTeamsEmail != null -> - visitor.visitSendToMsTeamsEmail(sendToMsTeamsEmail) - sendToMsTeamsChannelId != null -> - visitor.visitSendToMsTeamsChannelId(sendToMsTeamsChannelId) - sendToMsTeamsConversationId != null -> - visitor.visitSendToMsTeamsConversationId(sendToMsTeamsConversationId) - sendToMsTeamsChannelName != null -> - visitor.visitSendToMsTeamsChannelName(sendToMsTeamsChannelName) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): MsTeams = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitSendToMsTeamsUserId( - sendToMsTeamsUserId: SendToMsTeamsUserId - ) { - sendToMsTeamsUserId.validate() - } - - override fun visitSendToMsTeamsEmail( - sendToMsTeamsEmail: SendToMsTeamsEmail - ) { - sendToMsTeamsEmail.validate() - } - - override fun visitSendToMsTeamsChannelId( - sendToMsTeamsChannelId: SendToMsTeamsChannelId - ) { - sendToMsTeamsChannelId.validate() - } - - override fun visitSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) { - sendToMsTeamsConversationId.validate() - } - - override fun visitSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ) { - sendToMsTeamsChannelName.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitSendToMsTeamsUserId( - sendToMsTeamsUserId: SendToMsTeamsUserId - ) = sendToMsTeamsUserId.validity() - - override fun visitSendToMsTeamsEmail( - sendToMsTeamsEmail: SendToMsTeamsEmail - ) = sendToMsTeamsEmail.validity() - - override fun visitSendToMsTeamsChannelId( - sendToMsTeamsChannelId: SendToMsTeamsChannelId - ) = sendToMsTeamsChannelId.validity() - - override fun visitSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) = sendToMsTeamsConversationId.validity() - - override fun visitSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ) = sendToMsTeamsChannelName.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MsTeams && - sendToMsTeamsUserId == other.sendToMsTeamsUserId && - sendToMsTeamsEmail == other.sendToMsTeamsEmail && - sendToMsTeamsChannelId == other.sendToMsTeamsChannelId && - sendToMsTeamsConversationId == other.sendToMsTeamsConversationId && - sendToMsTeamsChannelName == other.sendToMsTeamsChannelName - } - - override fun hashCode(): Int = - Objects.hash( - sendToMsTeamsUserId, - sendToMsTeamsEmail, - sendToMsTeamsChannelId, - sendToMsTeamsConversationId, - sendToMsTeamsChannelName, - ) - - override fun toString(): String = - when { - sendToMsTeamsUserId != null -> - "MsTeams{sendToMsTeamsUserId=$sendToMsTeamsUserId}" - sendToMsTeamsEmail != null -> "MsTeams{sendToMsTeamsEmail=$sendToMsTeamsEmail}" - sendToMsTeamsChannelId != null -> - "MsTeams{sendToMsTeamsChannelId=$sendToMsTeamsChannelId}" - sendToMsTeamsConversationId != null -> - "MsTeams{sendToMsTeamsConversationId=$sendToMsTeamsConversationId}" - sendToMsTeamsChannelName != null -> - "MsTeams{sendToMsTeamsChannelName=$sendToMsTeamsChannelName}" - _json != null -> "MsTeams{_unknown=$_json}" - else -> throw IllegalStateException("Invalid MsTeams") - } - - companion object { - - @JvmStatic - fun ofSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId) = - MsTeams(sendToMsTeamsUserId = sendToMsTeamsUserId) - - @JvmStatic - fun ofSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail) = - MsTeams(sendToMsTeamsEmail = sendToMsTeamsEmail) - - @JvmStatic - fun ofSendToMsTeamsChannelId(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = - MsTeams(sendToMsTeamsChannelId = sendToMsTeamsChannelId) - - @JvmStatic - fun ofSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ) = MsTeams(sendToMsTeamsConversationId = sendToMsTeamsConversationId) - - @JvmStatic - fun ofSendToMsTeamsChannelName(sendToMsTeamsChannelName: SendToMsTeamsChannelName) = - MsTeams(sendToMsTeamsChannelName = sendToMsTeamsChannelName) - } - - /** - * An interface that defines how to map each variant of [MsTeams] to a value of type - * [T]. - */ - interface Visitor { - - fun visitSendToMsTeamsUserId(sendToMsTeamsUserId: SendToMsTeamsUserId): T - - fun visitSendToMsTeamsEmail(sendToMsTeamsEmail: SendToMsTeamsEmail): T - - fun visitSendToMsTeamsChannelId(sendToMsTeamsChannelId: SendToMsTeamsChannelId): T - - fun visitSendToMsTeamsConversationId( - sendToMsTeamsConversationId: SendToMsTeamsConversationId - ): T - - fun visitSendToMsTeamsChannelName( - sendToMsTeamsChannelName: SendToMsTeamsChannelName - ): T - - /** - * Maps an unknown variant of [MsTeams] to a value of type [T]. - * - * An instance of [MsTeams] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown MsTeams: $json") - } - } - - internal class Deserializer : BaseDeserializer(MsTeams::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): MsTeams { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MsTeams(sendToMsTeamsUserId = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - MsTeams(sendToMsTeamsEmail = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { MsTeams(sendToMsTeamsChannelId = it, _json = json) }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { - MsTeams(sendToMsTeamsConversationId = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef()) - ?.let { MsTeams(sendToMsTeamsChannelName = it, _json = json) }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> MsTeams(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(MsTeams::class) { - - override fun serialize( - value: MsTeams, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.sendToMsTeamsUserId != null -> - generator.writeObject(value.sendToMsTeamsUserId) - value.sendToMsTeamsEmail != null -> - generator.writeObject(value.sendToMsTeamsEmail) - value.sendToMsTeamsChannelId != null -> - generator.writeObject(value.sendToMsTeamsChannelId) - value.sendToMsTeamsConversationId != null -> - generator.writeObject(value.sendToMsTeamsConversationId) - value.sendToMsTeamsChannelName != null -> - generator.writeObject(value.sendToMsTeamsChannelName) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid MsTeams") - } - } - } - - class SendToMsTeamsUserId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - userId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, userId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun userId(): String = userId.getRequired("user_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsUserId]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsUserId]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var userId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsUserId: SendToMsTeamsUserId) = apply { - serviceUrl = sendToMsTeamsUserId.serviceUrl - tenantId = sendToMsTeamsUserId.tenantId - userId = sendToMsTeamsUserId.userId - additionalProperties = - sendToMsTeamsUserId.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun userId(userId: String) = userId(JsonField.of(userId)) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsUserId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsUserId = - SendToMsTeamsUserId( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("userId", userId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsUserId = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsUserId && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, userId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsUserId{serviceUrl=$serviceUrl, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsEmail - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val email: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("email") - @ExcludeMissing - email: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, email, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun email(): String = email.getRequired("email") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsEmail]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .email() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsEmail]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var email: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsEmail: SendToMsTeamsEmail) = apply { - serviceUrl = sendToMsTeamsEmail.serviceUrl - tenantId = sendToMsTeamsEmail.tenantId - email = sendToMsTeamsEmail.email - additionalProperties = - sendToMsTeamsEmail.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun email(email: String) = email(JsonField.of(email)) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsEmail]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .email() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsEmail = - SendToMsTeamsEmail( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("email", email), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsEmail = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - email() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (email.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsEmail && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - email == other.email && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, email, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsEmail{serviceUrl=$serviceUrl, tenantId=$tenantId, email=$email, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsChannelId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val channelId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("channel_id") - @ExcludeMissing - channelId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, channelId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channelId(): String = channelId.getRequired("channel_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [channelId]. - * - * Unlike [channelId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("channel_id") - @ExcludeMissing - fun _channelId(): JsonField = channelId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsChannelId]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsChannelId]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var channelId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsChannelId: SendToMsTeamsChannelId) = apply { - serviceUrl = sendToMsTeamsChannelId.serviceUrl - tenantId = sendToMsTeamsChannelId.tenantId - channelId = sendToMsTeamsChannelId.channelId - additionalProperties = - sendToMsTeamsChannelId.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun channelId(channelId: String) = channelId(JsonField.of(channelId)) - - /** - * Sets [Builder.channelId] to an arbitrary JSON value. - * - * You should usually call [Builder.channelId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun channelId(channelId: JsonField) = apply { - this.channelId = channelId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsChannelId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsChannelId = - SendToMsTeamsChannelId( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("channelId", channelId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsChannelId = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - channelId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (channelId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsChannelId && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - channelId == other.channelId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, channelId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsChannelId{serviceUrl=$serviceUrl, tenantId=$tenantId, channelId=$channelId, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsConversationId - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val conversationId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("conversation_id") - @ExcludeMissing - conversationId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, conversationId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun conversationId(): String = conversationId.getRequired("conversation_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [conversationId]. - * - * Unlike [conversationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("conversation_id") - @ExcludeMissing - fun _conversationId(): JsonField = conversationId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsConversationId]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .conversationId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsConversationId]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var conversationId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsConversationId: SendToMsTeamsConversationId) = - apply { - serviceUrl = sendToMsTeamsConversationId.serviceUrl - tenantId = sendToMsTeamsConversationId.tenantId - conversationId = sendToMsTeamsConversationId.conversationId - additionalProperties = - sendToMsTeamsConversationId.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun conversationId(conversationId: String) = - conversationId(JsonField.of(conversationId)) - - /** - * Sets [Builder.conversationId] to an arbitrary JSON value. - * - * You should usually call [Builder.conversationId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun conversationId(conversationId: JsonField) = apply { - this.conversationId = conversationId - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsConversationId]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .conversationId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsConversationId = - SendToMsTeamsConversationId( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("conversationId", conversationId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsConversationId = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - conversationId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (conversationId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsConversationId && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - conversationId == other.conversationId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, conversationId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsConversationId{serviceUrl=$serviceUrl, tenantId=$tenantId, conversationId=$conversationId, additionalProperties=$additionalProperties}" - } - - class SendToMsTeamsChannelName - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val serviceUrl: JsonField, - private val tenantId: JsonField, - private val channelName: JsonField, - private val teamId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("service_url") - @ExcludeMissing - serviceUrl: JsonField = JsonMissing.of(), - @JsonProperty("tenant_id") - @ExcludeMissing - tenantId: JsonField = JsonMissing.of(), - @JsonProperty("channel_name") - @ExcludeMissing - channelName: JsonField = JsonMissing.of(), - @JsonProperty("team_id") - @ExcludeMissing - teamId: JsonField = JsonMissing.of(), - ) : this(serviceUrl, tenantId, channelName, teamId, mutableMapOf()) - - fun toMsTeamsBaseProperties(): MsTeamsBaseProperties = - MsTeamsBaseProperties.builder() - .serviceUrl(serviceUrl) - .tenantId(tenantId) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun serviceUrl(): String = serviceUrl.getRequired("service_url") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun channelName(): String = channelName.getRequired("channel_name") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun teamId(): String = teamId.getRequired("team_id") - - /** - * Returns the raw JSON value of [serviceUrl]. - * - * Unlike [serviceUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("service_url") - @ExcludeMissing - fun _serviceUrl(): JsonField = serviceUrl - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tenant_id") - @ExcludeMissing - fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [channelName]. - * - * Unlike [channelName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("channel_name") - @ExcludeMissing - fun _channelName(): JsonField = channelName - - /** - * Returns the raw JSON value of [teamId]. - * - * Unlike [teamId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("team_id") @ExcludeMissing fun _teamId(): JsonField = teamId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [SendToMsTeamsChannelName]. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelName() - * .teamId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendToMsTeamsChannelName]. */ - class Builder internal constructor() { - - private var serviceUrl: JsonField? = null - private var tenantId: JsonField? = null - private var channelName: JsonField? = null - private var teamId: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(sendToMsTeamsChannelName: SendToMsTeamsChannelName) = apply { - serviceUrl = sendToMsTeamsChannelName.serviceUrl - tenantId = sendToMsTeamsChannelName.tenantId - channelName = sendToMsTeamsChannelName.channelName - teamId = sendToMsTeamsChannelName.teamId - additionalProperties = - sendToMsTeamsChannelName.additionalProperties.toMutableMap() - } - - fun serviceUrl(serviceUrl: String) = serviceUrl(JsonField.of(serviceUrl)) - - /** - * Sets [Builder.serviceUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.serviceUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun serviceUrl(serviceUrl: JsonField) = apply { - this.serviceUrl = serviceUrl - } - - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - fun channelName(channelName: String) = channelName(JsonField.of(channelName)) - - /** - * Sets [Builder.channelName] to an arbitrary JSON value. - * - * You should usually call [Builder.channelName] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun channelName(channelName: JsonField) = apply { - this.channelName = channelName - } - - fun teamId(teamId: String) = teamId(JsonField.of(teamId)) - - /** - * Sets [Builder.teamId] to an arbitrary JSON value. - * - * You should usually call [Builder.teamId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun teamId(teamId: JsonField) = apply { this.teamId = teamId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SendToMsTeamsChannelName]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .serviceUrl() - * .tenantId() - * .channelName() - * .teamId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendToMsTeamsChannelName = - SendToMsTeamsChannelName( - checkRequired("serviceUrl", serviceUrl), - checkRequired("tenantId", tenantId), - checkRequired("channelName", channelName), - checkRequired("teamId", teamId), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SendToMsTeamsChannelName = apply { - if (validated) { - return@apply - } - - serviceUrl() - tenantId() - channelName() - teamId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (serviceUrl.asKnown().isPresent) 1 else 0) + - (if (tenantId.asKnown().isPresent) 1 else 0) + - (if (channelName.asKnown().isPresent) 1 else 0) + - (if (teamId.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendToMsTeamsChannelName && - serviceUrl == other.serviceUrl && - tenantId == other.tenantId && - channelName == other.channelName && - teamId == other.teamId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(serviceUrl, tenantId, channelName, teamId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SendToMsTeamsChannelName{serviceUrl=$serviceUrl, tenantId=$tenantId, channelName=$channelName, teamId=$teamId, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MsTeamsRecipient && - msTeams == other.msTeams && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(msTeams, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "MsTeamsRecipient{msTeams=$msTeams, additionalProperties=$additionalProperties}" - } - - class RecipientData - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [RecipientData]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [RecipientData]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(recipientData: RecipientData) = apply { - additionalProperties = recipientData.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [RecipientData]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): RecipientData = RecipientData(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): RecipientData = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is RecipientData && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "RecipientData{additionalProperties=$additionalProperties}" - } - - class PagerdutyRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val pagerduty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("pagerduty") - @ExcludeMissing - pagerduty: JsonField = JsonMissing.of() - ) : this(pagerduty, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun pagerduty(): Pagerduty = pagerduty.getRequired("pagerduty") - - /** - * Returns the raw JSON value of [pagerduty]. - * - * Unlike [pagerduty], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pagerduty") - @ExcludeMissing - fun _pagerduty(): JsonField = pagerduty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PagerdutyRecipient]. - * - * The following fields are required: - * ```java - * .pagerduty() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PagerdutyRecipient]. */ - class Builder internal constructor() { - - private var pagerduty: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pagerdutyRecipient: PagerdutyRecipient) = apply { - pagerduty = pagerdutyRecipient.pagerduty - additionalProperties = pagerdutyRecipient.additionalProperties.toMutableMap() - } - - fun pagerduty(pagerduty: Pagerduty) = pagerduty(JsonField.of(pagerduty)) - - /** - * Sets [Builder.pagerduty] to an arbitrary JSON value. - * - * You should usually call [Builder.pagerduty] with a well-typed [Pagerduty] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pagerduty(pagerduty: JsonField) = apply { this.pagerduty = pagerduty } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PagerdutyRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .pagerduty() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PagerdutyRecipient = - PagerdutyRecipient( - checkRequired("pagerduty", pagerduty), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PagerdutyRecipient = apply { - if (validated) { - return@apply - } - - pagerduty().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (pagerduty.asKnown().getOrNull()?.validity() ?: 0) - - class Pagerduty - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val eventAction: JsonField, - private val routingKey: JsonField, - private val severity: JsonField, - private val source: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("event_action") - @ExcludeMissing - eventAction: JsonField = JsonMissing.of(), - @JsonProperty("routing_key") - @ExcludeMissing - routingKey: JsonField = JsonMissing.of(), - @JsonProperty("severity") - @ExcludeMissing - severity: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - ) : this(eventAction, routingKey, severity, source, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun eventAction(): Optional = eventAction.getOptional("event_action") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun routingKey(): Optional = routingKey.getOptional("routing_key") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun severity(): Optional = severity.getOptional("severity") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * Returns the raw JSON value of [eventAction]. - * - * Unlike [eventAction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("event_action") - @ExcludeMissing - fun _eventAction(): JsonField = eventAction - - /** - * Returns the raw JSON value of [routingKey]. - * - * Unlike [routingKey], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("routing_key") - @ExcludeMissing - fun _routingKey(): JsonField = routingKey - - /** - * Returns the raw JSON value of [severity]. - * - * Unlike [severity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("severity") @ExcludeMissing fun _severity(): JsonField = severity - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Pagerduty]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Pagerduty]. */ - class Builder internal constructor() { - - private var eventAction: JsonField = JsonMissing.of() - private var routingKey: JsonField = JsonMissing.of() - private var severity: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(pagerduty: Pagerduty) = apply { - eventAction = pagerduty.eventAction - routingKey = pagerduty.routingKey - severity = pagerduty.severity - source = pagerduty.source - additionalProperties = pagerduty.additionalProperties.toMutableMap() - } - - fun eventAction(eventAction: String?) = - eventAction(JsonField.ofNullable(eventAction)) - - /** Alias for calling [Builder.eventAction] with `eventAction.orElse(null)`. */ - fun eventAction(eventAction: Optional) = - eventAction(eventAction.getOrNull()) - - /** - * Sets [Builder.eventAction] to an arbitrary JSON value. - * - * You should usually call [Builder.eventAction] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun eventAction(eventAction: JsonField) = apply { - this.eventAction = eventAction - } - - fun routingKey(routingKey: String?) = routingKey(JsonField.ofNullable(routingKey)) - - /** Alias for calling [Builder.routingKey] with `routingKey.orElse(null)`. */ - fun routingKey(routingKey: Optional) = routingKey(routingKey.getOrNull()) - - /** - * Sets [Builder.routingKey] to an arbitrary JSON value. - * - * You should usually call [Builder.routingKey] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun routingKey(routingKey: JsonField) = apply { - this.routingKey = routingKey - } - - fun severity(severity: String?) = severity(JsonField.ofNullable(severity)) - - /** Alias for calling [Builder.severity] with `severity.orElse(null)`. */ - fun severity(severity: Optional) = severity(severity.getOrNull()) - - /** - * Sets [Builder.severity] to an arbitrary JSON value. - * - * You should usually call [Builder.severity] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun severity(severity: JsonField) = apply { this.severity = severity } - - fun source(source: String?) = source(JsonField.ofNullable(source)) - - /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Pagerduty]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Pagerduty = - Pagerduty( - eventAction, - routingKey, - severity, - source, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Pagerduty = apply { - if (validated) { - return@apply - } - - eventAction() - routingKey() - severity() - source() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (eventAction.asKnown().isPresent) 1 else 0) + - (if (routingKey.asKnown().isPresent) 1 else 0) + - (if (severity.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Pagerduty && - eventAction == other.eventAction && - routingKey == other.routingKey && - severity == other.severity && - source == other.source && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(eventAction, routingKey, severity, source, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Pagerduty{eventAction=$eventAction, routingKey=$routingKey, severity=$severity, source=$source, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PagerdutyRecipient && - pagerduty == other.pagerduty && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(pagerduty, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PagerdutyRecipient{pagerduty=$pagerduty, additionalProperties=$additionalProperties}" - } - - class WebhookRecipient - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val webhook: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("webhook") @ExcludeMissing webhook: JsonField = JsonMissing.of() - ) : this(webhook, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun webhook(): Webhook = webhook.getRequired("webhook") - - /** - * Returns the raw JSON value of [webhook]. - * - * Unlike [webhook], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("webhook") @ExcludeMissing fun _webhook(): JsonField = webhook - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [WebhookRecipient]. - * - * The following fields are required: - * ```java - * .webhook() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookRecipient]. */ - class Builder internal constructor() { - - private var webhook: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webhookRecipient: WebhookRecipient) = apply { - webhook = webhookRecipient.webhook - additionalProperties = webhookRecipient.additionalProperties.toMutableMap() - } - - fun webhook(webhook: Webhook) = webhook(JsonField.of(webhook)) - - /** - * Sets [Builder.webhook] to an arbitrary JSON value. - * - * You should usually call [Builder.webhook] with a well-typed [Webhook] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun webhook(webhook: JsonField) = apply { this.webhook = webhook } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [WebhookRecipient]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .webhook() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): WebhookRecipient = - WebhookRecipient( - checkRequired("webhook", webhook), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): WebhookRecipient = apply { - if (validated) { - return@apply - } - - webhook().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (webhook.asKnown().getOrNull()?.validity() ?: 0) - - class Webhook - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val url: JsonField, - private val authentication: JsonField, - private val headers: JsonField, - private val method: JsonField, - private val profile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - @JsonProperty("authentication") - @ExcludeMissing - authentication: JsonField = JsonMissing.of(), - @JsonProperty("headers") - @ExcludeMissing - headers: JsonField = JsonMissing.of(), - @JsonProperty("method") - @ExcludeMissing - method: JsonField = JsonMissing.of(), - @JsonProperty("profile") - @ExcludeMissing - profile: JsonField = JsonMissing.of(), - ) : this(url, authentication, headers, method, profile, mutableMapOf()) - - /** - * The URL to send the webhook request to. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun url(): String = url.getRequired("url") - - /** - * Authentication configuration for the webhook request. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun authentication(): Optional = - authentication.getOptional("authentication") - - /** - * Custom headers to include in the webhook request. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun headers(): Optional = headers.getOptional("headers") - - /** - * The HTTP method to use for the webhook request. Defaults to POST if not specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun method(): Optional = method.getOptional("method") - - /** - * Specifies what profile information is included in the request payload. Defaults to - * 'limited' if not specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun profile(): Optional = profile.getOptional("profile") - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [authentication]. - * - * Unlike [authentication], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("authentication") - @ExcludeMissing - fun _authentication(): JsonField = authentication - - /** - * Returns the raw JSON value of [headers]. - * - * Unlike [headers], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonField = headers - - /** - * Returns the raw JSON value of [method]. - * - * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Webhook]. - * - * The following fields are required: - * ```java - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Webhook]. */ - class Builder internal constructor() { - - private var url: JsonField? = null - private var authentication: JsonField = JsonMissing.of() - private var headers: JsonField = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var profile: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webhook: Webhook) = apply { - url = webhook.url - authentication = webhook.authentication - headers = webhook.headers - method = webhook.method - profile = webhook.profile - additionalProperties = webhook.additionalProperties.toMutableMap() - } - - /** The URL to send the webhook request to. */ - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - /** Authentication configuration for the webhook request. */ - fun authentication(authentication: Authentication?) = - authentication(JsonField.ofNullable(authentication)) - - /** - * Alias for calling [Builder.authentication] with `authentication.orElse(null)`. - */ - fun authentication(authentication: Optional) = - authentication(authentication.getOrNull()) - - /** - * Sets [Builder.authentication] to an arbitrary JSON value. - * - * You should usually call [Builder.authentication] with a well-typed - * [Authentication] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun authentication(authentication: JsonField) = apply { - this.authentication = authentication - } - - /** Custom headers to include in the webhook request. */ - fun headers(headers: Headers?) = headers(JsonField.ofNullable(headers)) - - /** Alias for calling [Builder.headers] with `headers.orElse(null)`. */ - fun headers(headers: Optional) = headers(headers.getOrNull()) - - /** - * Sets [Builder.headers] to an arbitrary JSON value. - * - * You should usually call [Builder.headers] with a well-typed [Headers] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun headers(headers: JsonField) = apply { this.headers = headers } - - /** - * The HTTP method to use for the webhook request. Defaults to POST if not - * specified. - */ - fun method(method: Method?) = method(JsonField.ofNullable(method)) - - /** Alias for calling [Builder.method] with `method.orElse(null)`. */ - fun method(method: Optional) = method(method.getOrNull()) - - /** - * Sets [Builder.method] to an arbitrary JSON value. - * - * You should usually call [Builder.method] with a well-typed [Method] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun method(method: JsonField) = apply { this.method = method } - - /** - * Specifies what profile information is included in the request payload. Defaults - * to 'limited' if not specified. - */ - fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Webhook]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Webhook = - Webhook( - checkRequired("url", url), - authentication, - headers, - method, - profile, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Webhook = apply { - if (validated) { - return@apply - } - - url() - authentication().ifPresent { it.validate() } - headers().ifPresent { it.validate() } - method().ifPresent { it.validate() } - profile().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (url.asKnown().isPresent) 1 else 0) + - (authentication.asKnown().getOrNull()?.validity() ?: 0) + - (headers.asKnown().getOrNull()?.validity() ?: 0) + - (method.asKnown().getOrNull()?.validity() ?: 0) + - (profile.asKnown().getOrNull()?.validity() ?: 0) - - /** Authentication configuration for the webhook request. */ - class Authentication - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val mode: JsonField, - private val token: JsonField, - private val password: JsonField, - private val username: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), - @JsonProperty("token") - @ExcludeMissing - token: JsonField = JsonMissing.of(), - @JsonProperty("password") - @ExcludeMissing - password: JsonField = JsonMissing.of(), - @JsonProperty("username") - @ExcludeMissing - username: JsonField = JsonMissing.of(), - ) : this(mode, token, password, username, mutableMapOf()) - - /** - * The authentication mode to use. Defaults to 'none' if not specified. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun mode(): Mode = mode.getRequired("mode") - - /** - * Token for bearer authentication. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun token(): Optional = token.getOptional("token") - - /** - * Password for basic authentication. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun password(): Optional = password.getOptional("password") - - /** - * Username for basic authentication. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun username(): Optional = username.getOptional("username") - - /** - * Returns the raw JSON value of [mode]. - * - * Unlike [mode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode - - /** - * Returns the raw JSON value of [token]. - * - * Unlike [token], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - - /** - * Returns the raw JSON value of [password]. - * - * Unlike [password], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("password") - @ExcludeMissing - fun _password(): JsonField = password - - /** - * Returns the raw JSON value of [username]. - * - * Unlike [username], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("username") - @ExcludeMissing - fun _username(): JsonField = username - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Authentication]. - * - * The following fields are required: - * ```java - * .mode() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Authentication]. */ - class Builder internal constructor() { - - private var mode: JsonField? = null - private var token: JsonField = JsonMissing.of() - private var password: JsonField = JsonMissing.of() - private var username: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(authentication: Authentication) = apply { - mode = authentication.mode - token = authentication.token - password = authentication.password - username = authentication.username - additionalProperties = authentication.additionalProperties.toMutableMap() - } - - /** The authentication mode to use. Defaults to 'none' if not specified. */ - fun mode(mode: Mode) = mode(JsonField.of(mode)) - - /** - * Sets [Builder.mode] to an arbitrary JSON value. - * - * You should usually call [Builder.mode] with a well-typed [Mode] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun mode(mode: JsonField) = apply { this.mode = mode } - - /** Token for bearer authentication. */ - fun token(token: String?) = token(JsonField.ofNullable(token)) - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - /** Password for basic authentication. */ - fun password(password: String?) = password(JsonField.ofNullable(password)) - - /** Alias for calling [Builder.password] with `password.orElse(null)`. */ - fun password(password: Optional) = password(password.getOrNull()) - - /** - * Sets [Builder.password] to an arbitrary JSON value. - * - * You should usually call [Builder.password] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun password(password: JsonField) = apply { this.password = password } - - /** Username for basic authentication. */ - fun username(username: String?) = username(JsonField.ofNullable(username)) - - /** Alias for calling [Builder.username] with `username.orElse(null)`. */ - fun username(username: Optional) = username(username.getOrNull()) - - /** - * Sets [Builder.username] to an arbitrary JSON value. - * - * You should usually call [Builder.username] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun username(username: JsonField) = apply { this.username = username } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Authentication]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .mode() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Authentication = - Authentication( - checkRequired("mode", mode), - token, - password, - username, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Authentication = apply { - if (validated) { - return@apply - } - - mode().validate() - token() - password() - username() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (mode.asKnown().getOrNull()?.validity() ?: 0) + - (if (token.asKnown().isPresent) 1 else 0) + - (if (password.asKnown().isPresent) 1 else 0) + - (if (username.asKnown().isPresent) 1 else 0) - - /** The authentication mode to use. Defaults to 'none' if not specified. */ - class Mode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val NONE = of("none") - - @JvmField val BASIC = of("basic") - - @JvmField val BEARER = of("bearer") - - @JvmStatic fun of(value: String) = Mode(JsonField.of(value)) - } - - /** An enum containing [Mode]'s known values. */ - enum class Known { - NONE, - BASIC, - BEARER, - } - - /** - * An enum containing [Mode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Mode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NONE, - BASIC, - BEARER, - /** - * An enum member indicating that [Mode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NONE -> Value.NONE - BASIC -> Value.BASIC - BEARER -> Value.BEARER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - NONE -> Known.NONE - BASIC -> Known.BASIC - BEARER -> Known.BEARER - else -> throw CourierInvalidDataException("Unknown Mode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Mode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Mode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Authentication && - mode == other.mode && - token == other.token && - password == other.password && - username == other.username && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(mode, token, password, username, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Authentication{mode=$mode, token=$token, password=$password, username=$username, additionalProperties=$additionalProperties}" - } - - /** Custom headers to include in the webhook request. */ - class Headers - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Headers]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Headers]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(headers: Headers) = apply { - additionalProperties = headers.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Headers]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Headers = Headers(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Headers = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Headers && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Headers{additionalProperties=$additionalProperties}" - } - - /** - * The HTTP method to use for the webhook request. Defaults to POST if not specified. - */ - class Method @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val POST = of("POST") - - @JvmField val PUT = of("PUT") - - @JvmStatic fun of(value: String) = Method(JsonField.of(value)) - } - - /** An enum containing [Method]'s known values. */ - enum class Known { - POST, - PUT, - } - - /** - * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Method] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - POST, - PUT, - /** - * An enum member indicating that [Method] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - POST -> Value.POST - PUT -> Value.PUT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - POST -> Known.POST - PUT -> Known.PUT - else -> throw CourierInvalidDataException("Unknown Method: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Method = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Method && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Specifies what profile information is included in the request payload. Defaults to - * 'limited' if not specified. - */ - class Profile @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIMITED = of("limited") - - @JvmField val EXPANDED = of("expanded") - - @JvmStatic fun of(value: String) = Profile(JsonField.of(value)) - } - - /** An enum containing [Profile]'s known values. */ - enum class Known { - LIMITED, - EXPANDED, - } - - /** - * An enum containing [Profile]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Profile] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIMITED, - EXPANDED, - /** - * An enum member indicating that [Profile] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIMITED -> Value.LIMITED - EXPANDED -> Value.EXPANDED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - LIMITED -> Known.LIMITED - EXPANDED -> Known.EXPANDED - else -> throw CourierInvalidDataException("Unknown Profile: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Webhook && - url == other.url && - authentication == other.authentication && - headers == other.headers && - method == other.method && - profile == other.profile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(url, authentication, headers, method, profile, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Webhook{url=$url, authentication=$authentication, headers=$headers, method=$method, profile=$profile, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WebhookRecipient && - webhook == other.webhook && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(webhook, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookRecipient{webhook=$webhook, additionalProperties=$additionalProperties}" - } + override fun toString() = + "Recipient{accountId=$accountId, context=$context, data=$data, email=$email, locale=$locale, phoneNumber=$phoneNumber, preferences=$preferences, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt deleted file mode 100644 index 26f5c60f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt +++ /dev/null @@ -1,429 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -/** Use the send API to send a message to one or more recipients. */ -class SendMessageParams -private constructor( - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** - * Defines the message to be delivered - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): Message = body.message() - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _message(): JsonField = body._message() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SendMessageParams]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SendMessageParams]. */ - class Builder internal constructor() { - - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(sendMessageParams: SendMessageParams) = apply { - body = sendMessageParams.body.toBuilder() - additionalHeaders = sendMessageParams.additionalHeaders.toBuilder() - additionalQueryParams = sendMessageParams.additionalQueryParams.toBuilder() - } - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [message] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Defines the message to be delivered */ - fun message(message: Message) = apply { body.message(message) } - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [Message] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun message(message: JsonField) = apply { body.message(message) } - - /** Alias for calling [message] with `Message.ofContent(content)`. */ - fun message(content: Message.ContentMessage) = apply { body.message(content) } - - /** Alias for calling [message] with `Message.ofTemplate(template)`. */ - fun message(template: Message.TemplateMessage) = apply { body.message(template) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [SendMessageParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SendMessageParams = - SendMessageParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val message: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of() - ) : this(message, mutableMapOf()) - - /** - * Defines the message to be delivered - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): Message = message.getRequired("message") - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var message: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - message = body.message - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Defines the message to be delivered */ - fun message(message: Message) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [Message] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - /** Alias for calling [message] with `Message.ofContent(content)`. */ - fun message(content: Message.ContentMessage) = message(Message.ofContent(content)) - - /** Alias for calling [message] with `Message.ofTemplate(template)`. */ - fun message(template: Message.TemplateMessage) = message(Message.ofTemplate(template)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("message", message), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - message().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (message.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - message == other.message && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{message=$message, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SendMessageParams && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "SendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt new file mode 100644 index 00000000..57a3d730 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt @@ -0,0 +1,5284 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.Params +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.getOrThrow +import com.courier.api.core.http.Headers +import com.courier.api.core.http.QueryParams +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Use the send API to send a message to one or more recipients. */ +class SendSendMessageParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The message property has the following primary top-level properties. They define the + * destination and content of the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = body.message() + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _message(): JsonField = body._message() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SendSendMessageParams]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SendSendMessageParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(sendSendMessageParams: SendSendMessageParams) = apply { + body = sendSendMessageParams.body.toBuilder() + additionalHeaders = sendSendMessageParams.additionalHeaders.toBuilder() + additionalQueryParams = sendSendMessageParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [message] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * The message property has the following primary top-level properties. They define the + * destination and content of the message. + */ + fun message(message: Message) = apply { body.message(message) } + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { body.message(message) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SendSendMessageParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SendSendMessageParams = + SendSendMessageParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val message: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of() + ) : this(message, mutableMapOf()) + + /** + * The message property has the following primary top-level properties. They define the + * destination and content of the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .message() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var message: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + message = body.message + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * The message property has the following primary top-level properties. They define the + * destination and content of the message. + */ + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .message() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("message", message), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + message().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (message.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + message == other.message && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{message=$message, additionalProperties=$additionalProperties}" + } + + /** + * The message property has the following primary top-level properties. They define the + * destination and content of the message. + */ + class Message + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val brandId: JsonField, + private val channels: JsonField, + private val context: JsonField, + private val data: JsonField, + private val delay: JsonField, + private val expiry: JsonField, + private val metadata: JsonField, + private val preferences: JsonField, + private val providers: JsonField, + private val routing: JsonField, + private val timeout: JsonField, + private val to: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("delay") @ExcludeMissing delay: JsonField = JsonMissing.of(), + @JsonProperty("expiry") @ExcludeMissing expiry: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("providers") + @ExcludeMissing + providers: JsonField = JsonMissing.of(), + @JsonProperty("routing") @ExcludeMissing routing: JsonField = JsonMissing.of(), + @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this( + content, + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + mutableMapOf(), + ) + + /** + * Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun content(): Content = content.getRequired("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brandId(): Optional = brandId.getOptional("brand_id") + + /** + * Define run-time configuration for channels. Valid ChannelId's: email, sms, push, inbox, + * direct_message, banner, webhook. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun delay(): Optional = delay.getOptional("delay") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiry(): Optional = expiry.getOptional("expiry") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun metadata(): Optional = metadata.getOptional("metadata") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun providers(): Optional = providers.getOptional("providers") + + /** + * Customize which channels/providers Courier may deliver the message through. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun routing(): Optional = routing.getOptional("routing") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun timeout(): Optional = timeout.getOptional("timeout") + + /** + * The recipient or a list of recipients of the message + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun to(): Optional = to.getOptional("to") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [brandId]. + * + * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField = channels + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("context") @ExcludeMissing fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [delay]. + * + * Unlike [delay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("delay") @ExcludeMissing fun _delay(): JsonField = delay + + /** + * Returns the raw JSON value of [expiry]. + * + * Unlike [expiry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expiry") @ExcludeMissing fun _expiry(): JsonField = expiry + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [providers]. + * + * Unlike [providers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("providers") + @ExcludeMissing + fun _providers(): JsonField = providers + + /** + * Returns the raw JSON value of [routing]. + * + * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("routing") @ExcludeMissing fun _routing(): JsonField = routing + + /** + * Returns the raw JSON value of [timeout]. + * + * Unlike [timeout], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timeout") @ExcludeMissing fun _timeout(): JsonField = timeout + + /** + * Returns the raw JSON value of [to]. + * + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Message]. + * + * The following fields are required: + * ```java + * .content() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Message]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var brandId: JsonField = JsonMissing.of() + private var channels: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var delay: JsonField = JsonMissing.of() + private var expiry: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var providers: JsonField = JsonMissing.of() + private var routing: JsonField = JsonMissing.of() + private var timeout: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(message: Message) = apply { + content = message.content + brandId = message.brandId + channels = message.channels + context = message.context + data = message.data + delay = message.delay + expiry = message.expiry + metadata = message.metadata + preferences = message.preferences + providers = message.providers + routing = message.routing + timeout = message.timeout + to = message.to + additionalProperties = message.additionalProperties.toMutableMap() + } + + /** Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. */ + fun content(content: Content) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [Content] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) + + /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ + fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) + + /** + * Sets [Builder.brandId] to an arbitrary JSON value. + * + * You should usually call [Builder.brandId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brandId(brandId: JsonField) = apply { this.brandId = brandId } + + /** + * Define run-time configuration for channels. Valid ChannelId's: email, sms, push, + * inbox, direct_message, banner, webhook. + */ + fun channels(channels: Channels?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed [Channels] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField) = apply { this.channels = channels } + + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun context(context: JsonField) = apply { this.context = context } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun delay(delay: Delay?) = delay(JsonField.ofNullable(delay)) + + /** Alias for calling [Builder.delay] with `delay.orElse(null)`. */ + fun delay(delay: Optional) = delay(delay.getOrNull()) + + /** + * Sets [Builder.delay] to an arbitrary JSON value. + * + * You should usually call [Builder.delay] with a well-typed [Delay] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun delay(delay: JsonField) = apply { this.delay = delay } + + fun expiry(expiry: Expiry?) = expiry(JsonField.ofNullable(expiry)) + + /** Alias for calling [Builder.expiry] with `expiry.orElse(null)`. */ + fun expiry(expiry: Optional) = expiry(expiry.getOrNull()) + + /** + * Sets [Builder.expiry] to an arbitrary JSON value. + * + * You should usually call [Builder.expiry] with a well-typed [Expiry] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiry(expiry: JsonField) = apply { this.expiry = expiry } + + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun preferences(preferences: Preferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [Preferences] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + fun providers(providers: Providers?) = providers(JsonField.ofNullable(providers)) + + /** Alias for calling [Builder.providers] with `providers.orElse(null)`. */ + fun providers(providers: Optional) = providers(providers.getOrNull()) + + /** + * Sets [Builder.providers] to an arbitrary JSON value. + * + * You should usually call [Builder.providers] with a well-typed [Providers] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun providers(providers: JsonField) = apply { this.providers = providers } + + /** Customize which channels/providers Courier may deliver the message through. */ + fun routing(routing: Routing?) = routing(JsonField.ofNullable(routing)) + + /** Alias for calling [Builder.routing] with `routing.orElse(null)`. */ + fun routing(routing: Optional) = routing(routing.getOrNull()) + + /** + * Sets [Builder.routing] to an arbitrary JSON value. + * + * You should usually call [Builder.routing] with a well-typed [Routing] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun routing(routing: JsonField) = apply { this.routing = routing } + + fun timeout(timeout: Timeout?) = timeout(JsonField.ofNullable(timeout)) + + /** Alias for calling [Builder.timeout] with `timeout.orElse(null)`. */ + fun timeout(timeout: Optional) = timeout(timeout.getOrNull()) + + /** + * Sets [Builder.timeout] to an arbitrary JSON value. + * + * You should usually call [Builder.timeout] with a well-typed [Timeout] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timeout(timeout: JsonField) = apply { this.timeout = timeout } + + /** The recipient or a list of recipients of the message */ + fun to(to: To?) = to(JsonField.ofNullable(to)) + + /** Alias for calling [Builder.to] with `to.orElse(null)`. */ + fun to(to: Optional) = to(to.getOrNull()) + + /** + * Sets [Builder.to] to an arbitrary JSON value. + * + * You should usually call [Builder.to] with a well-typed [To] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun to(to: JsonField) = apply { this.to = to } + + /** Alias for calling [to] with `To.ofUnionMember0(unionMember0)`. */ + fun to(unionMember0: To.UnionMember0) = to(To.ofUnionMember0(unionMember0)) + + /** Alias for calling [to] with `To.ofRecipients(recipients)`. */ + fun toOfRecipients(recipients: List) = to(To.ofRecipients(recipients)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Message]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Message = + Message( + checkRequired("content", content), + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + content().validate() + brandId() + channels().ifPresent { it.validate() } + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + delay().ifPresent { it.validate() } + expiry().ifPresent { it.validate() } + metadata().ifPresent { it.validate() } + preferences().ifPresent { it.validate() } + providers().ifPresent { it.validate() } + routing().ifPresent { it.validate() } + timeout().ifPresent { it.validate() } + to().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (content.asKnown().getOrNull()?.validity() ?: 0) + + (if (brandId.asKnown().isPresent) 1 else 0) + + (channels.asKnown().getOrNull()?.validity() ?: 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (delay.asKnown().getOrNull()?.validity() ?: 0) + + (expiry.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (providers.asKnown().getOrNull()?.validity() ?: 0) + + (routing.asKnown().getOrNull()?.validity() ?: 0) + + (timeout.asKnown().getOrNull()?.validity() ?: 0) + + (to.asKnown().getOrNull()?.validity() ?: 0) + + /** Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks. */ + class Content + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val body: JsonField, + private val title: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), + @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), + ) : this(body, title, mutableMapOf()) + + /** + * The text content displayed in the notification. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun body(): String = body.getRequired("body") + + /** + * Title/subject displayed by supported channels. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun title(): String = title.getRequired("title") + + /** + * Returns the raw JSON value of [body]. + * + * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + + /** + * Returns the raw JSON value of [title]. + * + * Unlike [title], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Content]. + * + * The following fields are required: + * ```java + * .body() + * .title() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Content]. */ + class Builder internal constructor() { + + private var body: JsonField? = null + private var title: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(content: Content) = apply { + body = content.body + title = content.title + additionalProperties = content.additionalProperties.toMutableMap() + } + + /** The text content displayed in the notification. */ + fun body(body: String) = body(JsonField.of(body)) + + /** + * Sets [Builder.body] to an arbitrary JSON value. + * + * You should usually call [Builder.body] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun body(body: JsonField) = apply { this.body = body } + + /** Title/subject displayed by supported channels. */ + fun title(title: String) = title(JsonField.of(title)) + + /** + * Sets [Builder.title] to an arbitrary JSON value. + * + * You should usually call [Builder.title] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun title(title: JsonField) = apply { this.title = title } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Content]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * .title() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Content = + Content( + checkRequired("body", body), + checkRequired("title", title), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Content = apply { + if (validated) { + return@apply + } + + body() + title() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (body.asKnown().isPresent) 1 else 0) + (if (title.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Content && + body == other.body && + title == other.title && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(body, title, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Content{body=$body, title=$title, additionalProperties=$additionalProperties}" + } + + /** + * Define run-time configuration for channels. Valid ChannelId's: email, sms, push, inbox, + * direct_message, banner, webhook. + */ + class Channels + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Channels]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Channels]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channels: Channels) = apply { + additionalProperties = channels.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Channels]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Channels = Channels(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Channels = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channels && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Channels{additionalProperties=$additionalProperties}" + } + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Delay + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val duration: JsonField, + private val until: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("duration") + @ExcludeMissing + duration: JsonField = JsonMissing.of(), + @JsonProperty("until") @ExcludeMissing until: JsonField = JsonMissing.of(), + ) : this(duration, until, mutableMapOf()) + + /** + * The duration of the delay in milliseconds. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun duration(): Optional = duration.getOptional("duration") + + /** + * ISO 8601 timestamp or opening_hours-like format. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun until(): Optional = until.getOptional("until") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [until]. + * + * Unlike [until], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Delay]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Delay]. */ + class Builder internal constructor() { + + private var duration: JsonField = JsonMissing.of() + private var until: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(delay: Delay) = apply { + duration = delay.duration + until = delay.until + additionalProperties = delay.additionalProperties.toMutableMap() + } + + /** The duration of the delay in milliseconds. */ + fun duration(duration: Long?) = duration(JsonField.ofNullable(duration)) + + /** + * Alias for [Builder.duration]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun duration(duration: Long) = duration(duration as Long?) + + /** Alias for calling [Builder.duration] with `duration.orElse(null)`. */ + fun duration(duration: Optional) = duration(duration.getOrNull()) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** ISO 8601 timestamp or opening_hours-like format. */ + fun until(until: String?) = until(JsonField.ofNullable(until)) + + /** Alias for calling [Builder.until] with `until.orElse(null)`. */ + fun until(until: Optional) = until(until.getOrNull()) + + /** + * Sets [Builder.until] to an arbitrary JSON value. + * + * You should usually call [Builder.until] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun until(until: JsonField) = apply { this.until = until } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Delay]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Delay = Delay(duration, until, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Delay = apply { + if (validated) { + return@apply + } + + duration() + until() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (duration.asKnown().isPresent) 1 else 0) + + (if (until.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Delay && + duration == other.duration && + until == other.until && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(duration, until, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Delay{duration=$duration, until=$until, additionalProperties=$additionalProperties}" + } + + class Expiry + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expiresIn: JsonField, + private val expiresAt: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expires_in") + @ExcludeMissing + expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField = JsonMissing.of(), + ) : this(expiresIn, expiresAt, mutableMapOf()) + + /** + * Duration in ms or ISO8601 duration (e.g. P1DT4H). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun expiresIn(): ExpiresIn = expiresIn.getRequired("expires_in") + + /** + * Epoch or ISO8601 timestamp with timezone. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresAt(): Optional = expiresAt.getOptional("expires_at") + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expires_in") + @ExcludeMissing + fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField = expiresAt + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Expiry]. + * + * The following fields are required: + * ```java + * .expiresIn() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Expiry]. */ + class Builder internal constructor() { + + private var expiresIn: JsonField? = null + private var expiresAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(expiry: Expiry) = apply { + expiresIn = expiry.expiresIn + expiresAt = expiry.expiresAt + additionalProperties = expiry.additionalProperties.toMutableMap() + } + + /** Duration in ms or ISO8601 duration (e.g. P1DT4H). */ + fun expiresIn(expiresIn: ExpiresIn) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [ExpiresIn] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { + this.expiresIn = expiresIn + } + + /** Alias for calling [expiresIn] with `ExpiresIn.ofString(string)`. */ + fun expiresIn(string: String) = expiresIn(ExpiresIn.ofString(string)) + + /** Alias for calling [expiresIn] with `ExpiresIn.ofInteger(integer)`. */ + fun expiresIn(integer: Long) = expiresIn(ExpiresIn.ofInteger(integer)) + + /** Epoch or ISO8601 timestamp with timezone. */ + fun expiresAt(expiresAt: String?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Expiry]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .expiresIn() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Expiry = + Expiry( + checkRequired("expiresIn", expiresIn), + expiresAt, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Expiry = apply { + if (validated) { + return@apply + } + + expiresIn().validate() + expiresAt() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (expiresIn.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + /** Duration in ms or ISO8601 duration (e.g. P1DT4H). */ + @JsonDeserialize(using = ExpiresIn.Deserializer::class) + @JsonSerialize(using = ExpiresIn.Serializer::class) + class ExpiresIn + private constructor( + private val string: String? = null, + private val integer: Long? = null, + private val _json: JsonValue? = null, + ) { + + fun string(): Optional = Optional.ofNullable(string) + + fun integer(): Optional = Optional.ofNullable(integer) + + fun isString(): Boolean = string != null + + fun isInteger(): Boolean = integer != null + + fun asString(): String = string.getOrThrow("string") + + fun asInteger(): Long = integer.getOrThrow("integer") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + integer != null -> visitor.visitInteger(integer) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ExpiresIn = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitString(string: String) {} + + override fun visitInteger(integer: Long) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 + + override fun visitInteger(integer: Long) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ExpiresIn && string == other.string && integer == other.integer + } + + override fun hashCode(): Int = Objects.hash(string, integer) + + override fun toString(): String = + when { + string != null -> "ExpiresIn{string=$string}" + integer != null -> "ExpiresIn{integer=$integer}" + _json != null -> "ExpiresIn{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ExpiresIn") + } + + companion object { + + @JvmStatic fun ofString(string: String) = ExpiresIn(string = string) + + @JvmStatic fun ofInteger(integer: Long) = ExpiresIn(integer = integer) + } + + /** + * An interface that defines how to map each variant of [ExpiresIn] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitInteger(integer: Long): T + + /** + * Maps an unknown variant of [ExpiresIn] to a value of type [T]. + * + * An instance of [ExpiresIn] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ExpiresIn: $json") + } + } + + internal class Deserializer : BaseDeserializer(ExpiresIn::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ExpiresIn { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ExpiresIn(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ExpiresIn(integer = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> ExpiresIn(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ExpiresIn::class) { + + override fun serialize( + value: ExpiresIn, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.integer != null -> generator.writeObject(value.integer) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ExpiresIn") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Expiry && + expiresIn == other.expiresIn && + expiresAt == other.expiresAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expiresIn, expiresAt, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Expiry{expiresIn=$expiresIn, expiresAt=$expiresAt, additionalProperties=$additionalProperties}" + } + + class Metadata + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val event: JsonField, + private val tags: JsonField>, + private val traceId: JsonField, + private val utm: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("event") @ExcludeMissing event: JsonField = JsonMissing.of(), + @JsonProperty("tags") + @ExcludeMissing + tags: JsonField> = JsonMissing.of(), + @JsonProperty("trace_id") + @ExcludeMissing + traceId: JsonField = JsonMissing.of(), + @JsonProperty("utm") @ExcludeMissing utm: JsonField = JsonMissing.of(), + ) : this(event, tags, traceId, utm, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun event(): Optional = event.getOptional("event") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tags(): Optional> = tags.getOptional("tags") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun traceId(): Optional = traceId.getOptional("trace_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun utm(): Optional = utm.getOptional("utm") + + /** + * Returns the raw JSON value of [event]. + * + * Unlike [event], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event") @ExcludeMissing fun _event(): JsonField = event + + /** + * Returns the raw JSON value of [tags]. + * + * Unlike [tags], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tags") @ExcludeMissing fun _tags(): JsonField> = tags + + /** + * Returns the raw JSON value of [traceId]. + * + * Unlike [traceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("trace_id") @ExcludeMissing fun _traceId(): JsonField = traceId + + /** + * Returns the raw JSON value of [utm]. + * + * Unlike [utm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("utm") @ExcludeMissing fun _utm(): JsonField = utm + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Metadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var event: JsonField = JsonMissing.of() + private var tags: JsonField>? = null + private var traceId: JsonField = JsonMissing.of() + private var utm: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + event = metadata.event + tags = metadata.tags.map { it.toMutableList() } + traceId = metadata.traceId + utm = metadata.utm + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + fun event(event: String?) = event(JsonField.ofNullable(event)) + + /** Alias for calling [Builder.event] with `event.orElse(null)`. */ + fun event(event: Optional) = event(event.getOrNull()) + + /** + * Sets [Builder.event] to an arbitrary JSON value. + * + * You should usually call [Builder.event] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun event(event: JsonField) = apply { this.event = event } + + fun tags(tags: List?) = tags(JsonField.ofNullable(tags)) + + /** Alias for calling [Builder.tags] with `tags.orElse(null)`. */ + fun tags(tags: Optional>) = tags(tags.getOrNull()) + + /** + * Sets [Builder.tags] to an arbitrary JSON value. + * + * You should usually call [Builder.tags] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tags(tags: JsonField>) = apply { + this.tags = tags.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [tags]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTag(tag: String) = apply { + tags = + (tags ?: JsonField.of(mutableListOf())).also { + checkKnown("tags", it).add(tag) + } + } + + fun traceId(traceId: String?) = traceId(JsonField.ofNullable(traceId)) + + /** Alias for calling [Builder.traceId] with `traceId.orElse(null)`. */ + fun traceId(traceId: Optional) = traceId(traceId.getOrNull()) + + /** + * Sets [Builder.traceId] to an arbitrary JSON value. + * + * You should usually call [Builder.traceId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun traceId(traceId: JsonField) = apply { this.traceId = traceId } + + fun utm(utm: Utm?) = utm(JsonField.ofNullable(utm)) + + /** Alias for calling [Builder.utm] with `utm.orElse(null)`. */ + fun utm(utm: Optional) = utm(utm.getOrNull()) + + /** + * Sets [Builder.utm] to an arbitrary JSON value. + * + * You should usually call [Builder.utm] with a well-typed [Utm] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun utm(utm: JsonField) = apply { this.utm = utm } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Metadata = + Metadata( + event, + (tags ?: JsonMissing.of()).map { it.toImmutable() }, + traceId, + utm, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + event() + tags() + traceId() + utm().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (event.asKnown().isPresent) 1 else 0) + + (tags.asKnown().getOrNull()?.size ?: 0) + + (if (traceId.asKnown().isPresent) 1 else 0) + + (utm.asKnown().getOrNull()?.validity() ?: 0) + + class Utm + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val campaign: JsonField, + private val content: JsonField, + private val medium: JsonField, + private val source: JsonField, + private val term: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("campaign") + @ExcludeMissing + campaign: JsonField = JsonMissing.of(), + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("medium") + @ExcludeMissing + medium: JsonField = JsonMissing.of(), + @JsonProperty("source") + @ExcludeMissing + source: JsonField = JsonMissing.of(), + @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), + ) : this(campaign, content, medium, source, term, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun campaign(): Optional = campaign.getOptional("campaign") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun medium(): Optional = medium.getOptional("medium") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun term(): Optional = term.getOptional("term") + + /** + * Returns the raw JSON value of [campaign]. + * + * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("campaign") + @ExcludeMissing + fun _campaign(): JsonField = campaign + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [medium]. + * + * Unlike [medium], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [term]. + * + * Unlike [term], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Utm]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Utm]. */ + class Builder internal constructor() { + + private var campaign: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var medium: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var term: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(utm: Utm) = apply { + campaign = utm.campaign + content = utm.content + medium = utm.medium + source = utm.source + term = utm.term + additionalProperties = utm.additionalProperties.toMutableMap() + } + + fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) + + /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ + fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) + + /** + * Sets [Builder.campaign] to an arbitrary JSON value. + * + * You should usually call [Builder.campaign] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun campaign(campaign: JsonField) = apply { this.campaign = campaign } + + fun content(content: String?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) + + /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ + fun medium(medium: Optional) = medium(medium.getOrNull()) + + /** + * Sets [Builder.medium] to an arbitrary JSON value. + * + * You should usually call [Builder.medium] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun medium(medium: JsonField) = apply { this.medium = medium } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun term(term: String?) = term(JsonField.ofNullable(term)) + + /** Alias for calling [Builder.term] with `term.orElse(null)`. */ + fun term(term: Optional) = term(term.getOrNull()) + + /** + * Sets [Builder.term] to an arbitrary JSON value. + * + * You should usually call [Builder.term] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun term(term: JsonField) = apply { this.term = term } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Utm]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Utm = + Utm( + campaign, + content, + medium, + source, + term, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Utm = apply { + if (validated) { + return@apply + } + + campaign() + content() + medium() + source() + term() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (campaign.asKnown().isPresent) 1 else 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (if (medium.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (term.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Utm && + campaign == other.campaign && + content == other.content && + medium == other.medium && + source == other.source && + term == other.term && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(campaign, content, medium, source, term, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Metadata && + event == other.event && + tags == other.tags && + traceId == other.traceId && + utm == other.utm && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(event, tags, traceId, utm, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{event=$event, tags=$tags, traceId=$traceId, utm=$utm, additionalProperties=$additionalProperties}" + } + + class Preferences + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val subscriptionTopicId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("subscription_topic_id") + @ExcludeMissing + subscriptionTopicId: JsonField = JsonMissing.of() + ) : this(subscriptionTopicId, mutableMapOf()) + + /** + * The subscription topic to apply to the message. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun subscriptionTopicId(): String = + subscriptionTopicId.getRequired("subscription_topic_id") + + /** + * Returns the raw JSON value of [subscriptionTopicId]. + * + * Unlike [subscriptionTopicId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("subscription_topic_id") + @ExcludeMissing + fun _subscriptionTopicId(): JsonField = subscriptionTopicId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Preferences]. + * + * The following fields are required: + * ```java + * .subscriptionTopicId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Preferences]. */ + class Builder internal constructor() { + + private var subscriptionTopicId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preferences: Preferences) = apply { + subscriptionTopicId = preferences.subscriptionTopicId + additionalProperties = preferences.additionalProperties.toMutableMap() + } + + /** The subscription topic to apply to the message. */ + fun subscriptionTopicId(subscriptionTopicId: String) = + subscriptionTopicId(JsonField.of(subscriptionTopicId)) + + /** + * Sets [Builder.subscriptionTopicId] to an arbitrary JSON value. + * + * You should usually call [Builder.subscriptionTopicId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun subscriptionTopicId(subscriptionTopicId: JsonField) = apply { + this.subscriptionTopicId = subscriptionTopicId + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Preferences]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .subscriptionTopicId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Preferences = + Preferences( + checkRequired("subscriptionTopicId", subscriptionTopicId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Preferences = apply { + if (validated) { + return@apply + } + + subscriptionTopicId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (subscriptionTopicId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Preferences && + subscriptionTopicId == other.subscriptionTopicId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(subscriptionTopicId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Preferences{subscriptionTopicId=$subscriptionTopicId, additionalProperties=$additionalProperties}" + } + + class Providers + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Providers]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Providers]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(providers: Providers) = apply { + additionalProperties = providers.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Providers]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Providers = Providers(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Providers = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Providers && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Providers{additionalProperties=$additionalProperties}" + } + + /** Customize which channels/providers Courier may deliver the message through. */ + class Routing + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val method: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("method") @ExcludeMissing method: JsonField = JsonMissing.of(), + ) : this(channels, method, mutableMapOf()) + + /** + * A list of channels or providers (or nested routing rules). + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun channels(): List = channels.getRequired("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun method(): Method = method.getRequired("method") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [method]. + * + * Unlike [method], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Routing]. + * + * The following fields are required: + * ```java + * .channels() + * .method() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Routing]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var method: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(routing: Routing) = apply { + channels = routing.channels.map { it.toMutableList() } + method = routing.method + additionalProperties = routing.additionalProperties.toMutableMap() + } + + /** A list of channels or providers (or nested routing rules). */ + fun channels(channels: List) = + channels(JsonField.of(channels)) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [MessageRoutingChannel] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: MessageRoutingChannel) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + /** Alias for calling [addChannel] with `MessageRoutingChannel.ofString(string)`. */ + fun addChannel(string: String) = addChannel(MessageRoutingChannel.ofString(string)) + + /** + * Alias for calling [addChannel] with + * `MessageRoutingChannel.ofMessageRouting(messageRouting)`. + */ + fun addChannel(messageRouting: MessageRouting) = + addChannel(MessageRoutingChannel.ofMessageRouting(messageRouting)) + + fun method(method: Method) = method(JsonField.of(method)) + + /** + * Sets [Builder.method] to an arbitrary JSON value. + * + * You should usually call [Builder.method] with a well-typed [Method] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun method(method: JsonField) = apply { this.method = method } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Routing]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channels() + * .method() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Routing = + Routing( + checkRequired("channels", channels).map { it.toImmutable() }, + checkRequired("method", method), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Routing = apply { + if (validated) { + return@apply + } + + channels().forEach { it.validate() } + method().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (method.asKnown().getOrNull()?.validity() ?: 0) + + class Method @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ALL = of("all") + + @JvmField val SINGLE = of("single") + + @JvmStatic fun of(value: String) = Method(JsonField.of(value)) + } + + /** An enum containing [Method]'s known values. */ + enum class Known { + ALL, + SINGLE, + } + + /** + * An enum containing [Method]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Method] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ALL, + SINGLE, + /** + * An enum member indicating that [Method] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ALL -> Value.ALL + SINGLE -> Value.SINGLE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ALL -> Known.ALL + SINGLE -> Known.SINGLE + else -> throw CourierInvalidDataException("Unknown Method: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Method = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Method && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Routing && + channels == other.channels && + method == other.method && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, method, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Routing{channels=$channels, method=$method, additionalProperties=$additionalProperties}" + } + + class Timeout + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val criteria: JsonField, + private val escalation: JsonField, + private val message: JsonField, + private val provider: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") + @ExcludeMissing + channel: JsonField = JsonMissing.of(), + @JsonProperty("criteria") + @ExcludeMissing + criteria: JsonField = JsonMissing.of(), + @JsonProperty("escalation") + @ExcludeMissing + escalation: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField = JsonMissing.of(), + ) : this(channel, criteria, escalation, message, provider, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun channel(): Optional = channel.getOptional("channel") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun criteria(): Optional = criteria.getOptional("criteria") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun escalation(): Optional = escalation.getOptional("escalation") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun message(): Optional = message.getOptional("message") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun provider(): Optional = provider.getOptional("provider") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + /** + * Returns the raw JSON value of [criteria]. + * + * Unlike [criteria], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("criteria") + @ExcludeMissing + fun _criteria(): JsonField = criteria + + /** + * Returns the raw JSON value of [escalation]. + * + * Unlike [escalation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("escalation") + @ExcludeMissing + fun _escalation(): JsonField = escalation + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider") + @ExcludeMissing + fun _provider(): JsonField = provider + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Timeout]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Timeout]. */ + class Builder internal constructor() { + + private var channel: JsonField = JsonMissing.of() + private var criteria: JsonField = JsonMissing.of() + private var escalation: JsonField = JsonMissing.of() + private var message: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(timeout: Timeout) = apply { + channel = timeout.channel + criteria = timeout.criteria + escalation = timeout.escalation + message = timeout.message + provider = timeout.provider + additionalProperties = timeout.additionalProperties.toMutableMap() + } + + fun channel(channel: Channel?) = channel(JsonField.ofNullable(channel)) + + /** Alias for calling [Builder.channel] with `channel.orElse(null)`. */ + fun channel(channel: Optional) = channel(channel.getOrNull()) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [Channel] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun criteria(criteria: Criteria?) = criteria(JsonField.ofNullable(criteria)) + + /** Alias for calling [Builder.criteria] with `criteria.orElse(null)`. */ + fun criteria(criteria: Optional) = criteria(criteria.getOrNull()) + + /** + * Sets [Builder.criteria] to an arbitrary JSON value. + * + * You should usually call [Builder.criteria] with a well-typed [Criteria] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun criteria(criteria: JsonField) = apply { this.criteria = criteria } + + fun escalation(escalation: Long?) = escalation(JsonField.ofNullable(escalation)) + + /** + * Alias for [Builder.escalation]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun escalation(escalation: Long) = escalation(escalation as Long?) + + /** Alias for calling [Builder.escalation] with `escalation.orElse(null)`. */ + fun escalation(escalation: Optional) = escalation(escalation.getOrNull()) + + /** + * Sets [Builder.escalation] to an arbitrary JSON value. + * + * You should usually call [Builder.escalation] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun escalation(escalation: JsonField) = apply { this.escalation = escalation } + + fun message(message: Long?) = message(JsonField.ofNullable(message)) + + /** + * Alias for [Builder.message]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun message(message: Long) = message(message as Long?) + + /** Alias for calling [Builder.message] with `message.orElse(null)`. */ + fun message(message: Optional) = message(message.getOrNull()) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun provider(provider: Provider?) = provider(JsonField.ofNullable(provider)) + + /** Alias for calling [Builder.provider] with `provider.orElse(null)`. */ + fun provider(provider: Optional) = provider(provider.getOrNull()) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [Provider] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Timeout]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Timeout = + Timeout( + channel, + criteria, + escalation, + message, + provider, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Timeout = apply { + if (validated) { + return@apply + } + + channel().ifPresent { it.validate() } + criteria().ifPresent { it.validate() } + escalation() + message() + provider().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channel.asKnown().getOrNull()?.validity() ?: 0) + + (criteria.asKnown().getOrNull()?.validity() ?: 0) + + (if (escalation.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (provider.asKnown().getOrNull()?.validity() ?: 0) + + class Channel + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Channel]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Channel]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channel: Channel) = apply { + additionalProperties = channel.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Channel]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Channel = Channel(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channel && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Channel{additionalProperties=$additionalProperties}" + } + + class Criteria @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val NO_ESCALATION = of("no-escalation") + + @JvmField val DELIVERED = of("delivered") + + @JvmField val VIEWED = of("viewed") + + @JvmField val ENGAGED = of("engaged") + + @JvmStatic fun of(value: String) = Criteria(JsonField.of(value)) + } + + /** An enum containing [Criteria]'s known values. */ + enum class Known { + NO_ESCALATION, + DELIVERED, + VIEWED, + ENGAGED, + } + + /** + * An enum containing [Criteria]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Criteria] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NO_ESCALATION, + DELIVERED, + VIEWED, + ENGAGED, + /** + * An enum member indicating that [Criteria] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NO_ESCALATION -> Value.NO_ESCALATION + DELIVERED -> Value.DELIVERED + VIEWED -> Value.VIEWED + ENGAGED -> Value.ENGAGED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + NO_ESCALATION -> Known.NO_ESCALATION + DELIVERED -> Known.DELIVERED + VIEWED -> Known.VIEWED + ENGAGED -> Known.ENGAGED + else -> throw CourierInvalidDataException("Unknown Criteria: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Criteria = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Criteria && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Provider + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Provider]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Provider]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(provider: Provider) = apply { + additionalProperties = provider.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Provider]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Provider = Provider(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Provider = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Provider && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Provider{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Timeout && + channel == other.channel && + criteria == other.criteria && + escalation == other.escalation && + message == other.message && + provider == other.provider && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channel, criteria, escalation, message, provider, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Timeout{channel=$channel, criteria=$criteria, escalation=$escalation, message=$message, provider=$provider, additionalProperties=$additionalProperties}" + } + + /** The recipient or a list of recipients of the message */ + @JsonDeserialize(using = To.Deserializer::class) + @JsonSerialize(using = To.Serializer::class) + class To + private constructor( + private val unionMember0: UnionMember0? = null, + private val recipients: List? = null, + private val _json: JsonValue? = null, + ) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun recipients(): Optional> = Optional.ofNullable(recipients) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isRecipients(): Boolean = recipients != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asRecipients(): List = recipients.getOrThrow("recipients") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + recipients != null -> visitor.visitRecipients(recipients) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): To = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitRecipients(recipients: List) { + recipients.forEach { it.validate() } + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = + unionMember0.validity() + + override fun visitRecipients(recipients: List) = + recipients.sumOf { it.validity().toInt() } + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is To && + unionMember0 == other.unionMember0 && + recipients == other.recipients + } + + override fun hashCode(): Int = Objects.hash(unionMember0, recipients) + + override fun toString(): String = + when { + unionMember0 != null -> "To{unionMember0=$unionMember0}" + recipients != null -> "To{recipients=$recipients}" + _json != null -> "To{_unknown=$_json}" + else -> throw IllegalStateException("Invalid To") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = To(unionMember0 = unionMember0) + + @JvmStatic + fun ofRecipients(recipients: List) = + To(recipients = recipients.toImmutable()) + } + + /** An interface that defines how to map each variant of [To] to a value of type [T]. */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitRecipients(recipients: List): T + + /** + * Maps an unknown variant of [To] to a value of type [T]. + * + * An instance of [To] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown To: $json") + } + } + + internal class Deserializer : BaseDeserializer(To::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): To { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + To(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + To(recipients = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from boolean). + 0 -> To(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(To::class) { + + override fun serialize( + value: To, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.recipients != null -> generator.writeObject(value.recipients) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid To") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val accountId: JsonField, + private val context: JsonField, + private val data: JsonField, + private val email: JsonField, + private val locale: JsonField, + private val phoneNumber: JsonField, + private val preferences: JsonField, + private val tenantId: JsonField, + private val userId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("account_id") + @ExcludeMissing + accountId: JsonField = JsonMissing.of(), + @JsonProperty("context") + @ExcludeMissing + context: JsonField = JsonMissing.of(), + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + email: JsonField = JsonMissing.of(), + @JsonProperty("locale") + @ExcludeMissing + locale: JsonField = JsonMissing.of(), + @JsonProperty("phone_number") + @ExcludeMissing + phoneNumber: JsonField = JsonMissing.of(), + @JsonProperty("preferences") + @ExcludeMissing + preferences: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") + @ExcludeMissing + tenantId: JsonField = JsonMissing.of(), + @JsonProperty("user_id") + @ExcludeMissing + userId: JsonField = JsonMissing.of(), + ) : this( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + mutableMapOf(), + ) + + /** + * Use `tenant_id` instead. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun accountId(): Optional = accountId.getOptional("account_id") + + /** + * Context such as tenant_id to send the notification with. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun context(): Optional = context.getOptional("context") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * The user's preferred ISO 639-1 language code. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun locale(): Optional = locale.getOptional("locale") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun phoneNumber(): Optional = phoneNumber.getOptional("phone_number") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun preferences(): Optional = preferences.getOptional("preferences") + + /** + * Tenant id. Will load brand, default preferences and base context data. + * + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun tenantId(): Optional = tenantId.getOptional("tenant_id") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun userId(): Optional = userId.getOptional("user_id") + + /** + * Returns the raw JSON value of [accountId]. + * + * Unlike [accountId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("account_id") + @ExcludeMissing + fun _accountId(): JsonField = accountId + + /** + * Returns the raw JSON value of [context]. + * + * Unlike [context], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("context") + @ExcludeMissing + fun _context(): JsonField = context + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [locale]. + * + * Unlike [locale], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("locale") @ExcludeMissing fun _locale(): JsonField = locale + + /** + * Returns the raw JSON value of [phoneNumber]. + * + * Unlike [phoneNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("phone_number") + @ExcludeMissing + fun _phoneNumber(): JsonField = phoneNumber + + /** + * Returns the raw JSON value of [preferences]. + * + * Unlike [preferences], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("preferences") + @ExcludeMissing + fun _preferences(): JsonField = preferences + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("tenant_id") + @ExcludeMissing + fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var accountId: JsonField = JsonMissing.of() + private var context: JsonField = JsonMissing.of() + private var data: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var locale: JsonField = JsonMissing.of() + private var phoneNumber: JsonField = JsonMissing.of() + private var preferences: JsonField = JsonMissing.of() + private var tenantId: JsonField = JsonMissing.of() + private var userId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + accountId = unionMember0.accountId + context = unionMember0.context + data = unionMember0.data + email = unionMember0.email + locale = unionMember0.locale + phoneNumber = unionMember0.phoneNumber + preferences = unionMember0.preferences + tenantId = unionMember0.tenantId + userId = unionMember0.userId + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + /** Use `tenant_id` instead. */ + fun accountId(accountId: String?) = accountId(JsonField.ofNullable(accountId)) + + /** Alias for calling [Builder.accountId] with `accountId.orElse(null)`. */ + fun accountId(accountId: Optional) = accountId(accountId.getOrNull()) + + /** + * Sets [Builder.accountId] to an arbitrary JSON value. + * + * You should usually call [Builder.accountId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun accountId(accountId: JsonField) = apply { + this.accountId = accountId + } + + /** Context such as tenant_id to send the notification with. */ + fun context(context: MessageContext?) = context(JsonField.ofNullable(context)) + + /** Alias for calling [Builder.context] with `context.orElse(null)`. */ + fun context(context: Optional) = context(context.getOrNull()) + + /** + * Sets [Builder.context] to an arbitrary JSON value. + * + * You should usually call [Builder.context] with a well-typed [MessageContext] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun context(context: JsonField) = apply { + this.context = context + } + + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + /** Alias for calling [Builder.data] with `data.orElse(null)`. */ + fun data(data: Optional) = data(data.getOrNull()) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun email(email: String?) = email(JsonField.ofNullable(email)) + + /** Alias for calling [Builder.email] with `email.orElse(null)`. */ + fun email(email: Optional) = email(email.getOrNull()) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** The user's preferred ISO 639-1 language code. */ + fun locale(locale: String?) = locale(JsonField.ofNullable(locale)) + + /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ + fun locale(locale: Optional) = locale(locale.getOrNull()) + + /** + * Sets [Builder.locale] to an arbitrary JSON value. + * + * You should usually call [Builder.locale] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun locale(locale: JsonField) = apply { this.locale = locale } + + fun phoneNumber(phoneNumber: String?) = + phoneNumber(JsonField.ofNullable(phoneNumber)) + + /** Alias for calling [Builder.phoneNumber] with `phoneNumber.orElse(null)`. */ + fun phoneNumber(phoneNumber: Optional) = + phoneNumber(phoneNumber.getOrNull()) + + /** + * Sets [Builder.phoneNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.phoneNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun phoneNumber(phoneNumber: JsonField) = apply { + this.phoneNumber = phoneNumber + } + + fun preferences(preferences: Preferences?) = + preferences(JsonField.ofNullable(preferences)) + + /** Alias for calling [Builder.preferences] with `preferences.orElse(null)`. */ + fun preferences(preferences: Optional) = + preferences(preferences.getOrNull()) + + /** + * Sets [Builder.preferences] to an arbitrary JSON value. + * + * You should usually call [Builder.preferences] with a well-typed [Preferences] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun preferences(preferences: JsonField) = apply { + this.preferences = preferences + } + + /** Tenant id. Will load brand, default preferences and base context data. */ + fun tenantId(tenantId: String?) = tenantId(JsonField.ofNullable(tenantId)) + + /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ + fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) + + /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ + fun userId(userId: Optional) = userId(userId.getOrNull()) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + accountId() + context().ifPresent { it.validate() } + data().ifPresent { it.validate() } + email() + locale() + phoneNumber() + preferences().ifPresent { it.validate() } + tenantId() + userId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accountId.asKnown().isPresent) 1 else 0) + + (context.asKnown().getOrNull()?.validity() ?: 0) + + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (locale.asKnown().isPresent) 1 else 0) + + (if (phoneNumber.asKnown().isPresent) 1 else 0) + + (preferences.asKnown().getOrNull()?.validity() ?: 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = Data(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Data{additionalProperties=$additionalProperties}" + } + + class Preferences + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val notifications: JsonField, + private val categories: JsonField, + private val templateId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("notifications") + @ExcludeMissing + notifications: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField = JsonMissing.of(), + @JsonProperty("templateId") + @ExcludeMissing + templateId: JsonField = JsonMissing.of(), + ) : this(notifications, categories, templateId, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * or is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun notifications(): Notifications = notifications.getRequired("notifications") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun categories(): Optional = categories.getOptional("categories") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun templateId(): Optional = templateId.getOptional("templateId") + + /** + * Returns the raw JSON value of [notifications]. + * + * Unlike [notifications], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("notifications") + @ExcludeMissing + fun _notifications(): JsonField = notifications + + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField = categories + + /** + * Returns the raw JSON value of [templateId]. + * + * Unlike [templateId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("templateId") + @ExcludeMissing + fun _templateId(): JsonField = templateId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Preferences]. + * + * The following fields are required: + * ```java + * .notifications() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Preferences]. */ + class Builder internal constructor() { + + private var notifications: JsonField? = null + private var categories: JsonField = JsonMissing.of() + private var templateId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(preferences: Preferences) = apply { + notifications = preferences.notifications + categories = preferences.categories + templateId = preferences.templateId + additionalProperties = preferences.additionalProperties.toMutableMap() + } + + fun notifications(notifications: Notifications) = + notifications(JsonField.of(notifications)) + + /** + * Sets [Builder.notifications] to an arbitrary JSON value. + * + * You should usually call [Builder.notifications] with a well-typed + * [Notifications] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun notifications(notifications: JsonField) = apply { + this.notifications = notifications + } + + fun categories(categories: Categories?) = + categories(JsonField.ofNullable(categories)) + + /** + * Alias for calling [Builder.categories] with `categories.orElse(null)`. + */ + fun categories(categories: Optional) = + categories(categories.getOrNull()) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed + * [Categories] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun categories(categories: JsonField) = apply { + this.categories = categories + } + + fun templateId(templateId: String?) = + templateId(JsonField.ofNullable(templateId)) + + /** + * Alias for calling [Builder.templateId] with `templateId.orElse(null)`. + */ + fun templateId(templateId: Optional) = + templateId(templateId.getOrNull()) + + /** + * Sets [Builder.templateId] to an arbitrary JSON value. + * + * You should usually call [Builder.templateId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun templateId(templateId: JsonField) = apply { + this.templateId = templateId + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Preferences]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .notifications() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Preferences = + Preferences( + checkRequired("notifications", notifications), + categories, + templateId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Preferences = apply { + if (validated) { + return@apply + } + + notifications().validate() + categories().ifPresent { it.validate() } + templateId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (notifications.asKnown().getOrNull()?.validity() ?: 0) + + (categories.asKnown().getOrNull()?.validity() ?: 0) + + (if (templateId.asKnown().isPresent) 1 else 0) + + class Notifications + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Notifications]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Notifications]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(notifications: Notifications) = apply { + additionalProperties = + notifications.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Notifications]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Notifications = + Notifications(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Notifications = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Notifications && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Notifications{additionalProperties=$additionalProperties}" + } + + class Categories + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [Categories]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Categories]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(categories: Categories) = apply { + additionalProperties = + categories.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Categories]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): Categories = Categories(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): Categories = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Categories && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Categories{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Preferences && + notifications == other.notifications && + categories == other.categories && + templateId == other.templateId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(notifications, categories, templateId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Preferences{notifications=$notifications, categories=$categories, templateId=$templateId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + accountId == other.accountId && + context == other.context && + data == other.data && + email == other.email && + locale == other.locale && + phoneNumber == other.phoneNumber && + preferences == other.preferences && + tenantId == other.tenantId && + userId == other.userId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + accountId, + context, + data, + email, + locale, + phoneNumber, + preferences, + tenantId, + userId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{accountId=$accountId, context=$context, data=$data, email=$email, locale=$locale, phoneNumber=$phoneNumber, preferences=$preferences, tenantId=$tenantId, userId=$userId, additionalProperties=$additionalProperties}" + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Message && + content == other.content && + brandId == other.brandId && + channels == other.channels && + context == other.context && + data == other.data && + delay == other.delay && + expiry == other.expiry && + metadata == other.metadata && + preferences == other.preferences && + providers == other.providers && + routing == other.routing && + timeout == other.timeout && + to == other.to && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + brandId, + channels, + context, + data, + delay, + expiry, + metadata, + preferences, + providers, + routing, + timeout, + to, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Message{content=$content, brandId=$brandId, channels=$channels, context=$context, data=$data, delay=$delay, expiry=$expiry, metadata=$metadata, preferences=$preferences, providers=$providers, routing=$routing, timeout=$timeout, to=$to, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SendSendMessageParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SendSendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt similarity index 74% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt index 62d7e7fd..095675f4 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt @@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects -class SendMessageResponse +class SendSendMessageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val requestId: JsonField, @@ -29,15 +29,8 @@ private constructor( /** * A successful call to `POST /send` returns a `202` status code along with a `requestId` in the - * response body. - * - * For send requests that have a single recipient, the `requestId` is assigned to the derived - * message as its message_id. Therefore the `requestId` can be supplied to the Message's API for - * single recipient messages. - * - * For send requests that have multiple recipients (accounts, audiences, lists, etc.), Courier - * assigns a unique id to each derived message as its `message_id`. Therefore the `requestId` - * cannot be supplied to the Message's API for single-recipient messages. + * response body. For single-recipient requests, the `requestId` is the derived message_id. For + * multiple recipients, Courier assigns a unique message_id to each derived message. * * @throws CourierInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). @@ -66,7 +59,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SendMessageResponse]. + * Returns a mutable builder for constructing an instance of [SendSendMessageResponse]. * * The following fields are required: * ```java @@ -76,29 +69,23 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SendMessageResponse]. */ + /** A builder for [SendSendMessageResponse]. */ class Builder internal constructor() { private var requestId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(sendMessageResponse: SendMessageResponse) = apply { - requestId = sendMessageResponse.requestId - additionalProperties = sendMessageResponse.additionalProperties.toMutableMap() + internal fun from(sendSendMessageResponse: SendSendMessageResponse) = apply { + requestId = sendSendMessageResponse.requestId + additionalProperties = sendSendMessageResponse.additionalProperties.toMutableMap() } /** * A successful call to `POST /send` returns a `202` status code along with a `requestId` in - * the response body. - * - * For send requests that have a single recipient, the `requestId` is assigned to the - * derived message as its message_id. Therefore the `requestId` can be supplied to the - * Message's API for single recipient messages. - * - * For send requests that have multiple recipients (accounts, audiences, lists, etc.), - * Courier assigns a unique id to each derived message as its `message_id`. Therefore the - * `requestId` cannot be supplied to the Message's API for single-recipient messages. + * the response body. For single-recipient requests, the `requestId` is the derived + * message_id. For multiple recipients, Courier assigns a unique message_id to each derived + * message. */ fun requestId(requestId: String) = requestId(JsonField.of(requestId)) @@ -131,7 +118,7 @@ private constructor( } /** - * Returns an immutable instance of [SendMessageResponse]. + * Returns an immutable instance of [SendSendMessageResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -142,8 +129,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): SendMessageResponse = - SendMessageResponse( + fun build(): SendSendMessageResponse = + SendSendMessageResponse( checkRequired("requestId", requestId), additionalProperties.toMutableMap(), ) @@ -151,7 +138,7 @@ private constructor( private var validated: Boolean = false - fun validate(): SendMessageResponse = apply { + fun validate(): SendSendMessageResponse = apply { if (validated) { return@apply } @@ -180,7 +167,7 @@ private constructor( return true } - return other is SendMessageResponse && + return other is SendSendMessageResponse && requestId == other.requestId && additionalProperties == other.additionalProperties } @@ -190,5 +177,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" + "SendSendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt deleted file mode 100644 index 4eb4bddc..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SlackBaseProperties.kt +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class SlackBaseProperties -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val accessToken: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("access_token") - @ExcludeMissing - accessToken: JsonField = JsonMissing.of() - ) : this(accessToken, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun accessToken(): String = accessToken.getRequired("access_token") - - /** - * Returns the raw JSON value of [accessToken]. - * - * Unlike [accessToken], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("access_token") - @ExcludeMissing - fun _accessToken(): JsonField = accessToken - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SlackBaseProperties]. - * - * The following fields are required: - * ```java - * .accessToken() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SlackBaseProperties]. */ - class Builder internal constructor() { - - private var accessToken: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(slackBaseProperties: SlackBaseProperties) = apply { - accessToken = slackBaseProperties.accessToken - additionalProperties = slackBaseProperties.additionalProperties.toMutableMap() - } - - fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) - - /** - * Sets [Builder.accessToken] to an arbitrary JSON value. - * - * You should usually call [Builder.accessToken] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SlackBaseProperties]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .accessToken() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SlackBaseProperties = - SlackBaseProperties( - checkRequired("accessToken", accessToken), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SlackBaseProperties = apply { - if (validated) { - return@apply - } - - accessToken() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (accessToken.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SlackBaseProperties && - accessToken == other.accessToken && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(accessToken, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SlackBaseProperties{accessToken=$accessToken, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt deleted file mode 100644 index 8504b223..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt +++ /dev/null @@ -1,293 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class Utm -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val campaign: JsonField, - private val content: JsonField, - private val medium: JsonField, - private val source: JsonField, - private val term: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("campaign") @ExcludeMissing campaign: JsonField = JsonMissing.of(), - @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), - @JsonProperty("medium") @ExcludeMissing medium: JsonField = JsonMissing.of(), - @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), - @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), - ) : this(campaign, content, medium, source, term, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun campaign(): Optional = campaign.getOptional("campaign") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun medium(): Optional = medium.getOptional("medium") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun term(): Optional = term.getOptional("term") - - /** - * Returns the raw JSON value of [campaign]. - * - * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [medium]. - * - * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - /** - * Returns the raw JSON value of [term]. - * - * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Utm]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Utm]. */ - class Builder internal constructor() { - - private var campaign: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var medium: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var term: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(utm: Utm) = apply { - campaign = utm.campaign - content = utm.content - medium = utm.medium - source = utm.source - term = utm.term - additionalProperties = utm.additionalProperties.toMutableMap() - } - - fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) - - /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ - fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) - - /** - * Sets [Builder.campaign] to an arbitrary JSON value. - * - * You should usually call [Builder.campaign] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun campaign(campaign: JsonField) = apply { this.campaign = campaign } - - fun content(content: String?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) - - /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ - fun medium(medium: Optional) = medium(medium.getOrNull()) - - /** - * Sets [Builder.medium] to an arbitrary JSON value. - * - * You should usually call [Builder.medium] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun medium(medium: JsonField) = apply { this.medium = medium } - - fun source(source: String?) = source(JsonField.ofNullable(source)) - - /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun term(term: String?) = term(JsonField.ofNullable(term)) - - /** Alias for calling [Builder.term] with `term.orElse(null)`. */ - fun term(term: Optional) = term(term.getOrNull()) - - /** - * Sets [Builder.term] to an arbitrary JSON value. - * - * You should usually call [Builder.term] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun term(term: JsonField) = apply { this.term = term } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Utm]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Utm = - Utm(campaign, content, medium, source, term, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Utm = apply { - if (validated) { - return@apply - } - - campaign() - content() - medium() - source() - term() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (campaign.asKnown().isPresent) 1 else 0) + - (if (content.asKnown().isPresent) 1 else 0) + - (if (medium.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (term.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Utm && - campaign == other.campaign && - content == other.content && - medium == other.medium && - source == other.source && - term == other.term && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(campaign, content, medium, source, term, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt deleted file mode 100644 index 7de80040..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/DefaultPreferences.kt +++ /dev/null @@ -1,512 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class DefaultPreferences -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun items(): Optional> = items.getOptional("items") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [DefaultPreferences]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [DefaultPreferences]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(defaultPreferences: DefaultPreferences) = apply { - items = defaultPreferences.items.map { it.toMutableList() } - additionalProperties = defaultPreferences.additionalProperties.toMutableMap() - } - - fun items(items: List?) = items(JsonField.ofNullable(items)) - - /** Alias for calling [Builder.items] with `items.orElse(null)`. */ - fun items(items: Optional>) = items(items.getOrNull()) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Item] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Item) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [DefaultPreferences]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): DefaultPreferences = - DefaultPreferences( - (items ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): DefaultPreferences = apply { - if (validated) { - return@apply - } - - items().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val status: JsonField, - private val customRouting: JsonField>, - private val hasCustomRouting: JsonField, - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("custom_routing") - @ExcludeMissing - customRouting: JsonField> = JsonMissing.of(), - @JsonProperty("has_custom_routing") - @ExcludeMissing - hasCustomRouting: JsonField = JsonMissing.of(), - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - ) : this(status, customRouting, hasCustomRouting, id, mutableMapOf()) - - fun toSubscriptionTopicNew(): SubscriptionTopicNew = - SubscriptionTopicNew.builder() - .status(status) - .customRouting(customRouting) - .hasCustomRouting(hasCustomRouting) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): SubscriptionTopicNew.Status = status.getRequired("status") - - /** - * The default channels to send to this tenant when has_custom_routing is enabled - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customRouting(): Optional> = - customRouting.getOptional("custom_routing") - - /** - * Override channel routing with custom preferences. This will override any template - * prefernces that are set, but a user can still customize their preferences - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hasCustomRouting(): Optional = - hasCustomRouting.getOptional("has_custom_routing") - - /** - * Topic ID - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") - @ExcludeMissing - fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [customRouting]. - * - * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_routing") - @ExcludeMissing - fun _customRouting(): JsonField> = customRouting - - /** - * Returns the raw JSON value of [hasCustomRouting]. - * - * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("has_custom_routing") - @ExcludeMissing - fun _hasCustomRouting(): JsonField = hasCustomRouting - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Item]. - * - * The following fields are required: - * ```java - * .status() - * .id() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var customRouting: JsonField>? = null - private var hasCustomRouting: JsonField = JsonMissing.of() - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - status = item.status - customRouting = item.customRouting.map { it.toMutableList() } - hasCustomRouting = item.hasCustomRouting - id = item.id - additionalProperties = item.additionalProperties.toMutableMap() - } - - fun status(status: SubscriptionTopicNew.Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed - * [SubscriptionTopicNew.Status] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { - this.status = status - } - - /** The default channels to send to this tenant when has_custom_routing is enabled */ - fun customRouting(customRouting: List?) = - customRouting(JsonField.ofNullable(customRouting)) - - /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ - fun customRouting(customRouting: Optional>) = - customRouting(customRouting.getOrNull()) - - /** - * Sets [Builder.customRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.customRouting] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun customRouting(customRouting: JsonField>) = apply { - this.customRouting = customRouting.map { it.toMutableList() } - } - - /** - * Adds a single [ChannelClassification] to [Builder.customRouting]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCustomRouting(customRouting: ChannelClassification) = apply { - this.customRouting = - (this.customRouting ?: JsonField.of(mutableListOf())).also { - checkKnown("customRouting", it).add(customRouting) - } - } - - /** - * Override channel routing with custom preferences. This will override any template - * prefernces that are set, but a user can still customize their preferences - */ - fun hasCustomRouting(hasCustomRouting: Boolean?) = - hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) - - /** - * Alias for [Builder.hasCustomRouting]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hasCustomRouting(hasCustomRouting: Boolean) = - hasCustomRouting(hasCustomRouting as Boolean?) - - /** - * Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. - */ - fun hasCustomRouting(hasCustomRouting: Optional) = - hasCustomRouting(hasCustomRouting.getOrNull()) - - /** - * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun hasCustomRouting(hasCustomRouting: JsonField) = apply { - this.hasCustomRouting = hasCustomRouting - } - - /** Topic ID */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - checkRequired("status", status), - (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, - hasCustomRouting, - checkRequired("id", id), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - status().validate() - customRouting().ifPresent { it.forEach { it.validate() } } - hasCustomRouting() - id() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (status.asKnown().getOrNull()?.validity() ?: 0) + - (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (hasCustomRouting.asKnown().isPresent) 1 else 0) + - (if (id.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - status == other.status && - customRouting == other.customRouting && - hasCustomRouting == other.hasCustomRouting && - id == other.id && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(status, customRouting, hasCustomRouting, id, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{status=$status, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, id=$id, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DefaultPreferences && - items == other.items && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DefaultPreferences{items=$items, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt deleted file mode 100644 index 0b5f3a3b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/Tenant.kt +++ /dev/null @@ -1,655 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class Tenant -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val name: JsonField, - private val brandId: JsonField, - private val defaultPreferences: JsonField, - private val parentTenantId: JsonField, - private val properties: JsonField, - private val userProfile: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), - @JsonProperty("default_preferences") - @ExcludeMissing - defaultPreferences: JsonField = JsonMissing.of(), - @JsonProperty("parent_tenant_id") - @ExcludeMissing - parentTenantId: JsonField = JsonMissing.of(), - @JsonProperty("properties") - @ExcludeMissing - properties: JsonField = JsonMissing.of(), - @JsonProperty("user_profile") - @ExcludeMissing - userProfile: JsonField = JsonMissing.of(), - ) : this( - id, - name, - brandId, - defaultPreferences, - parentTenantId, - properties, - userProfile, - mutableMapOf(), - ) - - /** - * Id of the tenant. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * Name of the tenant. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * Brand to be used for the account when one is not specified by the send call. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * Defines the preferences used for the account when the user hasn't specified their own. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun defaultPreferences(): Optional = - defaultPreferences.getOptional("default_preferences") - - /** - * Tenant's parent id (if any). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun parentTenantId(): Optional = parentTenantId.getOptional("parent_tenant_id") - - /** - * Arbitrary properties accessible to a template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun properties(): Optional = properties.getOptional("properties") - - /** - * A user profile object merged with user profile on send. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userProfile(): Optional = userProfile.getOptional("user_profile") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [defaultPreferences]. - * - * Unlike [defaultPreferences], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("default_preferences") - @ExcludeMissing - fun _defaultPreferences(): JsonField = defaultPreferences - - /** - * Returns the raw JSON value of [parentTenantId]. - * - * Unlike [parentTenantId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("parent_tenant_id") - @ExcludeMissing - fun _parentTenantId(): JsonField = parentTenantId - - /** - * Returns the raw JSON value of [properties]. - * - * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("properties") - @ExcludeMissing - fun _properties(): JsonField = properties - - /** - * Returns the raw JSON value of [userProfile]. - * - * Unlike [userProfile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_profile") - @ExcludeMissing - fun _userProfile(): JsonField = userProfile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tenant]. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tenant]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var name: JsonField? = null - private var brandId: JsonField = JsonMissing.of() - private var defaultPreferences: JsonField = JsonMissing.of() - private var parentTenantId: JsonField = JsonMissing.of() - private var properties: JsonField = JsonMissing.of() - private var userProfile: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenant: Tenant) = apply { - id = tenant.id - name = tenant.name - brandId = tenant.brandId - defaultPreferences = tenant.defaultPreferences - parentTenantId = tenant.parentTenantId - properties = tenant.properties - userProfile = tenant.userProfile - additionalProperties = tenant.additionalProperties.toMutableMap() - } - - /** Id of the tenant. */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** Name of the tenant. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Brand to be used for the account when one is not specified by the send call. */ - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * Defines the preferences used for the account when the user hasn't specified their own. - */ - fun defaultPreferences(defaultPreferences: DefaultPreferences?) = - defaultPreferences(JsonField.ofNullable(defaultPreferences)) - - /** - * Alias for calling [Builder.defaultPreferences] with `defaultPreferences.orElse(null)`. - */ - fun defaultPreferences(defaultPreferences: Optional) = - defaultPreferences(defaultPreferences.getOrNull()) - - /** - * Sets [Builder.defaultPreferences] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultPreferences] with a well-typed - * [DefaultPreferences] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun defaultPreferences(defaultPreferences: JsonField) = apply { - this.defaultPreferences = defaultPreferences - } - - /** Tenant's parent id (if any). */ - fun parentTenantId(parentTenantId: String?) = - parentTenantId(JsonField.ofNullable(parentTenantId)) - - /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ - fun parentTenantId(parentTenantId: Optional) = - parentTenantId(parentTenantId.getOrNull()) - - /** - * Sets [Builder.parentTenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.parentTenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parentTenantId(parentTenantId: JsonField) = apply { - this.parentTenantId = parentTenantId - } - - /** Arbitrary properties accessible to a template. */ - fun properties(properties: Properties?) = properties(JsonField.ofNullable(properties)) - - /** Alias for calling [Builder.properties] with `properties.orElse(null)`. */ - fun properties(properties: Optional) = properties(properties.getOrNull()) - - /** - * Sets [Builder.properties] to an arbitrary JSON value. - * - * You should usually call [Builder.properties] with a well-typed [Properties] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun properties(properties: JsonField) = apply { this.properties = properties } - - /** A user profile object merged with user profile on send. */ - fun userProfile(userProfile: UserProfile?) = userProfile(JsonField.ofNullable(userProfile)) - - /** Alias for calling [Builder.userProfile] with `userProfile.orElse(null)`. */ - fun userProfile(userProfile: Optional) = userProfile(userProfile.getOrNull()) - - /** - * Sets [Builder.userProfile] to an arbitrary JSON value. - * - * You should usually call [Builder.userProfile] with a well-typed [UserProfile] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun userProfile(userProfile: JsonField) = apply { - this.userProfile = userProfile - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tenant]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tenant = - Tenant( - checkRequired("id", id), - checkRequired("name", name), - brandId, - defaultPreferences, - parentTenantId, - properties, - userProfile, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tenant = apply { - if (validated) { - return@apply - } - - id() - name() - brandId() - defaultPreferences().ifPresent { it.validate() } - parentTenantId() - properties().ifPresent { it.validate() } - userProfile().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (brandId.asKnown().isPresent) 1 else 0) + - (defaultPreferences.asKnown().getOrNull()?.validity() ?: 0) + - (if (parentTenantId.asKnown().isPresent) 1 else 0) + - (properties.asKnown().getOrNull()?.validity() ?: 0) + - (userProfile.asKnown().getOrNull()?.validity() ?: 0) - - /** Arbitrary properties accessible to a template. */ - class Properties - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Properties]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Properties]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(properties: Properties) = apply { - additionalProperties = properties.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Properties]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Properties = Properties(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Properties = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Properties && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Properties{additionalProperties=$additionalProperties}" - } - - /** A user profile object merged with user profile on send. */ - class UserProfile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UserProfile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UserProfile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(userProfile: UserProfile) = apply { - additionalProperties = userProfile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UserProfile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UserProfile = UserProfile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): UserProfile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserProfile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "UserProfile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tenant && - id == other.id && - name == other.name && - brandId == other.brandId && - defaultPreferences == other.defaultPreferences && - parentTenantId == other.parentTenantId && - properties == other.properties && - userProfile == other.userProfile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - name, - brandId, - defaultPreferences, - parentTenantId, - properties, - userProfile, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tenant{id=$id, name=$name, brandId=$brandId, defaultPreferences=$defaultPreferences, parentTenantId=$parentTenantId, properties=$properties, userProfile=$userProfile, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt deleted file mode 100644 index 01fe752f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantDeleteParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete a Tenant */ -class TenantDeleteParams -private constructor( - private val tenantId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TenantDeleteParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TenantDeleteParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantDeleteParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantDeleteParams: TenantDeleteParams) = apply { - tenantId = tenantDeleteParams.tenantId - additionalHeaders = tenantDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = tenantDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [TenantDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TenantDeleteParams = - TenantDeleteParams( - tenantId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantDeleteParams && - tenantId == other.tenantId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(tenantId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "TenantDeleteParams{tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt deleted file mode 100644 index ef1b6f01..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListParams.kt +++ /dev/null @@ -1,234 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get a List of Tenants */ -class TenantListParams -private constructor( - private val cursor: String?, - private val limit: Long?, - private val parentTenantId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** Continue the pagination with the next cursor */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** The number of tenants to return (defaults to 20, maximum value of 100) */ - fun limit(): Optional = Optional.ofNullable(limit) - - /** Filter the list of tenants by parent_id */ - fun parentTenantId(): Optional = Optional.ofNullable(parentTenantId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TenantListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TenantListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantListParams]. */ - class Builder internal constructor() { - - private var cursor: String? = null - private var limit: Long? = null - private var parentTenantId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantListParams: TenantListParams) = apply { - cursor = tenantListParams.cursor - limit = tenantListParams.limit - parentTenantId = tenantListParams.parentTenantId - additionalHeaders = tenantListParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantListParams.additionalQueryParams.toBuilder() - } - - /** Continue the pagination with the next cursor */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** The number of tenants to return (defaults to 20, maximum value of 100) */ - fun limit(limit: Long?) = apply { this.limit = limit } - - /** - * Alias for [Builder.limit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun limit(limit: Long) = limit(limit as Long?) - - /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ - fun limit(limit: Optional) = limit(limit.getOrNull()) - - /** Filter the list of tenants by parent_id */ - fun parentTenantId(parentTenantId: String?) = apply { this.parentTenantId = parentTenantId } - - /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ - fun parentTenantId(parentTenantId: Optional) = - parentTenantId(parentTenantId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TenantListParams = - TenantListParams( - cursor, - limit, - parentTenantId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - limit?.let { put("limit", it.toString()) } - parentTenantId?.let { put("parent_tenant_id", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantListParams && - cursor == other.cursor && - limit == other.limit && - parentTenantId == other.parentTenantId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(cursor, limit, parentTenantId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantListParams{cursor=$cursor, limit=$limit, parentTenantId=$parentTenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt deleted file mode 100644 index 3e8c7532..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListResponse.kt +++ /dev/null @@ -1,501 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TenantListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val hasMore: JsonField, - private val items: JsonField>, - private val type: JsonField, - private val url: JsonField, - private val cursor: JsonField, - private val nextUrl: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), - @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), - ) : this(hasMore, items, type, url, cursor, nextUrl, mutableMapOf()) - - /** - * Set to true when there are more pages that can be retrieved. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun hasMore(): Boolean = hasMore.getRequired("has_more") - - /** - * An array of Tenants - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * Always set to "list". Represents the type of this object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * A url that may be used to generate these results. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun url(): String = url.getRequired("url") - - /** - * A pointer to the next page of results. Defined only when has_more is set to true. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cursor(): Optional = cursor.getOptional("cursor") - - /** - * A url that may be used to generate fetch the next set of results. Defined only when has_more - * is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun nextUrl(): Optional = nextUrl.getOptional("next_url") - - /** - * Returns the raw JSON value of [hasMore]. - * - * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [cursor]. - * - * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor - - /** - * Returns the raw JSON value of [nextUrl]. - * - * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantListResponse]. - * - * The following fields are required: - * ```java - * .hasMore() - * .items() - * .type() - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantListResponse]. */ - class Builder internal constructor() { - - private var hasMore: JsonField? = null - private var items: JsonField>? = null - private var type: JsonField? = null - private var url: JsonField? = null - private var cursor: JsonField = JsonMissing.of() - private var nextUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantListResponse: TenantListResponse) = apply { - hasMore = tenantListResponse.hasMore - items = tenantListResponse.items.map { it.toMutableList() } - type = tenantListResponse.type - url = tenantListResponse.url - cursor = tenantListResponse.cursor - nextUrl = tenantListResponse.nextUrl - additionalProperties = tenantListResponse.additionalProperties.toMutableMap() - } - - /** Set to true when there are more pages that can be retrieved. */ - fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) - - /** - * Sets [Builder.hasMore] to an arbitrary JSON value. - * - * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } - - /** An array of Tenants */ - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Tenant] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Tenant) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - /** Always set to "list". Represents the type of this object. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** A url that may be used to generate these results. */ - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - /** A pointer to the next page of results. Defined only when has_more is set to true. */ - fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** - * Sets [Builder.cursor] to an arbitrary JSON value. - * - * You should usually call [Builder.cursor] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * has_more is set to true - */ - fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) - - /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ - fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) - - /** - * Sets [Builder.nextUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TenantListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .hasMore() - * .items() - * .type() - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantListResponse = - TenantListResponse( - checkRequired("hasMore", hasMore), - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("type", type), - checkRequired("url", url), - cursor, - nextUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TenantListResponse = apply { - if (validated) { - return@apply - } - - hasMore() - items().forEach { it.validate() } - type().validate() - url() - cursor() - nextUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (hasMore.asKnown().isPresent) 1 else 0) + - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (url.asKnown().isPresent) 1 else 0) + - (if (cursor.asKnown().isPresent) 1 else 0) + - (if (nextUrl.asKnown().isPresent) 1 else 0) - - /** Always set to "list". Represents the type of this object. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIST = of("list") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - LIST - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST -> Value.LIST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LIST -> Known.LIST - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantListResponse && - hasMore == other.hasMore && - items == other.items && - type == other.type && - url == other.url && - cursor == other.cursor && - nextUrl == other.nextUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(hasMore, items, type, url, cursor, nextUrl, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TenantListResponse{hasMore=$hasMore, items=$items, type=$type, url=$url, cursor=$cursor, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt deleted file mode 100644 index 2f7aa8aa..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersParams.kt +++ /dev/null @@ -1,236 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get Users in Tenant */ -class TenantListUsersParams -private constructor( - private val tenantId: String?, - private val cursor: String?, - private val limit: Long?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Continue the pagination with the next cursor */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** The number of accounts to return (defaults to 20, maximum value of 100) */ - fun limit(): Optional = Optional.ofNullable(limit) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TenantListUsersParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TenantListUsersParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantListUsersParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var cursor: String? = null - private var limit: Long? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantListUsersParams: TenantListUsersParams) = apply { - tenantId = tenantListUsersParams.tenantId - cursor = tenantListUsersParams.cursor - limit = tenantListUsersParams.limit - additionalHeaders = tenantListUsersParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantListUsersParams.additionalQueryParams.toBuilder() - } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** Continue the pagination with the next cursor */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** The number of accounts to return (defaults to 20, maximum value of 100) */ - fun limit(limit: Long?) = apply { this.limit = limit } - - /** - * Alias for [Builder.limit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun limit(limit: Long) = limit(limit as Long?) - - /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ - fun limit(limit: Optional) = limit(limit.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantListUsersParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TenantListUsersParams = - TenantListUsersParams( - tenantId, - cursor, - limit, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - limit?.let { put("limit", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantListUsersParams && - tenantId == other.tenantId && - cursor == other.cursor && - limit == other.limit && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tenantId, cursor, limit, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantListUsersParams{tenantId=$tenantId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt deleted file mode 100644 index 124df60a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantListUsersResponse.kt +++ /dev/null @@ -1,502 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.users.tenants.TenantAssociation -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TenantListUsersResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val hasMore: JsonField, - private val type: JsonField, - private val url: JsonField, - private val cursor: JsonField, - private val items: JsonField>, - private val nextUrl: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), - @JsonProperty("items") - @ExcludeMissing - items: JsonField> = JsonMissing.of(), - @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), - ) : this(hasMore, type, url, cursor, items, nextUrl, mutableMapOf()) - - /** - * Set to true when there are more pages that can be retrieved. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun hasMore(): Boolean = hasMore.getRequired("has_more") - - /** - * Always set to `list`. Represents the type of this object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * A url that may be used to generate these results. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun url(): String = url.getRequired("url") - - /** - * A pointer to the next page of results. Defined only when `has_more` is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cursor(): Optional = cursor.getOptional("cursor") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun items(): Optional> = items.getOptional("items") - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * `has_more` is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun nextUrl(): Optional = nextUrl.getOptional("next_url") - - /** - * Returns the raw JSON value of [hasMore]. - * - * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [cursor]. - * - * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [nextUrl]. - * - * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantListUsersResponse]. - * - * The following fields are required: - * ```java - * .hasMore() - * .type() - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantListUsersResponse]. */ - class Builder internal constructor() { - - private var hasMore: JsonField? = null - private var type: JsonField? = null - private var url: JsonField? = null - private var cursor: JsonField = JsonMissing.of() - private var items: JsonField>? = null - private var nextUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantListUsersResponse: TenantListUsersResponse) = apply { - hasMore = tenantListUsersResponse.hasMore - type = tenantListUsersResponse.type - url = tenantListUsersResponse.url - cursor = tenantListUsersResponse.cursor - items = tenantListUsersResponse.items.map { it.toMutableList() } - nextUrl = tenantListUsersResponse.nextUrl - additionalProperties = tenantListUsersResponse.additionalProperties.toMutableMap() - } - - /** Set to true when there are more pages that can be retrieved. */ - fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) - - /** - * Sets [Builder.hasMore] to an arbitrary JSON value. - * - * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } - - /** Always set to `list`. Represents the type of this object. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** A url that may be used to generate these results. */ - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - /** A pointer to the next page of results. Defined only when `has_more` is set to true */ - fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** - * Sets [Builder.cursor] to an arbitrary JSON value. - * - * You should usually call [Builder.cursor] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun items(items: List?) = items(JsonField.ofNullable(items)) - - /** Alias for calling [Builder.items] with `items.orElse(null)`. */ - fun items(items: Optional>) = items(items.getOrNull()) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [TenantAssociation] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: TenantAssociation) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * `has_more` is set to true - */ - fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) - - /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ - fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) - - /** - * Sets [Builder.nextUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TenantListUsersResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .hasMore() - * .type() - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantListUsersResponse = - TenantListUsersResponse( - checkRequired("hasMore", hasMore), - checkRequired("type", type), - checkRequired("url", url), - cursor, - (items ?: JsonMissing.of()).map { it.toImmutable() }, - nextUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TenantListUsersResponse = apply { - if (validated) { - return@apply - } - - hasMore() - type().validate() - url() - cursor() - items().ifPresent { it.forEach { it.validate() } } - nextUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (hasMore.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (url.asKnown().isPresent) 1 else 0) + - (if (cursor.asKnown().isPresent) 1 else 0) + - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (nextUrl.asKnown().isPresent) 1 else 0) - - /** Always set to `list`. Represents the type of this object. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIST = of("list") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - LIST - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST -> Value.LIST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LIST -> Known.LIST - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantListUsersResponse && - hasMore == other.hasMore && - type == other.type && - url == other.url && - cursor == other.cursor && - items == other.items && - nextUrl == other.nextUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(hasMore, type, url, cursor, items, nextUrl, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TenantListUsersResponse{hasMore=$hasMore, type=$type, url=$url, cursor=$cursor, items=$items, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt deleted file mode 100644 index 700f1525..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantRetrieveParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get a Tenant */ -class TenantRetrieveParams -private constructor( - private val tenantId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TenantRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TenantRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantRetrieveParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantRetrieveParams: TenantRetrieveParams) = apply { - tenantId = tenantRetrieveParams.tenantId - additionalHeaders = tenantRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantRetrieveParams.additionalQueryParams.toBuilder() - } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TenantRetrieveParams = - TenantRetrieveParams(tenantId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantRetrieveParams && - tenantId == other.tenantId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(tenantId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantRetrieveParams{tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt deleted file mode 100644 index 43eef9c4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/TenantUpdateParams.kt +++ /dev/null @@ -1,1055 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Create or Replace a Tenant */ -class TenantUpdateParams -private constructor( - private val tenantId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** - * Name of the tenant. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = body.name() - - /** - * Brand to be used for the account when one is not specified by the send call. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brandId(): Optional = body.brandId() - - /** - * Defines the preferences used for the tenant when the user hasn't specified their own. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun defaultPreferences(): Optional = body.defaultPreferences() - - /** - * Tenant's parent id (if any). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun parentTenantId(): Optional = body.parentTenantId() - - /** - * Arbitrary properties accessible to a template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun properties(): Optional = body.properties() - - /** - * A user profile object merged with user profile on send. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userProfile(): Optional = body.userProfile() - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _name(): JsonField = body._name() - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _brandId(): JsonField = body._brandId() - - /** - * Returns the raw JSON value of [defaultPreferences]. - * - * Unlike [defaultPreferences], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _defaultPreferences(): JsonField = body._defaultPreferences() - - /** - * Returns the raw JSON value of [parentTenantId]. - * - * Unlike [parentTenantId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _parentTenantId(): JsonField = body._parentTenantId() - - /** - * Returns the raw JSON value of [properties]. - * - * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _properties(): JsonField = body._properties() - - /** - * Returns the raw JSON value of [userProfile]. - * - * Unlike [userProfile], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _userProfile(): JsonField = body._userProfile() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantUpdateParams]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantUpdateParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantUpdateParams: TenantUpdateParams) = apply { - tenantId = tenantUpdateParams.tenantId - body = tenantUpdateParams.body.toBuilder() - additionalHeaders = tenantUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantUpdateParams.additionalQueryParams.toBuilder() - } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [name] - * - [brandId] - * - [defaultPreferences] - * - [parentTenantId] - * - [properties] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Name of the tenant. */ - fun name(name: String) = apply { body.name(name) } - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun name(name: JsonField) = apply { body.name(name) } - - /** Brand to be used for the account when one is not specified by the send call. */ - fun brandId(brandId: String?) = apply { body.brandId(brandId) } - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun brandId(brandId: JsonField) = apply { body.brandId(brandId) } - - /** Defines the preferences used for the tenant when the user hasn't specified their own. */ - fun defaultPreferences(defaultPreferences: DefaultPreferences?) = apply { - body.defaultPreferences(defaultPreferences) - } - - /** - * Alias for calling [Builder.defaultPreferences] with `defaultPreferences.orElse(null)`. - */ - fun defaultPreferences(defaultPreferences: Optional) = - defaultPreferences(defaultPreferences.getOrNull()) - - /** - * Sets [Builder.defaultPreferences] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultPreferences] with a well-typed - * [DefaultPreferences] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun defaultPreferences(defaultPreferences: JsonField) = apply { - body.defaultPreferences(defaultPreferences) - } - - /** Tenant's parent id (if any). */ - fun parentTenantId(parentTenantId: String?) = apply { body.parentTenantId(parentTenantId) } - - /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ - fun parentTenantId(parentTenantId: Optional) = - parentTenantId(parentTenantId.getOrNull()) - - /** - * Sets [Builder.parentTenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.parentTenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parentTenantId(parentTenantId: JsonField) = apply { - body.parentTenantId(parentTenantId) - } - - /** Arbitrary properties accessible to a template. */ - fun properties(properties: Properties?) = apply { body.properties(properties) } - - /** Alias for calling [Builder.properties] with `properties.orElse(null)`. */ - fun properties(properties: Optional) = properties(properties.getOrNull()) - - /** - * Sets [Builder.properties] to an arbitrary JSON value. - * - * You should usually call [Builder.properties] with a well-typed [Properties] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun properties(properties: JsonField) = apply { body.properties(properties) } - - /** A user profile object merged with user profile on send. */ - fun userProfile(userProfile: UserProfile?) = apply { body.userProfile(userProfile) } - - /** Alias for calling [Builder.userProfile] with `userProfile.orElse(null)`. */ - fun userProfile(userProfile: Optional) = userProfile(userProfile.getOrNull()) - - /** - * Sets [Builder.userProfile] to an arbitrary JSON value. - * - * You should usually call [Builder.userProfile] with a well-typed [UserProfile] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun userProfile(userProfile: JsonField) = apply { - body.userProfile(userProfile) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantUpdateParams = - TenantUpdateParams( - tenantId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val brandId: JsonField, - private val defaultPreferences: JsonField, - private val parentTenantId: JsonField, - private val properties: JsonField, - private val userProfile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("brand_id") @ExcludeMissing brandId: JsonField = JsonMissing.of(), - @JsonProperty("default_preferences") - @ExcludeMissing - defaultPreferences: JsonField = JsonMissing.of(), - @JsonProperty("parent_tenant_id") - @ExcludeMissing - parentTenantId: JsonField = JsonMissing.of(), - @JsonProperty("properties") - @ExcludeMissing - properties: JsonField = JsonMissing.of(), - @JsonProperty("user_profile") - @ExcludeMissing - userProfile: JsonField = JsonMissing.of(), - ) : this( - name, - brandId, - defaultPreferences, - parentTenantId, - properties, - userProfile, - mutableMapOf(), - ) - - /** - * Name of the tenant. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * Brand to be used for the account when one is not specified by the send call. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun brandId(): Optional = brandId.getOptional("brand_id") - - /** - * Defines the preferences used for the tenant when the user hasn't specified their own. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun defaultPreferences(): Optional = - defaultPreferences.getOptional("default_preferences") - - /** - * Tenant's parent id (if any). - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun parentTenantId(): Optional = parentTenantId.getOptional("parent_tenant_id") - - /** - * Arbitrary properties accessible to a template. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun properties(): Optional = properties.getOptional("properties") - - /** - * A user profile object merged with user profile on send. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userProfile(): Optional = userProfile.getOptional("user_profile") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [brandId]. - * - * Unlike [brandId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("brand_id") @ExcludeMissing fun _brandId(): JsonField = brandId - - /** - * Returns the raw JSON value of [defaultPreferences]. - * - * Unlike [defaultPreferences], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("default_preferences") - @ExcludeMissing - fun _defaultPreferences(): JsonField = defaultPreferences - - /** - * Returns the raw JSON value of [parentTenantId]. - * - * Unlike [parentTenantId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parent_tenant_id") - @ExcludeMissing - fun _parentTenantId(): JsonField = parentTenantId - - /** - * Returns the raw JSON value of [properties]. - * - * Unlike [properties], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("properties") - @ExcludeMissing - fun _properties(): JsonField = properties - - /** - * Returns the raw JSON value of [userProfile]. - * - * Unlike [userProfile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_profile") - @ExcludeMissing - fun _userProfile(): JsonField = userProfile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var brandId: JsonField = JsonMissing.of() - private var defaultPreferences: JsonField = JsonMissing.of() - private var parentTenantId: JsonField = JsonMissing.of() - private var properties: JsonField = JsonMissing.of() - private var userProfile: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - name = body.name - brandId = body.brandId - defaultPreferences = body.defaultPreferences - parentTenantId = body.parentTenantId - properties = body.properties - userProfile = body.userProfile - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Name of the tenant. */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Brand to be used for the account when one is not specified by the send call. */ - fun brandId(brandId: String?) = brandId(JsonField.ofNullable(brandId)) - - /** Alias for calling [Builder.brandId] with `brandId.orElse(null)`. */ - fun brandId(brandId: Optional) = brandId(brandId.getOrNull()) - - /** - * Sets [Builder.brandId] to an arbitrary JSON value. - * - * You should usually call [Builder.brandId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun brandId(brandId: JsonField) = apply { this.brandId = brandId } - - /** - * Defines the preferences used for the tenant when the user hasn't specified their own. - */ - fun defaultPreferences(defaultPreferences: DefaultPreferences?) = - defaultPreferences(JsonField.ofNullable(defaultPreferences)) - - /** - * Alias for calling [Builder.defaultPreferences] with - * `defaultPreferences.orElse(null)`. - */ - fun defaultPreferences(defaultPreferences: Optional) = - defaultPreferences(defaultPreferences.getOrNull()) - - /** - * Sets [Builder.defaultPreferences] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultPreferences] with a well-typed - * [DefaultPreferences] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun defaultPreferences(defaultPreferences: JsonField) = apply { - this.defaultPreferences = defaultPreferences - } - - /** Tenant's parent id (if any). */ - fun parentTenantId(parentTenantId: String?) = - parentTenantId(JsonField.ofNullable(parentTenantId)) - - /** Alias for calling [Builder.parentTenantId] with `parentTenantId.orElse(null)`. */ - fun parentTenantId(parentTenantId: Optional) = - parentTenantId(parentTenantId.getOrNull()) - - /** - * Sets [Builder.parentTenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.parentTenantId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parentTenantId(parentTenantId: JsonField) = apply { - this.parentTenantId = parentTenantId - } - - /** Arbitrary properties accessible to a template. */ - fun properties(properties: Properties?) = properties(JsonField.ofNullable(properties)) - - /** Alias for calling [Builder.properties] with `properties.orElse(null)`. */ - fun properties(properties: Optional) = properties(properties.getOrNull()) - - /** - * Sets [Builder.properties] to an arbitrary JSON value. - * - * You should usually call [Builder.properties] with a well-typed [Properties] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun properties(properties: JsonField) = apply { - this.properties = properties - } - - /** A user profile object merged with user profile on send. */ - fun userProfile(userProfile: UserProfile?) = - userProfile(JsonField.ofNullable(userProfile)) - - /** Alias for calling [Builder.userProfile] with `userProfile.orElse(null)`. */ - fun userProfile(userProfile: Optional) = - userProfile(userProfile.getOrNull()) - - /** - * Sets [Builder.userProfile] to an arbitrary JSON value. - * - * You should usually call [Builder.userProfile] with a well-typed [UserProfile] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun userProfile(userProfile: JsonField) = apply { - this.userProfile = userProfile - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("name", name), - brandId, - defaultPreferences, - parentTenantId, - properties, - userProfile, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - name() - brandId() - defaultPreferences().ifPresent { it.validate() } - parentTenantId() - properties().ifPresent { it.validate() } - userProfile().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (if (brandId.asKnown().isPresent) 1 else 0) + - (defaultPreferences.asKnown().getOrNull()?.validity() ?: 0) + - (if (parentTenantId.asKnown().isPresent) 1 else 0) + - (properties.asKnown().getOrNull()?.validity() ?: 0) + - (userProfile.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - name == other.name && - brandId == other.brandId && - defaultPreferences == other.defaultPreferences && - parentTenantId == other.parentTenantId && - properties == other.properties && - userProfile == other.userProfile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - name, - brandId, - defaultPreferences, - parentTenantId, - properties, - userProfile, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{name=$name, brandId=$brandId, defaultPreferences=$defaultPreferences, parentTenantId=$parentTenantId, properties=$properties, userProfile=$userProfile, additionalProperties=$additionalProperties}" - } - - /** Arbitrary properties accessible to a template. */ - class Properties - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Properties]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Properties]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(properties: Properties) = apply { - additionalProperties = properties.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Properties]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Properties = Properties(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Properties = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Properties && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Properties{additionalProperties=$additionalProperties}" - } - - /** A user profile object merged with user profile on send. */ - class UserProfile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UserProfile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UserProfile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(userProfile: UserProfile) = apply { - additionalProperties = userProfile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UserProfile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UserProfile = UserProfile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): UserProfile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserProfile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "UserProfile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantUpdateParams && - tenantId == other.tenantId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tenantId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantUpdateParams{tenantId=$tenantId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt deleted file mode 100644 index e2c2b2ee..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ChannelClassification.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import com.courier.api.core.Enum -import com.courier.api.core.JsonField -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class ChannelClassification @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't match - * any known member, and you want to know that value. For example, if the SDK is on an older - * version than the API, then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DIRECT_MESSAGE = of("direct_message") - - @JvmField val EMAIL = of("email") - - @JvmField val PUSH = of("push") - - @JvmField val SMS = of("sms") - - @JvmField val WEBHOOK = of("webhook") - - @JvmField val INBOX = of("inbox") - - @JvmStatic fun of(value: String) = ChannelClassification(JsonField.of(value)) - } - - /** An enum containing [ChannelClassification]'s known values. */ - enum class Known { - DIRECT_MESSAGE, - EMAIL, - PUSH, - SMS, - WEBHOOK, - INBOX, - } - - /** - * An enum containing [ChannelClassification]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ChannelClassification] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the SDK - * is on an older version than the API, then the API may respond with new members that the SDK - * is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIRECT_MESSAGE, - EMAIL, - PUSH, - SMS, - WEBHOOK, - INBOX, - /** - * An enum member indicating that [ChannelClassification] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if - * the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want to - * throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIRECT_MESSAGE -> Value.DIRECT_MESSAGE - EMAIL -> Value.EMAIL - PUSH -> Value.PUSH - SMS -> Value.SMS - WEBHOOK -> Value.WEBHOOK - INBOX -> Value.INBOX - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't want - * to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - DIRECT_MESSAGE -> Known.DIRECT_MESSAGE - EMAIL -> Known.EMAIL - PUSH -> Known.PUSH - SMS -> Known.SMS - WEBHOOK -> Known.WEBHOOK - INBOX -> Known.INBOX - else -> throw CourierInvalidDataException("Unknown ChannelClassification: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging and - * generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ChannelClassification = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ChannelClassification && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt deleted file mode 100644 index f485c84c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParams.kt +++ /dev/null @@ -1,258 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Remove Default Preferences For Topic */ -class ItemDeleteParams -private constructor( - private val tenantId: String, - private val topicId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun tenantId(): String = tenantId - - fun topicId(): Optional = Optional.ofNullable(topicId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ItemDeleteParams]. - * - * The following fields are required: - * ```java - * .tenantId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ItemDeleteParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var topicId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(itemDeleteParams: ItemDeleteParams) = apply { - tenantId = itemDeleteParams.tenantId - topicId = itemDeleteParams.topicId - additionalHeaders = itemDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = itemDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = itemDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun tenantId(tenantId: String) = apply { this.tenantId = tenantId } - - fun topicId(topicId: String?) = apply { this.topicId = topicId } - - /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ - fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [ItemDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tenantId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ItemDeleteParams = - ItemDeleteParams( - checkRequired("tenantId", tenantId), - topicId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId - 1 -> topicId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ItemDeleteParams && - tenantId == other.tenantId && - topicId == other.topicId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash( - tenantId, - topicId, - additionalHeaders, - additionalQueryParams, - additionalBodyProperties, - ) - - override fun toString() = - "ItemDeleteParams{tenantId=$tenantId, topicId=$topicId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt deleted file mode 100644 index df367cb9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParams.kt +++ /dev/null @@ -1,242 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Create or Replace Default Preferences For Topic */ -class ItemUpdateParams -private constructor( - private val tenantId: String, - private val topicId: String?, - private val subscriptionTopicNew: SubscriptionTopicNew, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tenantId(): String = tenantId - - fun topicId(): Optional = Optional.ofNullable(topicId) - - fun subscriptionTopicNew(): SubscriptionTopicNew = subscriptionTopicNew - - fun _additionalBodyProperties(): Map = - subscriptionTopicNew._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ItemUpdateParams]. - * - * The following fields are required: - * ```java - * .tenantId() - * .subscriptionTopicNew() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ItemUpdateParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var topicId: String? = null - private var subscriptionTopicNew: SubscriptionTopicNew? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(itemUpdateParams: ItemUpdateParams) = apply { - tenantId = itemUpdateParams.tenantId - topicId = itemUpdateParams.topicId - subscriptionTopicNew = itemUpdateParams.subscriptionTopicNew - additionalHeaders = itemUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = itemUpdateParams.additionalQueryParams.toBuilder() - } - - fun tenantId(tenantId: String) = apply { this.tenantId = tenantId } - - fun topicId(topicId: String?) = apply { this.topicId = topicId } - - /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ - fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) - - fun subscriptionTopicNew(subscriptionTopicNew: SubscriptionTopicNew) = apply { - this.subscriptionTopicNew = subscriptionTopicNew - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [ItemUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tenantId() - * .subscriptionTopicNew() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ItemUpdateParams = - ItemUpdateParams( - checkRequired("tenantId", tenantId), - topicId, - checkRequired("subscriptionTopicNew", subscriptionTopicNew), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): SubscriptionTopicNew = subscriptionTopicNew - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId - 1 -> topicId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ItemUpdateParams && - tenantId == other.tenantId && - topicId == other.topicId && - subscriptionTopicNew == other.subscriptionTopicNew && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - tenantId, - topicId, - subscriptionTopicNew, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "ItemUpdateParams{tenantId=$tenantId, topicId=$topicId, subscriptionTopicNew=$subscriptionTopicNew, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt deleted file mode 100644 index 3c2f7358..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNew.kt +++ /dev/null @@ -1,428 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class SubscriptionTopicNew -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val status: JsonField, - private val customRouting: JsonField>, - private val hasCustomRouting: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("custom_routing") - @ExcludeMissing - customRouting: JsonField> = JsonMissing.of(), - @JsonProperty("has_custom_routing") - @ExcludeMissing - hasCustomRouting: JsonField = JsonMissing.of(), - ) : this(status, customRouting, hasCustomRouting, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): Status = status.getRequired("status") - - /** - * The default channels to send to this tenant when has_custom_routing is enabled - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customRouting(): Optional> = - customRouting.getOptional("custom_routing") - - /** - * Override channel routing with custom preferences. This will override any template prefernces - * that are set, but a user can still customize their preferences - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hasCustomRouting(): Optional = hasCustomRouting.getOptional("has_custom_routing") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [customRouting]. - * - * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("custom_routing") - @ExcludeMissing - fun _customRouting(): JsonField> = customRouting - - /** - * Returns the raw JSON value of [hasCustomRouting]. - * - * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("has_custom_routing") - @ExcludeMissing - fun _hasCustomRouting(): JsonField = hasCustomRouting - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [SubscriptionTopicNew]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [SubscriptionTopicNew]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var customRouting: JsonField>? = null - private var hasCustomRouting: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(subscriptionTopicNew: SubscriptionTopicNew) = apply { - status = subscriptionTopicNew.status - customRouting = subscriptionTopicNew.customRouting.map { it.toMutableList() } - hasCustomRouting = subscriptionTopicNew.hasCustomRouting - additionalProperties = subscriptionTopicNew.additionalProperties.toMutableMap() - } - - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** The default channels to send to this tenant when has_custom_routing is enabled */ - fun customRouting(customRouting: List?) = - customRouting(JsonField.ofNullable(customRouting)) - - /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ - fun customRouting(customRouting: Optional>) = - customRouting(customRouting.getOrNull()) - - /** - * Sets [Builder.customRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.customRouting] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun customRouting(customRouting: JsonField>) = apply { - this.customRouting = customRouting.map { it.toMutableList() } - } - - /** - * Adds a single [ChannelClassification] to [Builder.customRouting]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCustomRouting(customRouting: ChannelClassification) = apply { - this.customRouting = - (this.customRouting ?: JsonField.of(mutableListOf())).also { - checkKnown("customRouting", it).add(customRouting) - } - } - - /** - * Override channel routing with custom preferences. This will override any template - * prefernces that are set, but a user can still customize their preferences - */ - fun hasCustomRouting(hasCustomRouting: Boolean?) = - hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) - - /** - * Alias for [Builder.hasCustomRouting]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hasCustomRouting(hasCustomRouting: Boolean) = - hasCustomRouting(hasCustomRouting as Boolean?) - - /** Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. */ - fun hasCustomRouting(hasCustomRouting: Optional) = - hasCustomRouting(hasCustomRouting.getOrNull()) - - /** - * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun hasCustomRouting(hasCustomRouting: JsonField) = apply { - this.hasCustomRouting = hasCustomRouting - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [SubscriptionTopicNew]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): SubscriptionTopicNew = - SubscriptionTopicNew( - checkRequired("status", status), - (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, - hasCustomRouting, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): SubscriptionTopicNew = apply { - if (validated) { - return@apply - } - - status().validate() - customRouting().ifPresent { it.forEach { it.validate() } } - hasCustomRouting() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (status.asKnown().getOrNull()?.validity() ?: 0) + - (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (hasCustomRouting.asKnown().isPresent) 1 else 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val OPTED_OUT = of("OPTED_OUT") - - @JvmField val OPTED_IN = of("OPTED_IN") - - @JvmField val REQUIRED = of("REQUIRED") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - OPTED_OUT, - OPTED_IN, - REQUIRED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - OPTED_OUT, - OPTED_IN, - REQUIRED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - OPTED_OUT -> Value.OPTED_OUT - OPTED_IN -> Value.OPTED_IN - REQUIRED -> Value.REQUIRED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - OPTED_OUT -> Known.OPTED_OUT - OPTED_IN -> Known.OPTED_IN - REQUIRED -> Known.REQUIRED - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is SubscriptionTopicNew && - status == other.status && - customRouting == other.customRouting && - hasCustomRouting == other.hasCustomRouting && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(status, customRouting, hasCustomRouting, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "SubscriptionTopicNew{status=$status, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt deleted file mode 100644 index e5b4b448..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociation.kt +++ /dev/null @@ -1,329 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class BaseTemplateTenantAssociation -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val createdAt: JsonField, - private val publishedAt: JsonField, - private val updatedAt: JsonField, - private val version: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), - @JsonProperty("published_at") - @ExcludeMissing - publishedAt: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - ) : this(id, createdAt, publishedAt, updatedAt, version, mutableMapOf()) - - /** - * The template's id - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * The timestamp at which the template was created - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): String = createdAt.getRequired("created_at") - - /** - * The timestamp at which the template was published - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun publishedAt(): String = publishedAt.getRequired("published_at") - - /** - * The timestamp at which the template was last updated - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updatedAt(): String = updatedAt.getRequired("updated_at") - - /** - * The version of the template - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [publishedAt]. - * - * Unlike [publishedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("published_at") - @ExcludeMissing - fun _publishedAt(): JsonField = publishedAt - - /** - * Returns the raw JSON value of [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BaseTemplateTenantAssociation]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .publishedAt() - * .updatedAt() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BaseTemplateTenantAssociation]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var publishedAt: JsonField? = null - private var updatedAt: JsonField? = null - private var version: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(baseTemplateTenantAssociation: BaseTemplateTenantAssociation) = apply { - id = baseTemplateTenantAssociation.id - createdAt = baseTemplateTenantAssociation.createdAt - publishedAt = baseTemplateTenantAssociation.publishedAt - updatedAt = baseTemplateTenantAssociation.updatedAt - version = baseTemplateTenantAssociation.version - additionalProperties = baseTemplateTenantAssociation.additionalProperties.toMutableMap() - } - - /** The template's id */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp at which the template was created */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** The timestamp at which the template was published */ - fun publishedAt(publishedAt: String) = publishedAt(JsonField.of(publishedAt)) - - /** - * Sets [Builder.publishedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.publishedAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun publishedAt(publishedAt: JsonField) = apply { this.publishedAt = publishedAt } - - /** The timestamp at which the template was last updated */ - fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - /** The version of the template */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BaseTemplateTenantAssociation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .publishedAt() - * .updatedAt() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BaseTemplateTenantAssociation = - BaseTemplateTenantAssociation( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("publishedAt", publishedAt), - checkRequired("updatedAt", updatedAt), - checkRequired("version", version), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BaseTemplateTenantAssociation = apply { - if (validated) { - return@apply - } - - id() - createdAt() - publishedAt() - updatedAt() - version() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (publishedAt.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BaseTemplateTenantAssociation && - id == other.id && - createdAt == other.createdAt && - publishedAt == other.publishedAt && - updatedAt == other.updatedAt && - version == other.version && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, publishedAt, updatedAt, version, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BaseTemplateTenantAssociation{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt deleted file mode 100644 index 0700d91f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNode.kt +++ /dev/null @@ -1,572 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ElementalChannelNode -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val channel: JsonField, - private val channels: JsonField>, - private val elements: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val raw: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("raw") @ExcludeMissing raw: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(channel, channels, elements, if_, loop, raw, ref, mutableMapOf()) - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` is - * `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun elements(): Optional> = elements.getOptional("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun raw(): Optional = raw.getOptional("raw") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [raw]. - * - * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalChannelNode]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalChannelNode]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var channels: JsonField>? = null - private var elements: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var raw: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalChannelNode: ElementalChannelNode) = apply { - channel = elementalChannelNode.channel - channels = elementalChannelNode.channels.map { it.toMutableList() } - elements = elementalChannelNode.elements.map { it.toMutableList() } - if_ = elementalChannelNode.if_ - loop = elementalChannelNode.loop - raw = elementalChannelNode.raw - ref = elementalChannelNode.ref - additionalProperties = elementalChannelNode.additionalProperties.toMutableMap() - } - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - */ - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` - * is `required`. - */ - fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) - - /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ - fun elements(elements: Optional>) = elements(elements.getOrNull()) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - */ - fun raw(raw: Raw?) = raw(JsonField.ofNullable(raw)) - - /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ - fun raw(raw: Optional) = raw(raw.getOrNull()) - - /** - * Sets [Builder.raw] to an arbitrary JSON value. - * - * You should usually call [Builder.raw] with a well-typed [Raw] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. - */ - fun raw(raw: JsonField) = apply { this.raw = raw } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalChannelNode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalChannelNode = - ElementalChannelNode( - checkRequired("channel", channel), - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - (elements ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - raw, - ref, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalChannelNode = apply { - if (validated) { - return@apply - } - - channel() - channels() - elements().ifPresent { it.forEach { it.validate() } } - if_() - loop() - raw().ifPresent { it.validate() } - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (raw.asKnown().getOrNull()?.validity() ?: 0) + - (if (ref.asKnown().isPresent) 1 else 0) - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is `required`. - */ - class Raw - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Raw]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Raw]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(raw: Raw) = apply { - additionalProperties = raw.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Raw]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Raw = Raw(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Raw = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Raw && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Raw{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalChannelNode && - channel == other.channel && - channels == other.channels && - elements == other.elements && - if_ == other.if_ && - loop == other.loop && - raw == other.raw && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channel, channels, elements, if_, loop, raw, ref, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalChannelNode{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt deleted file mode 100644 index 536579a9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalContent.kt +++ /dev/null @@ -1,274 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class ElementalContent -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val elements: JsonField>, - private val version: JsonField, - private val brand: JsonValue, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("brand") @ExcludeMissing brand: JsonValue = JsonMissing.of(), - ) : this(elements, version, brand, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * For example, "2022-01-01" - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - @JsonProperty("brand") @ExcludeMissing fun _brand(): JsonValue = brand - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalContent]. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalContent]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var version: JsonField? = null - private var brand: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalContent: ElementalContent) = apply { - elements = elementalContent.elements.map { it.toMutableList() } - version = elementalContent.version - brand = elementalContent.brand - additionalProperties = elementalContent.additionalProperties.toMutableMap() - } - - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - /** For example, "2022-01-01" */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - fun brand(brand: JsonValue) = apply { this.brand = brand } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalContent]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * .version() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalContent = - ElementalContent( - checkRequired("elements", elements).map { it.toImmutable() }, - checkRequired("version", version), - brand, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalContent = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - version() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (version.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalContent && - elements == other.elements && - version == other.version && - brand == other.brand && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, version, brand, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalContent{elements=$elements, version=$version, brand=$brand, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt deleted file mode 100644 index ca5b8af9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNode.kt +++ /dev/null @@ -1,385 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class ElementalGroupNode -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val elements: JsonField>, - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - ) : this(elements, channels, if_, loop, ref, mutableMapOf()) - - /** - * Sub elements to render. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") @ExcludeMissing fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [ElementalGroupNode]. - * - * The following fields are required: - * ```java - * .elements() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ElementalGroupNode]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(elementalGroupNode: ElementalGroupNode) = apply { - elements = elementalGroupNode.elements.map { it.toMutableList() } - channels = elementalGroupNode.channels.map { it.toMutableList() } - if_ = elementalGroupNode.if_ - loop = elementalGroupNode.loop - ref = elementalGroupNode.ref - additionalProperties = elementalGroupNode.additionalProperties.toMutableMap() - } - - /** Sub elements to render. */ - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: ElementalNode.UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: ElementalNode.UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: ElementalNode.UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: ElementalNode.UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: ElementalNode.UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: ElementalNode.UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: ElementalNode.UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: ElementalNode.UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [ElementalGroupNode]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ElementalGroupNode = - ElementalGroupNode( - checkRequired("elements", elements).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): ElementalGroupNode = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - channels() - if_() - loop() - ref() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalGroupNode && - elements == other.elements && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, channels, if_, loop, ref, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ElementalGroupNode{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt deleted file mode 100644 index 0f1d982c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/ElementalNode.kt +++ /dev/null @@ -1,4182 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is sent - * through email, and a more concise message in a push notification. Channel elements are only valid - * as top-level elements; you cannot nest channel elements. If there is a channel element specified - * at the top-level of the document, all sibling elements must be channel elements. Note: As an - * alternative, most elements support a `channel` property. Which allows you to selectively display - * an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) for - * more details. - */ -@JsonDeserialize(using = ElementalNode.Deserializer::class) -@JsonSerialize(using = ElementalNode.Serializer::class) -class ElementalNode -private constructor( - private val unionMember0: UnionMember0? = null, - private val unionMember1: UnionMember1? = null, - private val unionMember2: UnionMember2? = null, - private val unionMember3: UnionMember3? = null, - private val unionMember4: UnionMember4? = null, - private val unionMember5: UnionMember5? = null, - private val unionMember6: UnionMember6? = null, - private val unionMember7: UnionMember7? = null, - private val _json: JsonValue? = null, -) { - - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) - - fun unionMember1(): Optional = Optional.ofNullable(unionMember1) - - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) - - fun unionMember3(): Optional = Optional.ofNullable(unionMember3) - - fun unionMember4(): Optional = Optional.ofNullable(unionMember4) - - fun unionMember5(): Optional = Optional.ofNullable(unionMember5) - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun unionMember6(): Optional = Optional.ofNullable(unionMember6) - - fun unionMember7(): Optional = Optional.ofNullable(unionMember7) - - fun isUnionMember0(): Boolean = unionMember0 != null - - fun isUnionMember1(): Boolean = unionMember1 != null - - fun isUnionMember2(): Boolean = unionMember2 != null - - fun isUnionMember3(): Boolean = unionMember3 != null - - fun isUnionMember4(): Boolean = unionMember4 != null - - fun isUnionMember5(): Boolean = unionMember5 != null - - fun isUnionMember6(): Boolean = unionMember6 != null - - fun isUnionMember7(): Boolean = unionMember7 != null - - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") - - fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") - - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") - - fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") - - fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") - - fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") - - fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - unionMember1 != null -> visitor.visitUnionMember1(unionMember1) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - unionMember3 != null -> visitor.visitUnionMember3(unionMember3) - unionMember4 != null -> visitor.visitUnionMember4(unionMember4) - unionMember5 != null -> visitor.visitUnionMember5(unionMember5) - unionMember6 != null -> visitor.visitUnionMember6(unionMember6) - unionMember7 != null -> visitor.visitUnionMember7(unionMember7) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ElementalNode = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } - - override fun visitUnionMember1(unionMember1: UnionMember1) { - unionMember1.validate() - } - - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() - } - - override fun visitUnionMember3(unionMember3: UnionMember3) { - unionMember3.validate() - } - - override fun visitUnionMember4(unionMember4: UnionMember4) { - unionMember4.validate() - } - - override fun visitUnionMember5(unionMember5: UnionMember5) { - unionMember5.validate() - } - - override fun visitUnionMember6(unionMember6: UnionMember6) { - unionMember6.validate() - } - - override fun visitUnionMember7(unionMember7: UnionMember7) { - unionMember7.validate() - } - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - - override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() - - override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() - - override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() - - override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() - - override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() - - override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() - - override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ElementalNode && - unionMember0 == other.unionMember0 && - unionMember1 == other.unionMember1 && - unionMember2 == other.unionMember2 && - unionMember3 == other.unionMember3 && - unionMember4 == other.unionMember4 && - unionMember5 == other.unionMember5 && - unionMember6 == other.unionMember6 && - unionMember7 == other.unionMember7 - } - - override fun hashCode(): Int = - Objects.hash( - unionMember0, - unionMember1, - unionMember2, - unionMember3, - unionMember4, - unionMember5, - unionMember6, - unionMember7, - ) - - override fun toString(): String = - when { - unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" - unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" - unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" - unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" - unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" - unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" - unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" - unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" - _json != null -> "ElementalNode{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ElementalNode") - } - - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) - - @JvmStatic - fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) - - /** - * The channel element allows a notification to be customized based on which channel it is - * sent through. For example, you may want to display a detailed message when the - * notification is sent through email, and a more concise message in a push notification. - * Channel elements are only valid as top-level elements; you cannot nest channel elements. - * If there is a channel element specified at the top-level of the document, all sibling - * elements must be channel elements. Note: As an alternative, most elements support a - * `channel` property. Which allows you to selectively display an individual element on a - * per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) - - @JvmStatic - fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) - - @JvmStatic - fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) - - @JvmStatic - fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) - - /** - * Allows you to group elements together. This can be useful when used in combination with - * "if" or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - @JvmStatic - fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) - - @JvmStatic - fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) - } - - /** - * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. - */ - interface Visitor { - - fun visitUnionMember0(unionMember0: UnionMember0): T - - fun visitUnionMember1(unionMember1: UnionMember1): T - - /** - * The channel element allows a notification to be customized based on which channel it is - * sent through. For example, you may want to display a detailed message when the - * notification is sent through email, and a more concise message in a push notification. - * Channel elements are only valid as top-level elements; you cannot nest channel elements. - * If there is a channel element specified at the top-level of the document, all sibling - * elements must be channel elements. Note: As an alternative, most elements support a - * `channel` property. Which allows you to selectively display an individual element on a - * per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun visitUnionMember2(unionMember2: UnionMember2): T - - fun visitUnionMember3(unionMember3: UnionMember3): T - - fun visitUnionMember4(unionMember4: UnionMember4): T - - fun visitUnionMember5(unionMember5: UnionMember5): T - - /** - * Allows you to group elements together. This can be useful when used in combination with - * "if" or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - fun visitUnionMember6(unionMember6: UnionMember6): T - - fun visitUnionMember7(unionMember7: UnionMember7): T - - /** - * Maps an unknown variant of [ElementalNode] to a value of type [T]. - * - * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older version - * than the API, then the API may respond with new variants that the SDK is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown ElementalNode: $json") - } - } - - internal class Deserializer : BaseDeserializer(ElementalNode::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember1 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember2 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember3 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember4 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember5 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember6 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ElementalNode(unionMember7 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> ElementalNode(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ElementalNode::class) { - - override fun serialize( - value: ElementalNode, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.unionMember1 != null -> generator.writeObject(value.unionMember1) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value.unionMember3 != null -> generator.writeObject(value.unionMember3) - value.unionMember4 != null -> generator.writeObject(value.unionMember4) - value.unionMember5 != null -> generator.writeObject(value.unionMember5) - value.unionMember6 != null -> generator.writeObject(value.unionMember6) - value.unionMember7 != null -> generator.writeObject(value.unionMember7) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ElementalNode") - } - } - } - - class UnionMember0 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember0]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - channels = unionMember0.channels.map { it.toMutableList() } - if_ = unionMember0.if_ - loop = unionMember0.loop - ref = unionMember0.ref - type = unionMember0.type - additionalProperties = unionMember0.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember0]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember0 = - UnionMember0( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember0 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val TEXT = of("text") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - TEXT - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - TEXT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - TEXT -> Value.TEXT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - TEXT -> Known.TEXT - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember0 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember1 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember1]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember1: UnionMember1) = apply { - channels = unionMember1.channels.map { it.toMutableList() } - if_ = unionMember1.if_ - loop = unionMember1.loop - ref = unionMember1.ref - type = unionMember1.type - additionalProperties = unionMember1.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember1]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember1 = - UnionMember1( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember1 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val META = of("meta") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - META - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - META, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - META -> Value.META - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - META -> Known.META - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember1 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - /** - * The channel element allows a notification to be customized based on which channel it is sent - * through. For example, you may want to display a detailed message when the notification is - * sent through email, and a more concise message in a push notification. Channel elements are - * only valid as top-level elements; you cannot nest channel elements. If there is a channel - * element specified at the top-level of the document, all sibling elements must be channel - * elements. Note: As an alternative, most elements support a `channel` property. Which allows - * you to selectively display an individual element on a per channel basis. See the - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - class UnionMember2 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channel: JsonField, - private val channels: JsonField>, - private val elements: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val raw: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("raw") - @ExcludeMissing - raw: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channel, channels, elements, if_, loop, raw, ref, type, mutableMapOf()) - - fun toElementalChannelNode(): ElementalChannelNode = - ElementalChannelNode.builder() - .channel(channel) - .channels(channels) - .elements(elements) - .if_(if_) - .loop(loop) - .raw(raw) - .ref(ref) - .build() - - /** - * The channel the contents of this element should be applied to. Can be `email`, `push`, - * `direct_message`, `sms` or a provider such as slack - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun channel(): String = channel.getRequired("channel") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, `elements` - * is `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun elements(): Optional> = elements.getOptional("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun raw(): Optional = raw.getOptional("raw") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channel]. - * - * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [raw]. - * - * Unlike [raw], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("raw") @ExcludeMissing fun _raw(): JsonField = raw - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember2]. - * - * The following fields are required: - * ```java - * .channel() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember2]. */ - class Builder internal constructor() { - - private var channel: JsonField? = null - private var channels: JsonField>? = null - private var elements: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var raw: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - channel = unionMember2.channel - channels = unionMember2.channels.map { it.toMutableList() } - elements = unionMember2.elements.map { it.toMutableList() } - if_ = unionMember2.if_ - loop = unionMember2.loop - raw = unionMember2.raw - ref = unionMember2.ref - type = unionMember2.type - additionalProperties = unionMember2.additionalProperties.toMutableMap() - } - - /** - * The channel the contents of this element should be applied to. Can be `email`, - * `push`, `direct_message`, `sms` or a provider such as slack - */ - fun channel(channel: String) = channel(JsonField.of(channel)) - - /** - * Sets [Builder.channel] to an arbitrary JSON value. - * - * You should usually call [Builder.channel] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channel(channel: JsonField) = apply { this.channel = channel } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - /** - * An array of elements to apply to the channel. If `raw` has not been specified, - * `elements` is `required`. - */ - fun elements(elements: List?) = elements(JsonField.ofNullable(elements)) - - /** Alias for calling [Builder.elements] with `elements.orElse(null)`. */ - fun elements(elements: Optional>) = elements(elements.getOrNull()) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - /** - * Raw data to apply to the channel. If `elements` has not been specified, `raw` is - * `required`. - */ - fun raw(raw: ElementalChannelNode.Raw?) = raw(JsonField.ofNullable(raw)) - - /** Alias for calling [Builder.raw] with `raw.orElse(null)`. */ - fun raw(raw: Optional) = raw(raw.getOrNull()) - - /** - * Sets [Builder.raw] to an arbitrary JSON value. - * - * You should usually call [Builder.raw] with a well-typed [ElementalChannelNode.Raw] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun raw(raw: JsonField) = apply { this.raw = raw } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember2]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .channel() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember2 = - UnionMember2( - checkRequired("channel", channel), - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - (elements ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - raw, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember2 = apply { - if (validated) { - return@apply - } - - channel() - channels() - elements().ifPresent { it.forEach { it.validate() } } - if_() - loop() - raw().ifPresent { it.validate() } - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (channel.asKnown().isPresent) 1 else 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (raw.asKnown().getOrNull()?.validity() ?: 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHANNEL = of("channel") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - CHANNEL - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHANNEL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHANNEL -> Value.CHANNEL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CHANNEL -> Known.CHANNEL - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember2 && - channel == other.channel && - channels == other.channels && - elements == other.elements && - if_ == other.if_ && - loop == other.loop && - raw == other.raw && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - channel, - channels, - elements, - if_, - loop, - raw, - ref, - type, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember2{channel=$channel, channels=$channels, elements=$elements, if_=$if_, loop=$loop, raw=$raw, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember3 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember3]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember3: UnionMember3) = apply { - channels = unionMember3.channels.map { it.toMutableList() } - if_ = unionMember3.if_ - loop = unionMember3.loop - ref = unionMember3.ref - type = unionMember3.type - additionalProperties = unionMember3.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember3]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember3 = - UnionMember3( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember3 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val IMAGE = of("image") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - IMAGE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - IMAGE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - IMAGE -> Value.IMAGE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - IMAGE -> Known.IMAGE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember3 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember4 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember4]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember4]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember4: UnionMember4) = apply { - channels = unionMember4.channels.map { it.toMutableList() } - if_ = unionMember4.if_ - loop = unionMember4.loop - ref = unionMember4.ref - type = unionMember4.type - additionalProperties = unionMember4.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember4]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember4 = - UnionMember4( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember4 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTION = of("action") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - ACTION - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTION, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTION -> Value.ACTION - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTION -> Known.ACTION - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember4 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember4{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember5 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember5]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember5]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember5: UnionMember5) = apply { - channels = unionMember5.channels.map { it.toMutableList() } - if_ = unionMember5.if_ - loop = unionMember5.loop - ref = unionMember5.ref - type = unionMember5.type - additionalProperties = unionMember5.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember5]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember5 = - UnionMember5( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember5 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DIVIDER = of("divider") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - DIVIDER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DIVIDER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DIVIDER -> Value.DIVIDER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DIVIDER -> Known.DIVIDER - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember5 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember5{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - /** - * Allows you to group elements together. This can be useful when used in combination with "if" - * or "loop". See - * [control flow docs](https://www.courier.com/docs/platform/content/elemental/control-flow/) - * for more details. - */ - class UnionMember6 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val elements: JsonField>, - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("elements") - @ExcludeMissing - elements: JsonField> = JsonMissing.of(), - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(elements, channels, if_, loop, ref, type, mutableMapOf()) - - fun toElementalGroupNode(): ElementalGroupNode = - ElementalGroupNode.builder() - .elements(elements) - .channels(channels) - .if_(if_) - .loop(loop) - .ref(ref) - .build() - - /** - * Sub elements to render. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun elements(): List = elements.getRequired("elements") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [elements]. - * - * Unlike [elements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("elements") - @ExcludeMissing - fun _elements(): JsonField> = elements - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember6]. - * - * The following fields are required: - * ```java - * .elements() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember6]. */ - class Builder internal constructor() { - - private var elements: JsonField>? = null - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember6: UnionMember6) = apply { - elements = unionMember6.elements.map { it.toMutableList() } - channels = unionMember6.channels.map { it.toMutableList() } - if_ = unionMember6.if_ - loop = unionMember6.loop - ref = unionMember6.ref - type = unionMember6.type - additionalProperties = unionMember6.additionalProperties.toMutableMap() - } - - /** Sub elements to render. */ - fun elements(elements: List) = elements(JsonField.of(elements)) - - /** - * Sets [Builder.elements] to an arbitrary JSON value. - * - * You should usually call [Builder.elements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun elements(elements: JsonField>) = apply { - this.elements = elements.map { it.toMutableList() } - } - - /** - * Adds a single [ElementalNode] to [elements]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addElement(element: ElementalNode) = apply { - elements = - (elements ?: JsonField.of(mutableListOf())).also { - checkKnown("elements", it).add(element) - } - } - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember0(unionMember0)`. */ - fun addElement(unionMember0: UnionMember0) = - addElement(ElementalNode.ofUnionMember0(unionMember0)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember1(unionMember1)`. */ - fun addElement(unionMember1: UnionMember1) = - addElement(ElementalNode.ofUnionMember1(unionMember1)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember2(unionMember2)`. */ - fun addElement(unionMember2: UnionMember2) = - addElement(ElementalNode.ofUnionMember2(unionMember2)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember3(unionMember3)`. */ - fun addElement(unionMember3: UnionMember3) = - addElement(ElementalNode.ofUnionMember3(unionMember3)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember4(unionMember4)`. */ - fun addElement(unionMember4: UnionMember4) = - addElement(ElementalNode.ofUnionMember4(unionMember4)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember5(unionMember5)`. */ - fun addElement(unionMember5: UnionMember5) = - addElement(ElementalNode.ofUnionMember5(unionMember5)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember6(unionMember6)`. */ - fun addElement(unionMember6: UnionMember6) = - addElement(ElementalNode.ofUnionMember6(unionMember6)) - - /** Alias for calling [addElement] with `ElementalNode.ofUnionMember7(unionMember7)`. */ - fun addElement(unionMember7: UnionMember7) = - addElement(ElementalNode.ofUnionMember7(unionMember7)) - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember6]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .elements() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember6 = - UnionMember6( - checkRequired("elements", elements).map { it.toImmutable() }, - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember6 = apply { - if (validated) { - return@apply - } - - elements().forEach { it.validate() } - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (elements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val GROUP = of("group") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - GROUP - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - GROUP, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - GROUP -> Value.GROUP - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - GROUP -> Known.GROUP - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember6 && - elements == other.elements && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(elements, channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember6{elements=$elements, channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } - - class UnionMember7 - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val channels: JsonField>, - private val if_: JsonField, - private val loop: JsonField, - private val ref: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("channels") - @ExcludeMissing - channels: JsonField> = JsonMissing.of(), - @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), - @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), - @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(channels, if_, loop, ref, type, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun channels(): Optional> = channels.getOptional("channels") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun if_(): Optional = if_.getOptional("if") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun loop(): Optional = loop.getOptional("loop") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ref(): Optional = ref.getOptional("ref") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [channels]. - * - * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("channels") - @ExcludeMissing - fun _channels(): JsonField> = channels - - /** - * Returns the raw JSON value of [if_]. - * - * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ - - /** - * Returns the raw JSON value of [loop]. - * - * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop - - /** - * Returns the raw JSON value of [ref]. - * - * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [UnionMember7]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember7]. */ - class Builder internal constructor() { - - private var channels: JsonField>? = null - private var if_: JsonField = JsonMissing.of() - private var loop: JsonField = JsonMissing.of() - private var ref: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember7: UnionMember7) = apply { - channels = unionMember7.channels.map { it.toMutableList() } - if_ = unionMember7.if_ - loop = unionMember7.loop - ref = unionMember7.ref - type = unionMember7.type - additionalProperties = unionMember7.additionalProperties.toMutableMap() - } - - fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) - - /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ - fun channels(channels: Optional>) = channels(channels.getOrNull()) - - /** - * Sets [Builder.channels] to an arbitrary JSON value. - * - * You should usually call [Builder.channels] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun channels(channels: JsonField>) = apply { - this.channels = channels.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [channels]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addChannel(channel: String) = apply { - channels = - (channels ?: JsonField.of(mutableListOf())).also { - checkKnown("channels", it).add(channel) - } - } - - fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) - - /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ - fun if_(if_: Optional) = if_(if_.getOrNull()) - - /** - * Sets [Builder.if_] to an arbitrary JSON value. - * - * You should usually call [Builder.if_] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun if_(if_: JsonField) = apply { this.if_ = if_ } - - fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) - - /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ - fun loop(loop: Optional) = loop(loop.getOrNull()) - - /** - * Sets [Builder.loop] to an arbitrary JSON value. - * - * You should usually call [Builder.loop] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun loop(loop: JsonField) = apply { this.loop = loop } - - fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) - - /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ - fun ref(ref: Optional) = ref(ref.getOrNull()) - - /** - * Sets [Builder.ref] to an arbitrary JSON value. - * - * You should usually call [Builder.ref] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ref(ref: JsonField) = apply { this.ref = ref } - - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember7]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnionMember7 = - UnionMember7( - (channels ?: JsonMissing.of()).map { it.toImmutable() }, - if_, - loop, - ref, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember7 = apply { - if (validated) { - return@apply - } - - channels() - if_() - loop() - ref() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (channels.asKnown().getOrNull()?.size ?: 0) + - (if (if_.asKnown().isPresent) 1 else 0) + - (if (loop.asKnown().isPresent) 1 else 0) + - (if (ref.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val QUOTE = of("quote") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - QUOTE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - QUOTE, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - QUOTE -> Value.QUOTE - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - QUOTE -> Known.QUOTE - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CourierInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UnionMember7 && - channels == other.channels && - if_ == other.if_ && - loop == other.loop && - ref == other.ref && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(channels, if_, loop, ref, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember7{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt deleted file mode 100644 index 815f14c1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListParams.kt +++ /dev/null @@ -1,236 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** List Templates in Tenant */ -class TemplateListParams -private constructor( - private val tenantId: String?, - private val cursor: String?, - private val limit: Long?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Continue the pagination with the next cursor */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** The number of templates to return (defaults to 20, maximum value of 100) */ - fun limit(): Optional = Optional.ofNullable(limit) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TemplateListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TemplateListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TemplateListParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var cursor: String? = null - private var limit: Long? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(templateListParams: TemplateListParams) = apply { - tenantId = templateListParams.tenantId - cursor = templateListParams.cursor - limit = templateListParams.limit - additionalHeaders = templateListParams.additionalHeaders.toBuilder() - additionalQueryParams = templateListParams.additionalQueryParams.toBuilder() - } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** Continue the pagination with the next cursor */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** The number of templates to return (defaults to 20, maximum value of 100) */ - fun limit(limit: Long?) = apply { this.limit = limit } - - /** - * Alias for [Builder.limit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun limit(limit: Long) = limit(limit as Long?) - - /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ - fun limit(limit: Optional) = limit(limit.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TemplateListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TemplateListParams = - TemplateListParams( - tenantId, - cursor, - limit, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - limit?.let { put("limit", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TemplateListParams && - tenantId == other.tenantId && - cursor == other.cursor && - limit == other.limit && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tenantId, cursor, limit, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TemplateListParams{tenantId=$tenantId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt deleted file mode 100644 index 5447eab6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateListResponse.kt +++ /dev/null @@ -1,1030 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.notifications.MessageRouting -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TemplateListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val hasMore: JsonField, - private val type: JsonField, - private val url: JsonField, - private val cursor: JsonField, - private val items: JsonField>, - private val nextUrl: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), - @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), - @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), - ) : this(hasMore, type, url, cursor, items, nextUrl, mutableMapOf()) - - /** - * Set to true when there are more pages that can be retrieved. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun hasMore(): Boolean = hasMore.getRequired("has_more") - - /** - * Always set to `list`. Represents the type of this object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * A url that may be used to generate these results. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun url(): String = url.getRequired("url") - - /** - * A pointer to the next page of results. Defined only when `has_more` is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cursor(): Optional = cursor.getOptional("cursor") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun items(): Optional> = items.getOptional("items") - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * `has_more` is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun nextUrl(): Optional = nextUrl.getOptional("next_url") - - /** - * Returns the raw JSON value of [hasMore]. - * - * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [cursor]. - * - * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [nextUrl]. - * - * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TemplateListResponse]. - * - * The following fields are required: - * ```java - * .hasMore() - * .type() - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TemplateListResponse]. */ - class Builder internal constructor() { - - private var hasMore: JsonField? = null - private var type: JsonField? = null - private var url: JsonField? = null - private var cursor: JsonField = JsonMissing.of() - private var items: JsonField>? = null - private var nextUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(templateListResponse: TemplateListResponse) = apply { - hasMore = templateListResponse.hasMore - type = templateListResponse.type - url = templateListResponse.url - cursor = templateListResponse.cursor - items = templateListResponse.items.map { it.toMutableList() } - nextUrl = templateListResponse.nextUrl - additionalProperties = templateListResponse.additionalProperties.toMutableMap() - } - - /** Set to true when there are more pages that can be retrieved. */ - fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) - - /** - * Sets [Builder.hasMore] to an arbitrary JSON value. - * - * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } - - /** Always set to `list`. Represents the type of this object. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** A url that may be used to generate these results. */ - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - /** A pointer to the next page of results. Defined only when `has_more` is set to true */ - fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** - * Sets [Builder.cursor] to an arbitrary JSON value. - * - * You should usually call [Builder.cursor] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun items(items: List?) = items(JsonField.ofNullable(items)) - - /** Alias for calling [Builder.items] with `items.orElse(null)`. */ - fun items(items: Optional>) = items(items.getOrNull()) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [Item] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: Item) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * `has_more` is set to true - */ - fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) - - /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ - fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) - - /** - * Sets [Builder.nextUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TemplateListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .hasMore() - * .type() - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TemplateListResponse = - TemplateListResponse( - checkRequired("hasMore", hasMore), - checkRequired("type", type), - checkRequired("url", url), - cursor, - (items ?: JsonMissing.of()).map { it.toImmutable() }, - nextUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TemplateListResponse = apply { - if (validated) { - return@apply - } - - hasMore() - type().validate() - url() - cursor() - items().ifPresent { it.forEach { it.validate() } } - nextUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (hasMore.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (url.asKnown().isPresent) 1 else 0) + - (if (cursor.asKnown().isPresent) 1 else 0) + - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (nextUrl.asKnown().isPresent) 1 else 0) - - /** Always set to `list`. Represents the type of this object. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIST = of("list") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - LIST - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST -> Value.LIST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LIST -> Known.LIST - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val createdAt: JsonField, - private val publishedAt: JsonField, - private val updatedAt: JsonField, - private val version: JsonField, - private val data: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("published_at") - @ExcludeMissing - publishedAt: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("version") @ExcludeMissing version: JsonField = JsonMissing.of(), - @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), - ) : this(id, createdAt, publishedAt, updatedAt, version, data, mutableMapOf()) - - fun toBaseTemplateTenantAssociation(): BaseTemplateTenantAssociation = - BaseTemplateTenantAssociation.builder() - .id(id) - .createdAt(createdAt) - .publishedAt(publishedAt) - .updatedAt(updatedAt) - .version(version) - .build() - - /** - * The template's id - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun id(): String = id.getRequired("id") - - /** - * The timestamp at which the template was created - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun createdAt(): String = createdAt.getRequired("created_at") - - /** - * The timestamp at which the template was published - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun publishedAt(): String = publishedAt.getRequired("published_at") - - /** - * The timestamp at which the template was last updated - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun updatedAt(): String = updatedAt.getRequired("updated_at") - - /** - * The version of the template - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun version(): String = version.getRequired("version") - - /** - * The template's data containing it's routing configs - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun data(): Data = data.getRequired("data") - - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - - /** - * Returns the raw JSON value of [createdAt]. - * - * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt(): JsonField = createdAt - - /** - * Returns the raw JSON value of [publishedAt]. - * - * Unlike [publishedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("published_at") - @ExcludeMissing - fun _publishedAt(): JsonField = publishedAt - - /** - * Returns the raw JSON value of [updatedAt]. - * - * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("updated_at") @ExcludeMissing fun _updatedAt(): JsonField = updatedAt - - /** - * Returns the raw JSON value of [version]. - * - * Unlike [version], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version - - /** - * Returns the raw JSON value of [data]. - * - * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Item]. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .publishedAt() - * .updatedAt() - * .version() - * .data() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Item]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var createdAt: JsonField? = null - private var publishedAt: JsonField? = null - private var updatedAt: JsonField? = null - private var version: JsonField? = null - private var data: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(item: Item) = apply { - id = item.id - createdAt = item.createdAt - publishedAt = item.publishedAt - updatedAt = item.updatedAt - version = item.version - data = item.data - additionalProperties = item.additionalProperties.toMutableMap() - } - - /** The template's id */ - fun id(id: String) = id(JsonField.of(id)) - - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun id(id: JsonField) = apply { this.id = id } - - /** The timestamp at which the template was created */ - fun createdAt(createdAt: String) = createdAt(JsonField.of(createdAt)) - - /** - * Sets [Builder.createdAt] to an arbitrary JSON value. - * - * You should usually call [Builder.createdAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - - /** The timestamp at which the template was published */ - fun publishedAt(publishedAt: String) = publishedAt(JsonField.of(publishedAt)) - - /** - * Sets [Builder.publishedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.publishedAt] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun publishedAt(publishedAt: JsonField) = apply { - this.publishedAt = publishedAt - } - - /** The timestamp at which the template was last updated */ - fun updatedAt(updatedAt: String) = updatedAt(JsonField.of(updatedAt)) - - /** - * Sets [Builder.updatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.updatedAt] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - - /** The version of the template */ - fun version(version: String) = version(JsonField.of(version)) - - /** - * Sets [Builder.version] to an arbitrary JSON value. - * - * You should usually call [Builder.version] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun version(version: JsonField) = apply { this.version = version } - - /** The template's data containing it's routing configs */ - fun data(data: Data) = data(JsonField.of(data)) - - /** - * Sets [Builder.data] to an arbitrary JSON value. - * - * You should usually call [Builder.data] with a well-typed [Data] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun data(data: JsonField) = apply { this.data = data } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .createdAt() - * .publishedAt() - * .updatedAt() - * .version() - * .data() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Item = - Item( - checkRequired("id", id), - checkRequired("createdAt", createdAt), - checkRequired("publishedAt", publishedAt), - checkRequired("updatedAt", updatedAt), - checkRequired("version", version), - checkRequired("data", data), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - id() - createdAt() - publishedAt() - updatedAt() - version() - data().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (id.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (publishedAt.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) + - (data.asKnown().getOrNull()?.validity() ?: 0) - - /** The template's data containing it's routing configs */ - class Data - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val routing: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("routing") - @ExcludeMissing - routing: JsonField = JsonMissing.of() - ) : this(routing, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun routing(): MessageRouting = routing.getRequired("routing") - - /** - * Returns the raw JSON value of [routing]. - * - * Unlike [routing], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("routing") - @ExcludeMissing - fun _routing(): JsonField = routing - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Data]. - * - * The following fields are required: - * ```java - * .routing() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Data]. */ - class Builder internal constructor() { - - private var routing: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(data: Data) = apply { - routing = data.routing - additionalProperties = data.additionalProperties.toMutableMap() - } - - fun routing(routing: MessageRouting) = routing(JsonField.of(routing)) - - /** - * Sets [Builder.routing] to an arbitrary JSON value. - * - * You should usually call [Builder.routing] with a well-typed [MessageRouting] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun routing(routing: JsonField) = apply { this.routing = routing } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Data]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .routing() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Data = - Data(checkRequired("routing", routing), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Data = apply { - if (validated) { - return@apply - } - - routing().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (routing.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Data && - routing == other.routing && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(routing, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Data{routing=$routing, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Item && - id == other.id && - createdAt == other.createdAt && - publishedAt == other.publishedAt && - updatedAt == other.updatedAt && - version == other.version && - data == other.data && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(id, createdAt, publishedAt, updatedAt, version, data, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Item{id=$id, createdAt=$createdAt, publishedAt=$publishedAt, updatedAt=$updatedAt, version=$version, data=$data, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TemplateListResponse && - hasMore == other.hasMore && - type == other.type && - url == other.url && - cursor == other.cursor && - items == other.items && - nextUrl == other.nextUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(hasMore, type, url, cursor, items, nextUrl, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TemplateListResponse{hasMore=$hasMore, type=$type, url=$url, cursor=$cursor, items=$items, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt deleted file mode 100644 index 58f4908c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParams.kt +++ /dev/null @@ -1,217 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get a Template in Tenant */ -class TemplateRetrieveParams -private constructor( - private val tenantId: String, - private val templateId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun tenantId(): String = tenantId - - fun templateId(): Optional = Optional.ofNullable(templateId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TemplateRetrieveParams]. - * - * The following fields are required: - * ```java - * .tenantId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TemplateRetrieveParams]. */ - class Builder internal constructor() { - - private var tenantId: String? = null - private var templateId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(templateRetrieveParams: TemplateRetrieveParams) = apply { - tenantId = templateRetrieveParams.tenantId - templateId = templateRetrieveParams.templateId - additionalHeaders = templateRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = templateRetrieveParams.additionalQueryParams.toBuilder() - } - - fun tenantId(tenantId: String) = apply { this.tenantId = tenantId } - - fun templateId(templateId: String?) = apply { this.templateId = templateId } - - /** Alias for calling [Builder.templateId] with `templateId.orElse(null)`. */ - fun templateId(templateId: Optional) = templateId(templateId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TemplateRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tenantId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TemplateRetrieveParams = - TemplateRetrieveParams( - checkRequired("tenantId", tenantId), - templateId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> tenantId - 1 -> templateId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TemplateRetrieveParams && - tenantId == other.tenantId && - templateId == other.templateId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(tenantId, templateId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TemplateRetrieveParams{tenantId=$tenantId, templateId=$templateId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt deleted file mode 100644 index 1742f669..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationRetrieveParams.kt +++ /dev/null @@ -1,217 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.translations - -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get translations by locale */ -class TranslationRetrieveParams -private constructor( - private val domain: String, - private val locale: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun domain(): String = domain - - fun locale(): Optional = Optional.ofNullable(locale) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TranslationRetrieveParams]. - * - * The following fields are required: - * ```java - * .domain() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TranslationRetrieveParams]. */ - class Builder internal constructor() { - - private var domain: String? = null - private var locale: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(translationRetrieveParams: TranslationRetrieveParams) = apply { - domain = translationRetrieveParams.domain - locale = translationRetrieveParams.locale - additionalHeaders = translationRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = translationRetrieveParams.additionalQueryParams.toBuilder() - } - - fun domain(domain: String) = apply { this.domain = domain } - - fun locale(locale: String?) = apply { this.locale = locale } - - /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ - fun locale(locale: Optional) = locale(locale.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TranslationRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .domain() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TranslationRetrieveParams = - TranslationRetrieveParams( - checkRequired("domain", domain), - locale, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> domain - 1 -> locale ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TranslationRetrieveParams && - domain == other.domain && - locale == other.locale && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(domain, locale, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TranslationRetrieveParams{domain=$domain, locale=$locale, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt deleted file mode 100644 index 437e07e5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/translations/TranslationUpdateParams.kt +++ /dev/null @@ -1,230 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.translations - -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Update a translation */ -class TranslationUpdateParams -private constructor( - private val domain: String, - private val locale: String?, - private val body: String, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun domain(): String = domain - - fun locale(): Optional = Optional.ofNullable(locale) - - fun body(): String = body - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TranslationUpdateParams]. - * - * The following fields are required: - * ```java - * .domain() - * .body() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TranslationUpdateParams]. */ - class Builder internal constructor() { - - private var domain: String? = null - private var locale: String? = null - private var body: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(translationUpdateParams: TranslationUpdateParams) = apply { - domain = translationUpdateParams.domain - locale = translationUpdateParams.locale - body = translationUpdateParams.body - additionalHeaders = translationUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = translationUpdateParams.additionalQueryParams.toBuilder() - } - - fun domain(domain: String) = apply { this.domain = domain } - - fun locale(locale: String?) = apply { this.locale = locale } - - /** Alias for calling [Builder.locale] with `locale.orElse(null)`. */ - fun locale(locale: Optional) = locale(locale.getOrNull()) - - fun body(body: String) = apply { this.body = body } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TranslationUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .domain() - * .body() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TranslationUpdateParams = - TranslationUpdateParams( - checkRequired("domain", domain), - locale, - checkRequired("body", body), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): String = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> domain - 1 -> locale ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TranslationUpdateParams && - domain == other.domain && - locale == other.locale && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(domain, locale, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TranslationUpdateParams{domain=$domain, locale=$locale, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt deleted file mode 100644 index 0346f3c8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParams.kt +++ /dev/null @@ -1,214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch all user preferences. */ -class PreferenceRetrieveParams -private constructor( - private val userId: String?, - private val tenantId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Query the preferences of a user for this specific tenant context. */ - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): PreferenceRetrieveParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [PreferenceRetrieveParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PreferenceRetrieveParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var tenantId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(preferenceRetrieveParams: PreferenceRetrieveParams) = apply { - userId = preferenceRetrieveParams.userId - tenantId = preferenceRetrieveParams.tenantId - additionalHeaders = preferenceRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = preferenceRetrieveParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** Query the preferences of a user for this specific tenant context. */ - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [PreferenceRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PreferenceRetrieveParams = - PreferenceRetrieveParams( - userId, - tenantId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - tenantId?.let { put("tenant_id", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceRetrieveParams && - userId == other.userId && - tenantId == other.tenantId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, tenantId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "PreferenceRetrieveParams{userId=$userId, tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt deleted file mode 100644 index d0a335ea..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponse.kt +++ /dev/null @@ -1,230 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class PreferenceRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val items: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("items") - @ExcludeMissing - items: JsonField> = JsonMissing.of(), - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - ) : this(items, paging, mutableMapOf()) - - /** - * The Preferences associated with the user_id. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun items(): List = items.getRequired("items") - - /** - * Deprecated - Paging not implemented on this endpoint - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun paging(): Paging = paging.getRequired("paging") - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [paging]. - * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PreferenceRetrieveResponse]. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PreferenceRetrieveResponse]. */ - class Builder internal constructor() { - - private var items: JsonField>? = null - private var paging: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(preferenceRetrieveResponse: PreferenceRetrieveResponse) = apply { - items = preferenceRetrieveResponse.items.map { it.toMutableList() } - paging = preferenceRetrieveResponse.paging - additionalProperties = preferenceRetrieveResponse.additionalProperties.toMutableMap() - } - - /** The Preferences associated with the user_id. */ - fun items(items: List) = items(JsonField.of(items)) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [TopicPreference] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: TopicPreference) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - /** Deprecated - Paging not implemented on this endpoint */ - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - /** - * Sets [Builder.paging] to an arbitrary JSON value. - * - * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PreferenceRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .items() - * .paging() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PreferenceRetrieveResponse = - PreferenceRetrieveResponse( - checkRequired("items", items).map { it.toImmutable() }, - checkRequired("paging", paging), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PreferenceRetrieveResponse = apply { - if (validated) { - return@apply - } - - items().forEach { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (paging.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceRetrieveResponse && - items == other.items && - paging == other.paging && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(items, paging, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PreferenceRetrieveResponse{items=$items, paging=$paging, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt deleted file mode 100644 index c0cf1b3a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParams.kt +++ /dev/null @@ -1,238 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Fetch user preferences for a specific subscription topic. */ -class PreferenceRetrieveTopicParams -private constructor( - private val userId: String, - private val topicId: String?, - private val tenantId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): String = userId - - fun topicId(): Optional = Optional.ofNullable(topicId) - - /** Query the preferences of a user for this specific tenant context. */ - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PreferenceRetrieveTopicParams]. - * - * The following fields are required: - * ```java - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PreferenceRetrieveTopicParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var topicId: String? = null - private var tenantId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(preferenceRetrieveTopicParams: PreferenceRetrieveTopicParams) = apply { - userId = preferenceRetrieveTopicParams.userId - topicId = preferenceRetrieveTopicParams.topicId - tenantId = preferenceRetrieveTopicParams.tenantId - additionalHeaders = preferenceRetrieveTopicParams.additionalHeaders.toBuilder() - additionalQueryParams = preferenceRetrieveTopicParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun topicId(topicId: String?) = apply { this.topicId = topicId } - - /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ - fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) - - /** Query the preferences of a user for this specific tenant context. */ - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [PreferenceRetrieveTopicParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PreferenceRetrieveTopicParams = - PreferenceRetrieveTopicParams( - checkRequired("userId", userId), - topicId, - tenantId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> topicId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - tenantId?.let { put("tenant_id", it) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceRetrieveTopicParams && - userId == other.userId && - topicId == other.topicId && - tenantId == other.tenantId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, topicId, tenantId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "PreferenceRetrieveTopicParams{userId=$userId, topicId=$topicId, tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt deleted file mode 100644 index 76484333..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponse.kt +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import kotlin.jvm.optionals.getOrNull - -class PreferenceRetrieveTopicResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val topic: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of() - ) : this(topic, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun topic(): TopicPreference = topic.getRequired("topic") - - /** - * Returns the raw JSON value of [topic]. - * - * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PreferenceRetrieveTopicResponse]. - * - * The following fields are required: - * ```java - * .topic() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PreferenceRetrieveTopicResponse]. */ - class Builder internal constructor() { - - private var topic: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(preferenceRetrieveTopicResponse: PreferenceRetrieveTopicResponse) = - apply { - topic = preferenceRetrieveTopicResponse.topic - additionalProperties = - preferenceRetrieveTopicResponse.additionalProperties.toMutableMap() - } - - fun topic(topic: TopicPreference) = topic(JsonField.of(topic)) - - /** - * Sets [Builder.topic] to an arbitrary JSON value. - * - * You should usually call [Builder.topic] with a well-typed [TopicPreference] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun topic(topic: JsonField) = apply { this.topic = topic } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PreferenceRetrieveTopicResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .topic() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PreferenceRetrieveTopicResponse = - PreferenceRetrieveTopicResponse( - checkRequired("topic", topic), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PreferenceRetrieveTopicResponse = apply { - if (validated) { - return@apply - } - - topic().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (topic.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceRetrieveTopicResponse && - topic == other.topic && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(topic, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PreferenceRetrieveTopicResponse{topic=$topic, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt deleted file mode 100644 index 9d7c1ad6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceStatus.kt +++ /dev/null @@ -1,139 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.Enum -import com.courier.api.core.JsonField -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator - -class PreferenceStatus @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't match - * any known member, and you want to know that value. For example, if the SDK is on an older - * version than the API, then the API may respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val OPTED_IN = of("OPTED_IN") - - @JvmField val OPTED_OUT = of("OPTED_OUT") - - @JvmField val REQUIRED = of("REQUIRED") - - @JvmStatic fun of(value: String) = PreferenceStatus(JsonField.of(value)) - } - - /** An enum containing [PreferenceStatus]'s known values. */ - enum class Known { - OPTED_IN, - OPTED_OUT, - REQUIRED, - } - - /** - * An enum containing [PreferenceStatus]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PreferenceStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the SDK - * is on an older version than the API, then the API may respond with new members that the SDK - * is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - OPTED_IN, - OPTED_OUT, - REQUIRED, - /** - * An enum member indicating that [PreferenceStatus] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] if - * the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want to - * throw for the unknown case. - */ - fun value(): Value = - when (this) { - OPTED_IN -> Value.OPTED_IN - OPTED_OUT -> Value.OPTED_OUT - REQUIRED -> Value.REQUIRED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't want - * to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - OPTED_IN -> Known.OPTED_IN - OPTED_OUT -> Known.OPTED_OUT - REQUIRED -> Known.REQUIRED - else -> throw CourierInvalidDataException("Unknown PreferenceStatus: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging and - * generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the expected - * primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PreferenceStatus = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceStatus && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt deleted file mode 100644 index 1c42555d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParams.kt +++ /dev/null @@ -1,745 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Update or Create user preferences for a specific subscription topic. */ -class PreferenceUpdateOrCreateTopicParams -private constructor( - private val userId: String, - private val topicId: String?, - private val tenantId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): String = userId - - fun topicId(): Optional = Optional.ofNullable(topicId) - - /** Update the preferences of a user for this specific tenant context. */ - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun topic(): Topic = body.topic() - - /** - * Returns the raw JSON value of [topic]. - * - * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _topic(): JsonField = body._topic() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PreferenceUpdateOrCreateTopicParams]. - * - * The following fields are required: - * ```java - * .userId() - * .topic() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PreferenceUpdateOrCreateTopicParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var topicId: String? = null - private var tenantId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from( - preferenceUpdateOrCreateTopicParams: PreferenceUpdateOrCreateTopicParams - ) = apply { - userId = preferenceUpdateOrCreateTopicParams.userId - topicId = preferenceUpdateOrCreateTopicParams.topicId - tenantId = preferenceUpdateOrCreateTopicParams.tenantId - body = preferenceUpdateOrCreateTopicParams.body.toBuilder() - additionalHeaders = preferenceUpdateOrCreateTopicParams.additionalHeaders.toBuilder() - additionalQueryParams = - preferenceUpdateOrCreateTopicParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun topicId(topicId: String?) = apply { this.topicId = topicId } - - /** Alias for calling [Builder.topicId] with `topicId.orElse(null)`. */ - fun topicId(topicId: Optional) = topicId(topicId.getOrNull()) - - /** Update the preferences of a user for this specific tenant context. */ - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [topic] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun topic(topic: Topic) = apply { body.topic(topic) } - - /** - * Sets [Builder.topic] to an arbitrary JSON value. - * - * You should usually call [Builder.topic] with a well-typed [Topic] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun topic(topic: JsonField) = apply { body.topic(topic) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [PreferenceUpdateOrCreateTopicParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * .topic() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PreferenceUpdateOrCreateTopicParams = - PreferenceUpdateOrCreateTopicParams( - checkRequired("userId", userId), - topicId, - tenantId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> topicId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - tenantId?.let { put("tenant_id", it) } - putAll(additionalQueryParams) - } - .build() - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val topic: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("topic") @ExcludeMissing topic: JsonField = JsonMissing.of() - ) : this(topic, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun topic(): Topic = topic.getRequired("topic") - - /** - * Returns the raw JSON value of [topic]. - * - * Unlike [topic], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic") @ExcludeMissing fun _topic(): JsonField = topic - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .topic() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var topic: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - topic = body.topic - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun topic(topic: Topic) = topic(JsonField.of(topic)) - - /** - * Sets [Builder.topic] to an arbitrary JSON value. - * - * You should usually call [Builder.topic] with a well-typed [Topic] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun topic(topic: JsonField) = apply { this.topic = topic } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .topic() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body(checkRequired("topic", topic), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - topic().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (topic.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - topic == other.topic && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(topic, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{topic=$topic, additionalProperties=$additionalProperties}" - } - - class Topic - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val status: JsonField, - private val customRouting: JsonField>, - private val hasCustomRouting: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("custom_routing") - @ExcludeMissing - customRouting: JsonField> = JsonMissing.of(), - @JsonProperty("has_custom_routing") - @ExcludeMissing - hasCustomRouting: JsonField = JsonMissing.of(), - ) : this(status, customRouting, hasCustomRouting, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): PreferenceStatus = status.getRequired("status") - - /** - * The Channels a user has chosen to receive notifications through for this topic - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customRouting(): Optional> = - customRouting.getOptional("custom_routing") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hasCustomRouting(): Optional = - hasCustomRouting.getOptional("has_custom_routing") - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [customRouting]. - * - * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_routing") - @ExcludeMissing - fun _customRouting(): JsonField> = customRouting - - /** - * Returns the raw JSON value of [hasCustomRouting]. - * - * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("has_custom_routing") - @ExcludeMissing - fun _hasCustomRouting(): JsonField = hasCustomRouting - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Topic]. - * - * The following fields are required: - * ```java - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Topic]. */ - class Builder internal constructor() { - - private var status: JsonField? = null - private var customRouting: JsonField>? = null - private var hasCustomRouting: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(topic: Topic) = apply { - status = topic.status - customRouting = topic.customRouting.map { it.toMutableList() } - hasCustomRouting = topic.hasCustomRouting - additionalProperties = topic.additionalProperties.toMutableMap() - } - - fun status(status: PreferenceStatus) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** The Channels a user has chosen to receive notifications through for this topic */ - fun customRouting(customRouting: List?) = - customRouting(JsonField.ofNullable(customRouting)) - - /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ - fun customRouting(customRouting: Optional>) = - customRouting(customRouting.getOrNull()) - - /** - * Sets [Builder.customRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.customRouting] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun customRouting(customRouting: JsonField>) = apply { - this.customRouting = customRouting.map { it.toMutableList() } - } - - /** - * Adds a single [ChannelClassification] to [Builder.customRouting]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCustomRouting(customRouting: ChannelClassification) = apply { - this.customRouting = - (this.customRouting ?: JsonField.of(mutableListOf())).also { - checkKnown("customRouting", it).add(customRouting) - } - } - - fun hasCustomRouting(hasCustomRouting: Boolean?) = - hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) - - /** - * Alias for [Builder.hasCustomRouting]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hasCustomRouting(hasCustomRouting: Boolean) = - hasCustomRouting(hasCustomRouting as Boolean?) - - /** - * Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. - */ - fun hasCustomRouting(hasCustomRouting: Optional) = - hasCustomRouting(hasCustomRouting.getOrNull()) - - /** - * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun hasCustomRouting(hasCustomRouting: JsonField) = apply { - this.hasCustomRouting = hasCustomRouting - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Topic]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Topic = - Topic( - checkRequired("status", status), - (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, - hasCustomRouting, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Topic = apply { - if (validated) { - return@apply - } - - status().validate() - customRouting().ifPresent { it.forEach { it.validate() } } - hasCustomRouting() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (status.asKnown().getOrNull()?.validity() ?: 0) + - (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (hasCustomRouting.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Topic && - status == other.status && - customRouting == other.customRouting && - hasCustomRouting == other.hasCustomRouting && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(status, customRouting, hasCustomRouting, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Topic{status=$status, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceUpdateOrCreateTopicParams && - userId == other.userId && - topicId == other.topicId && - tenantId == other.tenantId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, topicId, tenantId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "PreferenceUpdateOrCreateTopicParams{userId=$userId, topicId=$topicId, tenantId=$tenantId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt deleted file mode 100644 index 84fb4447..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponse.kt +++ /dev/null @@ -1,174 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects - -class PreferenceUpdateOrCreateTopicResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val message: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of() - ) : this(message, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): String = message.getRequired("message") - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [PreferenceUpdateOrCreateTopicResponse]. - * - * The following fields are required: - * ```java - * .message() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PreferenceUpdateOrCreateTopicResponse]. */ - class Builder internal constructor() { - - private var message: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - preferenceUpdateOrCreateTopicResponse: PreferenceUpdateOrCreateTopicResponse - ) = apply { - message = preferenceUpdateOrCreateTopicResponse.message - additionalProperties = - preferenceUpdateOrCreateTopicResponse.additionalProperties.toMutableMap() - } - - fun message(message: String) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PreferenceUpdateOrCreateTopicResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .message() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PreferenceUpdateOrCreateTopicResponse = - PreferenceUpdateOrCreateTopicResponse( - checkRequired("message", message), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PreferenceUpdateOrCreateTopicResponse = apply { - if (validated) { - return@apply - } - - message() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (message.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PreferenceUpdateOrCreateTopicResponse && - message == other.message && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(message, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PreferenceUpdateOrCreateTopicResponse{message=$message, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt deleted file mode 100644 index 8f537432..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/preferences/TopicPreference.kt +++ /dev/null @@ -1,417 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TopicPreference -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val defaultStatus: JsonField, - private val status: JsonField, - private val topicId: JsonField, - private val topicName: JsonField, - private val customRouting: JsonField>, - private val hasCustomRouting: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("default_status") - @ExcludeMissing - defaultStatus: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("topic_id") @ExcludeMissing topicId: JsonField = JsonMissing.of(), - @JsonProperty("topic_name") @ExcludeMissing topicName: JsonField = JsonMissing.of(), - @JsonProperty("custom_routing") - @ExcludeMissing - customRouting: JsonField> = JsonMissing.of(), - @JsonProperty("has_custom_routing") - @ExcludeMissing - hasCustomRouting: JsonField = JsonMissing.of(), - ) : this( - defaultStatus, - status, - topicId, - topicName, - customRouting, - hasCustomRouting, - mutableMapOf(), - ) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun defaultStatus(): PreferenceStatus = defaultStatus.getRequired("default_status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun status(): PreferenceStatus = status.getRequired("status") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun topicId(): String = topicId.getRequired("topic_id") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun topicName(): String = topicName.getRequired("topic_name") - - /** - * The Channels a user has chosen to receive notifications through for this topic - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customRouting(): Optional> = - customRouting.getOptional("custom_routing") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hasCustomRouting(): Optional = hasCustomRouting.getOptional("has_custom_routing") - - /** - * Returns the raw JSON value of [defaultStatus]. - * - * Unlike [defaultStatus], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("default_status") - @ExcludeMissing - fun _defaultStatus(): JsonField = defaultStatus - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [topicId]. - * - * Unlike [topicId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic_id") @ExcludeMissing fun _topicId(): JsonField = topicId - - /** - * Returns the raw JSON value of [topicName]. - * - * Unlike [topicName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("topic_name") @ExcludeMissing fun _topicName(): JsonField = topicName - - /** - * Returns the raw JSON value of [customRouting]. - * - * Unlike [customRouting], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("custom_routing") - @ExcludeMissing - fun _customRouting(): JsonField> = customRouting - - /** - * Returns the raw JSON value of [hasCustomRouting]. - * - * Unlike [hasCustomRouting], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("has_custom_routing") - @ExcludeMissing - fun _hasCustomRouting(): JsonField = hasCustomRouting - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TopicPreference]. - * - * The following fields are required: - * ```java - * .defaultStatus() - * .status() - * .topicId() - * .topicName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TopicPreference]. */ - class Builder internal constructor() { - - private var defaultStatus: JsonField? = null - private var status: JsonField? = null - private var topicId: JsonField? = null - private var topicName: JsonField? = null - private var customRouting: JsonField>? = null - private var hasCustomRouting: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(topicPreference: TopicPreference) = apply { - defaultStatus = topicPreference.defaultStatus - status = topicPreference.status - topicId = topicPreference.topicId - topicName = topicPreference.topicName - customRouting = topicPreference.customRouting.map { it.toMutableList() } - hasCustomRouting = topicPreference.hasCustomRouting - additionalProperties = topicPreference.additionalProperties.toMutableMap() - } - - fun defaultStatus(defaultStatus: PreferenceStatus) = - defaultStatus(JsonField.of(defaultStatus)) - - /** - * Sets [Builder.defaultStatus] to an arbitrary JSON value. - * - * You should usually call [Builder.defaultStatus] with a well-typed [PreferenceStatus] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun defaultStatus(defaultStatus: JsonField) = apply { - this.defaultStatus = defaultStatus - } - - fun status(status: PreferenceStatus) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [PreferenceStatus] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun topicId(topicId: String) = topicId(JsonField.of(topicId)) - - /** - * Sets [Builder.topicId] to an arbitrary JSON value. - * - * You should usually call [Builder.topicId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun topicId(topicId: JsonField) = apply { this.topicId = topicId } - - fun topicName(topicName: String) = topicName(JsonField.of(topicName)) - - /** - * Sets [Builder.topicName] to an arbitrary JSON value. - * - * You should usually call [Builder.topicName] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun topicName(topicName: JsonField) = apply { this.topicName = topicName } - - /** The Channels a user has chosen to receive notifications through for this topic */ - fun customRouting(customRouting: List?) = - customRouting(JsonField.ofNullable(customRouting)) - - /** Alias for calling [Builder.customRouting] with `customRouting.orElse(null)`. */ - fun customRouting(customRouting: Optional>) = - customRouting(customRouting.getOrNull()) - - /** - * Sets [Builder.customRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.customRouting] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun customRouting(customRouting: JsonField>) = apply { - this.customRouting = customRouting.map { it.toMutableList() } - } - - /** - * Adds a single [ChannelClassification] to [Builder.customRouting]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCustomRouting(customRouting: ChannelClassification) = apply { - this.customRouting = - (this.customRouting ?: JsonField.of(mutableListOf())).also { - checkKnown("customRouting", it).add(customRouting) - } - } - - fun hasCustomRouting(hasCustomRouting: Boolean?) = - hasCustomRouting(JsonField.ofNullable(hasCustomRouting)) - - /** - * Alias for [Builder.hasCustomRouting]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hasCustomRouting(hasCustomRouting: Boolean) = - hasCustomRouting(hasCustomRouting as Boolean?) - - /** Alias for calling [Builder.hasCustomRouting] with `hasCustomRouting.orElse(null)`. */ - fun hasCustomRouting(hasCustomRouting: Optional) = - hasCustomRouting(hasCustomRouting.getOrNull()) - - /** - * Sets [Builder.hasCustomRouting] to an arbitrary JSON value. - * - * You should usually call [Builder.hasCustomRouting] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun hasCustomRouting(hasCustomRouting: JsonField) = apply { - this.hasCustomRouting = hasCustomRouting - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TopicPreference]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .defaultStatus() - * .status() - * .topicId() - * .topicName() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TopicPreference = - TopicPreference( - checkRequired("defaultStatus", defaultStatus), - checkRequired("status", status), - checkRequired("topicId", topicId), - checkRequired("topicName", topicName), - (customRouting ?: JsonMissing.of()).map { it.toImmutable() }, - hasCustomRouting, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TopicPreference = apply { - if (validated) { - return@apply - } - - defaultStatus().validate() - status().validate() - topicId() - topicName() - customRouting().ifPresent { it.forEach { it.validate() } } - hasCustomRouting() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (defaultStatus.asKnown().getOrNull()?.validity() ?: 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (topicId.asKnown().isPresent) 1 else 0) + - (if (topicName.asKnown().isPresent) 1 else 0) + - (customRouting.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (hasCustomRouting.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TopicPreference && - defaultStatus == other.defaultStatus && - status == other.status && - topicId == other.topicId && - topicName == other.topicName && - customRouting == other.customRouting && - hasCustomRouting == other.hasCustomRouting && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - defaultStatus, - status, - topicId, - topicName, - customRouting, - hasCustomRouting, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TopicPreference{defaultStatus=$defaultStatus, status=$status, topicId=$topicId, topicName=$topicName, customRouting=$customRouting, hasCustomRouting=$hasCustomRouting, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt deleted file mode 100644 index de433ce2..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParams.kt +++ /dev/null @@ -1,467 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * This endpoint is used to add a user to multiple tenants in one call. A custom profile can also be - * supplied for each tenant. This profile will be merged with the user's main profile when sending - * to the user with that tenant. - */ -class TenantAddMultipleParams -private constructor( - private val userId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tenants(): List = body.tenants() - - /** - * Returns the raw JSON value of [tenants]. - * - * Unlike [tenants], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _tenants(): JsonField> = body._tenants() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantAddMultipleParams]. - * - * The following fields are required: - * ```java - * .tenants() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantAddMultipleParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantAddMultipleParams: TenantAddMultipleParams) = apply { - userId = tenantAddMultipleParams.userId - body = tenantAddMultipleParams.body.toBuilder() - additionalHeaders = tenantAddMultipleParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantAddMultipleParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [tenants] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun tenants(tenants: List) = apply { body.tenants(tenants) } - - /** - * Sets [Builder.tenants] to an arbitrary JSON value. - * - * You should usually call [Builder.tenants] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun tenants(tenants: JsonField>) = apply { body.tenants(tenants) } - - /** - * Adds a single [TenantAssociation] to [tenants]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTenant(tenant: TenantAssociation) = apply { body.addTenant(tenant) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantAddMultipleParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tenants() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantAddMultipleParams = - TenantAddMultipleParams( - userId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val tenants: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("tenants") - @ExcludeMissing - tenants: JsonField> = JsonMissing.of() - ) : this(tenants, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tenants(): List = tenants.getRequired("tenants") - - /** - * Returns the raw JSON value of [tenants]. - * - * Unlike [tenants], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tenants") - @ExcludeMissing - fun _tenants(): JsonField> = tenants - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .tenants() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var tenants: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - tenants = body.tenants.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun tenants(tenants: List) = tenants(JsonField.of(tenants)) - - /** - * Sets [Builder.tenants] to an arbitrary JSON value. - * - * You should usually call [Builder.tenants] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tenants(tenants: JsonField>) = apply { - this.tenants = tenants.map { it.toMutableList() } - } - - /** - * Adds a single [TenantAssociation] to [tenants]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTenant(tenant: TenantAssociation) = apply { - tenants = - (tenants ?: JsonField.of(mutableListOf())).also { - checkKnown("tenants", it).add(tenant) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tenants() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("tenants", tenants).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - tenants().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (tenants.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - tenants == other.tenants && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(tenants, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{tenants=$tenants, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantAddMultipleParams && - userId == other.userId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantAddMultipleParams{userId=$userId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt deleted file mode 100644 index b4f8f878..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParams.kt +++ /dev/null @@ -1,537 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * This endpoint is used to add a single tenant. - * - * A custom profile can also be supplied with the tenant. This profile will be merged with the - * user's main profile when sending to the user with that tenant. - */ -class TenantAddSingleParams -private constructor( - private val userId: String, - private val tenantId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): String = userId - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun profile(): Optional = body.profile() - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _profile(): JsonField = body._profile() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantAddSingleParams]. - * - * The following fields are required: - * ```java - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantAddSingleParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var tenantId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantAddSingleParams: TenantAddSingleParams) = apply { - userId = tenantAddSingleParams.userId - tenantId = tenantAddSingleParams.tenantId - body = tenantAddSingleParams.body.toBuilder() - additionalHeaders = tenantAddSingleParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantAddSingleParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [profile] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun profile(profile: Profile?) = apply { body.profile(profile) } - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { body.profile(profile) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantAddSingleParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantAddSingleParams = - TenantAddSingleParams( - checkRequired("userId", userId), - tenantId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val profile: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of() - ) : this(profile, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun profile(): Optional = profile.getOptional("profile") - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var profile: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - profile = body.profile - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(profile, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - profile().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (profile.asKnown().getOrNull()?.validity() ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - profile == other.profile && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(profile, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{profile=$profile, additionalProperties=$additionalProperties}" - } - - class Profile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Profile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Profile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profile: Profile) = apply { - additionalProperties = profile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Profile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Profile = Profile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Profile{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantAddSingleParams && - userId == other.userId && - tenantId == other.tenantId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, tenantId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantAddSingleParams{userId=$userId, tenantId=$tenantId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt deleted file mode 100644 index 0d81492a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantAssociation.kt +++ /dev/null @@ -1,508 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TenantAssociation -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val tenantId: JsonField, - private val profile: JsonField, - private val type: JsonField, - private val userId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), - @JsonProperty("profile") @ExcludeMissing profile: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), - ) : this(tenantId, profile, type, userId, mutableMapOf()) - - /** - * Tenant ID for the association between tenant and user - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun tenantId(): String = tenantId.getRequired("tenant_id") - - /** - * Additional metadata to be applied to a user profile when used in a tenant context - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun profile(): Optional = profile.getOptional("profile") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * User ID for the association between tenant and user - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun userId(): Optional = userId.getOptional("user_id") - - /** - * Returns the raw JSON value of [tenantId]. - * - * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId - - /** - * Returns the raw JSON value of [profile]. - * - * Unlike [profile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("profile") @ExcludeMissing fun _profile(): JsonField = profile - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantAssociation]. - * - * The following fields are required: - * ```java - * .tenantId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantAssociation]. */ - class Builder internal constructor() { - - private var tenantId: JsonField? = null - private var profile: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantAssociation: TenantAssociation) = apply { - tenantId = tenantAssociation.tenantId - profile = tenantAssociation.profile - type = tenantAssociation.type - userId = tenantAssociation.userId - additionalProperties = tenantAssociation.additionalProperties.toMutableMap() - } - - /** Tenant ID for the association between tenant and user */ - fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) - - /** - * Sets [Builder.tenantId] to an arbitrary JSON value. - * - * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } - - /** Additional metadata to be applied to a user profile when used in a tenant context */ - fun profile(profile: Profile?) = profile(JsonField.ofNullable(profile)) - - /** Alias for calling [Builder.profile] with `profile.orElse(null)`. */ - fun profile(profile: Optional) = profile(profile.getOrNull()) - - /** - * Sets [Builder.profile] to an arbitrary JSON value. - * - * You should usually call [Builder.profile] with a well-typed [Profile] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun profile(profile: JsonField) = apply { this.profile = profile } - - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** User ID for the association between tenant and user */ - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TenantAssociation]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .tenantId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantAssociation = - TenantAssociation( - checkRequired("tenantId", tenantId), - profile, - type, - userId, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TenantAssociation = apply { - if (validated) { - return@apply - } - - tenantId() - profile().ifPresent { it.validate() } - type().ifPresent { it.validate() } - userId() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (tenantId.asKnown().isPresent) 1 else 0) + - (profile.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (userId.asKnown().isPresent) 1 else 0) - - /** Additional metadata to be applied to a user profile when used in a tenant context */ - class Profile - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Profile]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Profile]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(profile: Profile) = apply { - additionalProperties = profile.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Profile]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Profile = Profile(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): Profile = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> !value.isNull() && !value.isMissing() } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Profile && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Profile{additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val USER = of("user") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - USER - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - USER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - USER -> Value.USER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - USER -> Known.USER - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantAssociation && - tenantId == other.tenantId && - profile == other.profile && - type == other.type && - userId == other.userId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(tenantId, profile, type, userId, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TenantAssociation{tenantId=$tenantId, profile=$profile, type=$type, userId=$userId, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt deleted file mode 100644 index d91e4a01..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListParams.kt +++ /dev/null @@ -1,236 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Returns a paginated list of user tenant associations. */ -class TenantListParams -private constructor( - private val userId: String?, - private val cursor: String?, - private val limit: Long?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Continue the pagination with the next cursor */ - fun cursor(): Optional = Optional.ofNullable(cursor) - - /** The number of accounts to return (defaults to 20, maximum value of 100) */ - fun limit(): Optional = Optional.ofNullable(limit) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TenantListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TenantListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantListParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var cursor: String? = null - private var limit: Long? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tenantListParams: TenantListParams) = apply { - userId = tenantListParams.userId - cursor = tenantListParams.cursor - limit = tenantListParams.limit - additionalHeaders = tenantListParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantListParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** Continue the pagination with the next cursor */ - fun cursor(cursor: String?) = apply { this.cursor = cursor } - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** The number of accounts to return (defaults to 20, maximum value of 100) */ - fun limit(limit: Long?) = apply { this.limit = limit } - - /** - * Alias for [Builder.limit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun limit(limit: Long) = limit(limit as Long?) - - /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ - fun limit(limit: Optional) = limit(limit.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TenantListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TenantListParams = - TenantListParams( - userId, - cursor, - limit, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - cursor?.let { put("cursor", it) } - limit?.let { put("limit", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantListParams && - userId == other.userId && - cursor == other.cursor && - limit == other.limit && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, cursor, limit, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TenantListParams{userId=$userId, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt deleted file mode 100644 index 8510021b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantListResponse.kt +++ /dev/null @@ -1,501 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TenantListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val hasMore: JsonField, - private val type: JsonField, - private val url: JsonField, - private val cursor: JsonField, - private val items: JsonField>, - private val nextUrl: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("has_more") @ExcludeMissing hasMore: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), - @JsonProperty("cursor") @ExcludeMissing cursor: JsonField = JsonMissing.of(), - @JsonProperty("items") - @ExcludeMissing - items: JsonField> = JsonMissing.of(), - @JsonProperty("next_url") @ExcludeMissing nextUrl: JsonField = JsonMissing.of(), - ) : this(hasMore, type, url, cursor, items, nextUrl, mutableMapOf()) - - /** - * Set to true when there are more pages that can be retrieved. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun hasMore(): Boolean = hasMore.getRequired("has_more") - - /** - * Always set to `list`. Represents the type of this object. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun type(): Type = type.getRequired("type") - - /** - * A url that may be used to generate these results. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun url(): String = url.getRequired("url") - - /** - * A pointer to the next page of results. Defined only when `has_more` is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun cursor(): Optional = cursor.getOptional("cursor") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun items(): Optional> = items.getOptional("items") - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * `has_more` is set to true - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun nextUrl(): Optional = nextUrl.getOptional("next_url") - - /** - * Returns the raw JSON value of [hasMore]. - * - * Unlike [hasMore], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [url]. - * - * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url - - /** - * Returns the raw JSON value of [cursor]. - * - * Unlike [cursor], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cursor") @ExcludeMissing fun _cursor(): JsonField = cursor - - /** - * Returns the raw JSON value of [items]. - * - * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items - - /** - * Returns the raw JSON value of [nextUrl]. - * - * Unlike [nextUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("next_url") @ExcludeMissing fun _nextUrl(): JsonField = nextUrl - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantListResponse]. - * - * The following fields are required: - * ```java - * .hasMore() - * .type() - * .url() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantListResponse]. */ - class Builder internal constructor() { - - private var hasMore: JsonField? = null - private var type: JsonField? = null - private var url: JsonField? = null - private var cursor: JsonField = JsonMissing.of() - private var items: JsonField>? = null - private var nextUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantListResponse: TenantListResponse) = apply { - hasMore = tenantListResponse.hasMore - type = tenantListResponse.type - url = tenantListResponse.url - cursor = tenantListResponse.cursor - items = tenantListResponse.items.map { it.toMutableList() } - nextUrl = tenantListResponse.nextUrl - additionalProperties = tenantListResponse.additionalProperties.toMutableMap() - } - - /** Set to true when there are more pages that can be retrieved. */ - fun hasMore(hasMore: Boolean) = hasMore(JsonField.of(hasMore)) - - /** - * Sets [Builder.hasMore] to an arbitrary JSON value. - * - * You should usually call [Builder.hasMore] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } - - /** Always set to `list`. Represents the type of this object. */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** A url that may be used to generate these results. */ - fun url(url: String) = url(JsonField.of(url)) - - /** - * Sets [Builder.url] to an arbitrary JSON value. - * - * You should usually call [Builder.url] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun url(url: JsonField) = apply { this.url = url } - - /** A pointer to the next page of results. Defined only when `has_more` is set to true */ - fun cursor(cursor: String?) = cursor(JsonField.ofNullable(cursor)) - - /** Alias for calling [Builder.cursor] with `cursor.orElse(null)`. */ - fun cursor(cursor: Optional) = cursor(cursor.getOrNull()) - - /** - * Sets [Builder.cursor] to an arbitrary JSON value. - * - * You should usually call [Builder.cursor] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun cursor(cursor: JsonField) = apply { this.cursor = cursor } - - fun items(items: List?) = items(JsonField.ofNullable(items)) - - /** Alias for calling [Builder.items] with `items.orElse(null)`. */ - fun items(items: Optional>) = items(items.getOrNull()) - - /** - * Sets [Builder.items] to an arbitrary JSON value. - * - * You should usually call [Builder.items] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun items(items: JsonField>) = apply { - this.items = items.map { it.toMutableList() } - } - - /** - * Adds a single [TenantAssociation] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: TenantAssociation) = apply { - items = - (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } - } - - /** - * A url that may be used to generate fetch the next set of results. Defined only when - * `has_more` is set to true - */ - fun nextUrl(nextUrl: String?) = nextUrl(JsonField.ofNullable(nextUrl)) - - /** Alias for calling [Builder.nextUrl] with `nextUrl.orElse(null)`. */ - fun nextUrl(nextUrl: Optional) = nextUrl(nextUrl.getOrNull()) - - /** - * Sets [Builder.nextUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.nextUrl] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun nextUrl(nextUrl: JsonField) = apply { this.nextUrl = nextUrl } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TenantListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .hasMore() - * .type() - * .url() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantListResponse = - TenantListResponse( - checkRequired("hasMore", hasMore), - checkRequired("type", type), - checkRequired("url", url), - cursor, - (items ?: JsonMissing.of()).map { it.toImmutable() }, - nextUrl, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TenantListResponse = apply { - if (validated) { - return@apply - } - - hasMore() - type().validate() - url() - cursor() - items().ifPresent { it.forEach { it.validate() } } - nextUrl() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (hasMore.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (url.asKnown().isPresent) 1 else 0) + - (if (cursor.asKnown().isPresent) 1 else 0) + - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (nextUrl.asKnown().isPresent) 1 else 0) - - /** Always set to `list`. Represents the type of this object. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val LIST = of("list") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - LIST - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - LIST, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - LIST -> Value.LIST - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - LIST -> Known.LIST - else -> throw CourierInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantListResponse && - hasMore == other.hasMore && - type == other.type && - url == other.url && - cursor == other.cursor && - items == other.items && - nextUrl == other.nextUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(hasMore, type, url, cursor, items, nextUrl, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TenantListResponse{hasMore=$hasMore, type=$type, url=$url, cursor=$cursor, items=$items, nextUrl=$nextUrl, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt deleted file mode 100644 index d450f273..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParams.kt +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Removes a user from any tenants they may have been associated with. */ -class TenantRemoveAllParams -private constructor( - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TenantRemoveAllParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TenantRemoveAllParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantRemoveAllParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantRemoveAllParams: TenantRemoveAllParams) = apply { - userId = tenantRemoveAllParams.userId - additionalHeaders = tenantRemoveAllParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantRemoveAllParams.additionalQueryParams.toBuilder() - additionalBodyProperties = tenantRemoveAllParams.additionalBodyProperties.toMutableMap() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [TenantRemoveAllParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TenantRemoveAllParams = - TenantRemoveAllParams( - userId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantRemoveAllParams && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "TenantRemoveAllParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt deleted file mode 100644 index 771b17c5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParams.kt +++ /dev/null @@ -1,259 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Removes a user from the supplied tenant. */ -class TenantRemoveSingleParams -private constructor( - private val userId: String, - private val tenantId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun userId(): String = userId - - fun tenantId(): Optional = Optional.ofNullable(tenantId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TenantRemoveSingleParams]. - * - * The following fields are required: - * ```java - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TenantRemoveSingleParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var tenantId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tenantRemoveSingleParams: TenantRemoveSingleParams) = apply { - userId = tenantRemoveSingleParams.userId - tenantId = tenantRemoveSingleParams.tenantId - additionalHeaders = tenantRemoveSingleParams.additionalHeaders.toBuilder() - additionalQueryParams = tenantRemoveSingleParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - tenantRemoveSingleParams.additionalBodyProperties.toMutableMap() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun tenantId(tenantId: String?) = apply { this.tenantId = tenantId } - - /** Alias for calling [Builder.tenantId] with `tenantId.orElse(null)`. */ - fun tenantId(tenantId: Optional) = tenantId(tenantId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [TenantRemoveSingleParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TenantRemoveSingleParams = - TenantRemoveSingleParams( - checkRequired("userId", userId), - tenantId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> tenantId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TenantRemoveSingleParams && - userId == other.userId && - tenantId == other.tenantId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash( - userId, - tenantId, - additionalHeaders, - additionalQueryParams, - additionalBodyProperties, - ) - - override fun toString() = - "TenantRemoveSingleParams{userId=$userId, tenantId=$tenantId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt deleted file mode 100644 index 45875576..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParams.kt +++ /dev/null @@ -1,230 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Adds multiple tokens to a user and overwrites matching existing tokens. */ -class TokenAddMultipleParams -private constructor( - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TokenAddMultipleParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TokenAddMultipleParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenAddMultipleParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tokenAddMultipleParams: TokenAddMultipleParams) = apply { - userId = tokenAddMultipleParams.userId - additionalHeaders = tokenAddMultipleParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenAddMultipleParams.additionalQueryParams.toBuilder() - additionalBodyProperties = - tokenAddMultipleParams.additionalBodyProperties.toMutableMap() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [TokenAddMultipleParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TokenAddMultipleParams = - TokenAddMultipleParams( - userId, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenAddMultipleParams && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash(userId, additionalHeaders, additionalQueryParams, additionalBodyProperties) - - override fun toString() = - "TokenAddMultipleParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt deleted file mode 100644 index 404a50fa..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParams.kt +++ /dev/null @@ -1,233 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Adds a single token to a user and overwrites a matching existing token. */ -class TokenAddSingleParams -private constructor( - private val userId: String, - private val pathToken: String?, - private val userToken: UserToken, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): String = userId - - fun pathToken(): Optional = Optional.ofNullable(pathToken) - - fun userToken(): UserToken = userToken - - fun _additionalBodyProperties(): Map = userToken._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TokenAddSingleParams]. - * - * The following fields are required: - * ```java - * .userId() - * .userToken() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenAddSingleParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var pathToken: String? = null - private var userToken: UserToken? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tokenAddSingleParams: TokenAddSingleParams) = apply { - userId = tokenAddSingleParams.userId - pathToken = tokenAddSingleParams.pathToken - userToken = tokenAddSingleParams.userToken - additionalHeaders = tokenAddSingleParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenAddSingleParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun pathToken(pathToken: String?) = apply { this.pathToken = pathToken } - - /** Alias for calling [Builder.pathToken] with `pathToken.orElse(null)`. */ - fun pathToken(pathToken: Optional) = pathToken(pathToken.getOrNull()) - - fun userToken(userToken: UserToken) = apply { this.userToken = userToken } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TokenAddSingleParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * .userToken() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenAddSingleParams = - TokenAddSingleParams( - checkRequired("userId", userId), - pathToken, - checkRequired("userToken", userToken), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): UserToken = userToken - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> pathToken ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenAddSingleParams && - userId == other.userId && - pathToken == other.pathToken && - userToken == other.userToken && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, pathToken, userToken, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TokenAddSingleParams{userId=$userId, pathToken=$pathToken, userToken=$userToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt deleted file mode 100644 index c4345cfe..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenDeleteParams.kt +++ /dev/null @@ -1,258 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Delete User Token */ -class TokenDeleteParams -private constructor( - private val userId: String, - private val token: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, - private val additionalBodyProperties: Map, -) : Params { - - fun userId(): String = userId - - fun token(): Optional = Optional.ofNullable(token) - - /** Additional body properties to send with the request. */ - fun _additionalBodyProperties(): Map = additionalBodyProperties - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TokenDeleteParams]. - * - * The following fields are required: - * ```java - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenDeleteParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var token: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - private var additionalBodyProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tokenDeleteParams: TokenDeleteParams) = apply { - userId = tokenDeleteParams.userId - token = tokenDeleteParams.token - additionalHeaders = tokenDeleteParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenDeleteParams.additionalQueryParams.toBuilder() - additionalBodyProperties = tokenDeleteParams.additionalBodyProperties.toMutableMap() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun token(token: String?) = apply { this.token = token } - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - this.additionalBodyProperties.clear() - putAllAdditionalBodyProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - additionalBodyProperties.put(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - this.additionalBodyProperties.putAll(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { - additionalBodyProperties.remove(key) - } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalBodyProperty) - } - - /** - * Returns an immutable instance of [TokenDeleteParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenDeleteParams = - TokenDeleteParams( - checkRequired("userId", userId), - token, - additionalHeaders.build(), - additionalQueryParams.build(), - additionalBodyProperties.toImmutable(), - ) - } - - fun _body(): Optional> = - Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> token ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenDeleteParams && - userId == other.userId && - token == other.token && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams && - additionalBodyProperties == other.additionalBodyProperties - } - - override fun hashCode(): Int = - Objects.hash( - userId, - token, - additionalHeaders, - additionalQueryParams, - additionalBodyProperties, - ) - - override fun toString() = - "TokenDeleteParams{userId=$userId, token=$token, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt deleted file mode 100644 index 31aab221..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenListParams.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.Params -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Gets all tokens available for a :user_id */ -class TokenListParams -private constructor( - private val userId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): Optional = Optional.ofNullable(userId) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): TokenListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [TokenListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenListParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tokenListParams: TokenListParams) = apply { - userId = tokenListParams.userId - additionalHeaders = tokenListParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenListParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String?) = apply { this.userId = userId } - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TokenListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): TokenListParams = - TokenListParams(userId, additionalHeaders.build(), additionalQueryParams.build()) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenListParams && - userId == other.userId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = Objects.hash(userId, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TokenListParams{userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt deleted file mode 100644 index 8bbc02b8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParams.kt +++ /dev/null @@ -1,217 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.Params -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Get single token available for a `:token` */ -class TokenRetrieveParams -private constructor( - private val userId: String, - private val token: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): String = userId - - fun token(): Optional = Optional.ofNullable(token) - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TokenRetrieveParams]. - * - * The following fields are required: - * ```java - * .userId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenRetrieveParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var token: String? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tokenRetrieveParams: TokenRetrieveParams) = apply { - userId = tokenRetrieveParams.userId - token = tokenRetrieveParams.token - additionalHeaders = tokenRetrieveParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenRetrieveParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun token(token: String?) = apply { this.token = token } - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TokenRetrieveParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenRetrieveParams = - TokenRetrieveParams( - checkRequired("userId", userId), - token, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> token ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenRetrieveParams && - userId == other.userId && - token == other.token && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, token, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TokenRetrieveParams{userId=$userId, token=$token, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt deleted file mode 100644 index 981fe28e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponse.kt +++ /dev/null @@ -1,616 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.checkRequired -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class TokenRetrieveResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val providerKey: JsonField, - private val token: JsonField, - private val device: JsonField, - private val expiryDate: JsonField, - private val properties: JsonValue, - private val tracking: JsonField, - private val status: JsonField, - private val statusReason: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("provider_key") - @ExcludeMissing - providerKey: JsonField = JsonMissing.of(), - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("device") - @ExcludeMissing - device: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("properties") @ExcludeMissing properties: JsonValue = JsonMissing.of(), - @JsonProperty("tracking") - @ExcludeMissing - tracking: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("status_reason") - @ExcludeMissing - statusReason: JsonField = JsonMissing.of(), - ) : this( - providerKey, - token, - device, - expiryDate, - properties, - tracking, - status, - statusReason, - mutableMapOf(), - ) - - fun toUserToken(): UserToken = - UserToken.builder() - .providerKey(providerKey) - .token(token) - .device(device) - .expiryDate(expiryDate) - .properties(properties) - .tracking(tracking) - .build() - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun providerKey(): UserToken.ProviderKey = providerKey.getRequired("provider_key") - - /** - * Full body of the token. Must match token in URL. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun token(): Optional = token.getOptional("token") - - /** - * Information about the device the token is associated with. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun device(): Optional = device.getOptional("device") - - /** - * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable - * expiration. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiryDate(): Optional = expiryDate.getOptional("expiry_date") - - /** Properties sent to the provider along with the token */ - @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties - - /** - * Information about the device the token is associated with. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tracking(): Optional = tracking.getOptional("tracking") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun status(): Optional = status.getOptional("status") - - /** - * The reason for the token status. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun statusReason(): Optional = statusReason.getOptional("status_reason") - - /** - * Returns the raw JSON value of [providerKey]. - * - * Unlike [providerKey], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("provider_key") - @ExcludeMissing - fun _providerKey(): JsonField = providerKey - - /** - * Returns the raw JSON value of [token]. - * - * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - - /** - * Returns the raw JSON value of [device]. - * - * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device - - /** - * Returns the raw JSON value of [expiryDate]. - * - * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - /** - * Returns the raw JSON value of [tracking]. - * - * Unlike [tracking], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tracking") - @ExcludeMissing - fun _tracking(): JsonField = tracking - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [statusReason]. - * - * Unlike [statusReason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status_reason") - @ExcludeMissing - fun _statusReason(): JsonField = statusReason - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TokenRetrieveResponse]. - * - * The following fields are required: - * ```java - * .providerKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenRetrieveResponse]. */ - class Builder internal constructor() { - - private var providerKey: JsonField? = null - private var token: JsonField = JsonMissing.of() - private var device: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var properties: JsonValue = JsonMissing.of() - private var tracking: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var statusReason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tokenRetrieveResponse: TokenRetrieveResponse) = apply { - providerKey = tokenRetrieveResponse.providerKey - token = tokenRetrieveResponse.token - device = tokenRetrieveResponse.device - expiryDate = tokenRetrieveResponse.expiryDate - properties = tokenRetrieveResponse.properties - tracking = tokenRetrieveResponse.tracking - status = tokenRetrieveResponse.status - statusReason = tokenRetrieveResponse.statusReason - additionalProperties = tokenRetrieveResponse.additionalProperties.toMutableMap() - } - - fun providerKey(providerKey: UserToken.ProviderKey) = providerKey(JsonField.of(providerKey)) - - /** - * Sets [Builder.providerKey] to an arbitrary JSON value. - * - * You should usually call [Builder.providerKey] with a well-typed [UserToken.ProviderKey] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun providerKey(providerKey: JsonField) = apply { - this.providerKey = providerKey - } - - /** Full body of the token. Must match token in URL. */ - fun token(token: String?) = token(JsonField.ofNullable(token)) - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - /** Information about the device the token is associated with. */ - fun device(device: UserToken.Device?) = device(JsonField.ofNullable(device)) - - /** Alias for calling [Builder.device] with `device.orElse(null)`. */ - fun device(device: Optional) = device(device.getOrNull()) - - /** - * Sets [Builder.device] to an arbitrary JSON value. - * - * You should usually call [Builder.device] with a well-typed [UserToken.Device] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun device(device: JsonField) = apply { this.device = device } - - /** - * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable - * expiration. - */ - fun expiryDate(expiryDate: UserToken.ExpiryDate?) = - expiryDate(JsonField.ofNullable(expiryDate)) - - /** Alias for calling [Builder.expiryDate] with `expiryDate.orElse(null)`. */ - fun expiryDate(expiryDate: Optional) = - expiryDate(expiryDate.getOrNull()) - - /** - * Sets [Builder.expiryDate] to an arbitrary JSON value. - * - * You should usually call [Builder.expiryDate] with a well-typed [UserToken.ExpiryDate] - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun expiryDate(expiryDate: JsonField) = apply { - this.expiryDate = expiryDate - } - - /** Alias for calling [expiryDate] with `UserToken.ExpiryDate.ofString(string)`. */ - fun expiryDate(string: String) = expiryDate(UserToken.ExpiryDate.ofString(string)) - - /** Alias for calling [expiryDate] with `UserToken.ExpiryDate.ofBool(bool)`. */ - fun expiryDate(bool: Boolean) = expiryDate(UserToken.ExpiryDate.ofBool(bool)) - - /** Properties sent to the provider along with the token */ - fun properties(properties: JsonValue) = apply { this.properties = properties } - - /** Information about the device the token is associated with. */ - fun tracking(tracking: UserToken.Tracking?) = tracking(JsonField.ofNullable(tracking)) - - /** Alias for calling [Builder.tracking] with `tracking.orElse(null)`. */ - fun tracking(tracking: Optional) = tracking(tracking.getOrNull()) - - /** - * Sets [Builder.tracking] to an arbitrary JSON value. - * - * You should usually call [Builder.tracking] with a well-typed [UserToken.Tracking] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun tracking(tracking: JsonField) = apply { this.tracking = tracking } - - fun status(status: Status?) = status(JsonField.ofNullable(status)) - - /** Alias for calling [Builder.status] with `status.orElse(null)`. */ - fun status(status: Optional) = status(status.getOrNull()) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** The reason for the token status. */ - fun statusReason(statusReason: String?) = statusReason(JsonField.ofNullable(statusReason)) - - /** Alias for calling [Builder.statusReason] with `statusReason.orElse(null)`. */ - fun statusReason(statusReason: Optional) = statusReason(statusReason.getOrNull()) - - /** - * Sets [Builder.statusReason] to an arbitrary JSON value. - * - * You should usually call [Builder.statusReason] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun statusReason(statusReason: JsonField) = apply { - this.statusReason = statusReason - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [TokenRetrieveResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .providerKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenRetrieveResponse = - TokenRetrieveResponse( - checkRequired("providerKey", providerKey), - token, - device, - expiryDate, - properties, - tracking, - status, - statusReason, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): TokenRetrieveResponse = apply { - if (validated) { - return@apply - } - - providerKey().validate() - token() - device().ifPresent { it.validate() } - expiryDate().ifPresent { it.validate() } - tracking().ifPresent { it.validate() } - status().ifPresent { it.validate() } - statusReason() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (providerKey.asKnown().getOrNull()?.validity() ?: 0) + - (if (token.asKnown().isPresent) 1 else 0) + - (device.asKnown().getOrNull()?.validity() ?: 0) + - (expiryDate.asKnown().getOrNull()?.validity() ?: 0) + - (tracking.asKnown().getOrNull()?.validity() ?: 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (statusReason.asKnown().isPresent) 1 else 0) - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACTIVE = of("active") - - @JvmField val UNKNOWN = of("unknown") - - @JvmField val FAILED = of("failed") - - @JvmField val REVOKED = of("revoked") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - ACTIVE, - UNKNOWN, - FAILED, - REVOKED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTIVE, - UNKNOWN, - FAILED, - REVOKED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - UNKNOWN -> Value.UNKNOWN - FAILED -> Value.FAILED - REVOKED -> Value.REVOKED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - UNKNOWN -> Known.UNKNOWN - FAILED -> Known.FAILED - REVOKED -> Known.REVOKED - else -> throw CourierInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Status = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenRetrieveResponse && - providerKey == other.providerKey && - token == other.token && - device == other.device && - expiryDate == other.expiryDate && - properties == other.properties && - tracking == other.tracking && - status == other.status && - statusReason == other.statusReason && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - providerKey, - token, - device, - expiryDate, - properties, - tracking, - status, - statusReason, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "TokenRetrieveResponse{providerKey=$providerKey, token=$token, device=$device, expiryDate=$expiryDate, properties=$properties, tracking=$tracking, status=$status, statusReason=$statusReason, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt deleted file mode 100644 index d877bfc5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/TokenUpdateParams.kt +++ /dev/null @@ -1,706 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.Params -import com.courier.api.core.checkKnown -import com.courier.api.core.checkRequired -import com.courier.api.core.http.Headers -import com.courier.api.core.http.QueryParams -import com.courier.api.core.toImmutable -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Apply a JSON Patch (RFC 6902) to the specified token. */ -class TokenUpdateParams -private constructor( - private val userId: String, - private val token: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun userId(): String = userId - - fun token(): Optional = Optional.ofNullable(token) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun patch(): List = body.patch() - - /** - * Returns the raw JSON value of [patch]. - * - * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _patch(): JsonField> = body._patch() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [TokenUpdateParams]. - * - * The following fields are required: - * ```java - * .userId() - * .patch() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [TokenUpdateParams]. */ - class Builder internal constructor() { - - private var userId: String? = null - private var token: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(tokenUpdateParams: TokenUpdateParams) = apply { - userId = tokenUpdateParams.userId - token = tokenUpdateParams.token - body = tokenUpdateParams.body.toBuilder() - additionalHeaders = tokenUpdateParams.additionalHeaders.toBuilder() - additionalQueryParams = tokenUpdateParams.additionalQueryParams.toBuilder() - } - - fun userId(userId: String) = apply { this.userId = userId } - - fun token(token: String?) = apply { this.token = token } - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [patch] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - fun patch(patch: List) = apply { body.patch(patch) } - - /** - * Sets [Builder.patch] to an arbitrary JSON value. - * - * You should usually call [Builder.patch] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun patch(patch: JsonField>) = apply { body.patch(patch) } - - /** - * Adds a single [Patch] to [Builder.patch]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPatch(patch: Patch) = apply { body.addPatch(patch) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [TokenUpdateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .userId() - * .patch() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): TokenUpdateParams = - TokenUpdateParams( - checkRequired("userId", userId), - token, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> userId - 1 -> token ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = additionalQueryParams - - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val patch: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("patch") @ExcludeMissing patch: JsonField> = JsonMissing.of() - ) : this(patch, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun patch(): List = patch.getRequired("patch") - - /** - * Returns the raw JSON value of [patch]. - * - * Unlike [patch], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("patch") @ExcludeMissing fun _patch(): JsonField> = patch - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .patch() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var patch: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - patch = body.patch.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - fun patch(patch: List) = patch(JsonField.of(patch)) - - /** - * Sets [Builder.patch] to an arbitrary JSON value. - * - * You should usually call [Builder.patch] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun patch(patch: JsonField>) = apply { - this.patch = patch.map { it.toMutableList() } - } - - /** - * Adds a single [Patch] to [Builder.patch]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addPatch(patch: Patch) = apply { - this.patch = - (this.patch ?: JsonField.of(mutableListOf())).also { - checkKnown("patch", it).add(patch) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .patch() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("patch", patch).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - patch().forEach { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (patch.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - patch == other.patch && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(patch, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{patch=$patch, additionalProperties=$additionalProperties}" - } - - class Patch - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val op: JsonField, - private val path: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("op") @ExcludeMissing op: JsonField = JsonMissing.of(), - @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(op, path, value, mutableMapOf()) - - /** - * The operation to perform. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun op(): String = op.getRequired("op") - - /** - * The JSON path specifying the part of the profile to operate on. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun path(): String = path.getRequired("path") - - /** - * The value for the operation. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun value(): Optional = value.getOptional("value") - - /** - * Returns the raw JSON value of [op]. - * - * Unlike [op], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("op") @ExcludeMissing fun _op(): JsonField = op - - /** - * Returns the raw JSON value of [path]. - * - * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Patch]. - * - * The following fields are required: - * ```java - * .op() - * .path() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Patch]. */ - class Builder internal constructor() { - - private var op: JsonField? = null - private var path: JsonField? = null - private var value: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(patch: Patch) = apply { - op = patch.op - path = patch.path - value = patch.value - additionalProperties = patch.additionalProperties.toMutableMap() - } - - /** The operation to perform. */ - fun op(op: String) = op(JsonField.of(op)) - - /** - * Sets [Builder.op] to an arbitrary JSON value. - * - * You should usually call [Builder.op] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun op(op: JsonField) = apply { this.op = op } - - /** The JSON path specifying the part of the profile to operate on. */ - fun path(path: String) = path(JsonField.of(path)) - - /** - * Sets [Builder.path] to an arbitrary JSON value. - * - * You should usually call [Builder.path] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun path(path: JsonField) = apply { this.path = path } - - /** The value for the operation. */ - fun value(value: String?) = value(JsonField.ofNullable(value)) - - /** Alias for calling [Builder.value] with `value.orElse(null)`. */ - fun value(value: Optional) = value(value.getOrNull()) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Patch]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .op() - * .path() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Patch = - Patch( - checkRequired("op", op), - checkRequired("path", path), - value, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Patch = apply { - if (validated) { - return@apply - } - - op() - path() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (op.asKnown().isPresent) 1 else 0) + - (if (path.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Patch && - op == other.op && - path == other.path && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(op, path, value, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Patch{op=$op, path=$path, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TokenUpdateParams && - userId == other.userId && - token == other.token && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(userId, token, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "TokenUpdateParams{userId=$userId, token=$token, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt deleted file mode 100644 index 019a8b44..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/users/tokens/UserToken.kt +++ /dev/null @@ -1,1309 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.BaseDeserializer -import com.courier.api.core.BaseSerializer -import com.courier.api.core.Enum -import com.courier.api.core.ExcludeMissing -import com.courier.api.core.JsonField -import com.courier.api.core.JsonMissing -import com.courier.api.core.JsonValue -import com.courier.api.core.allMaxBy -import com.courier.api.core.checkRequired -import com.courier.api.core.getOrThrow -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class UserToken -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val providerKey: JsonField, - private val token: JsonField, - private val device: JsonField, - private val expiryDate: JsonField, - private val properties: JsonValue, - private val tracking: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("provider_key") - @ExcludeMissing - providerKey: JsonField = JsonMissing.of(), - @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), - @JsonProperty("device") @ExcludeMissing device: JsonField = JsonMissing.of(), - @JsonProperty("expiry_date") - @ExcludeMissing - expiryDate: JsonField = JsonMissing.of(), - @JsonProperty("properties") @ExcludeMissing properties: JsonValue = JsonMissing.of(), - @JsonProperty("tracking") @ExcludeMissing tracking: JsonField = JsonMissing.of(), - ) : this(providerKey, token, device, expiryDate, properties, tracking, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun providerKey(): ProviderKey = providerKey.getRequired("provider_key") - - /** - * Full body of the token. Must match token in URL. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun token(): Optional = token.getOptional("token") - - /** - * Information about the device the token is associated with. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun device(): Optional = device.getOptional("device") - - /** - * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable - * expiration. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun expiryDate(): Optional = expiryDate.getOptional("expiry_date") - - /** Properties sent to the provider along with the token */ - @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties - - /** - * Information about the device the token is associated with. - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun tracking(): Optional = tracking.getOptional("tracking") - - /** - * Returns the raw JSON value of [providerKey]. - * - * Unlike [providerKey], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("provider_key") - @ExcludeMissing - fun _providerKey(): JsonField = providerKey - - /** - * Returns the raw JSON value of [token]. - * - * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token - - /** - * Returns the raw JSON value of [device]. - * - * Unlike [device], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device") @ExcludeMissing fun _device(): JsonField = device - - /** - * Returns the raw JSON value of [expiryDate]. - * - * Unlike [expiryDate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("expiry_date") - @ExcludeMissing - fun _expiryDate(): JsonField = expiryDate - - /** - * Returns the raw JSON value of [tracking]. - * - * Unlike [tracking], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tracking") @ExcludeMissing fun _tracking(): JsonField = tracking - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UserToken]. - * - * The following fields are required: - * ```java - * .providerKey() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UserToken]. */ - class Builder internal constructor() { - - private var providerKey: JsonField? = null - private var token: JsonField = JsonMissing.of() - private var device: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var properties: JsonValue = JsonMissing.of() - private var tracking: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(userToken: UserToken) = apply { - providerKey = userToken.providerKey - token = userToken.token - device = userToken.device - expiryDate = userToken.expiryDate - properties = userToken.properties - tracking = userToken.tracking - additionalProperties = userToken.additionalProperties.toMutableMap() - } - - fun providerKey(providerKey: ProviderKey) = providerKey(JsonField.of(providerKey)) - - /** - * Sets [Builder.providerKey] to an arbitrary JSON value. - * - * You should usually call [Builder.providerKey] with a well-typed [ProviderKey] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun providerKey(providerKey: JsonField) = apply { - this.providerKey = providerKey - } - - /** Full body of the token. Must match token in URL. */ - fun token(token: String?) = token(JsonField.ofNullable(token)) - - /** Alias for calling [Builder.token] with `token.orElse(null)`. */ - fun token(token: Optional) = token(token.getOrNull()) - - /** - * Sets [Builder.token] to an arbitrary JSON value. - * - * You should usually call [Builder.token] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun token(token: JsonField) = apply { this.token = token } - - /** Information about the device the token is associated with. */ - fun device(device: Device?) = device(JsonField.ofNullable(device)) - - /** Alias for calling [Builder.device] with `device.orElse(null)`. */ - fun device(device: Optional) = device(device.getOrNull()) - - /** - * Sets [Builder.device] to an arbitrary JSON value. - * - * You should usually call [Builder.device] with a well-typed [Device] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun device(device: JsonField) = apply { this.device = device } - - /** - * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable - * expiration. - */ - fun expiryDate(expiryDate: ExpiryDate?) = expiryDate(JsonField.ofNullable(expiryDate)) - - /** Alias for calling [Builder.expiryDate] with `expiryDate.orElse(null)`. */ - fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.getOrNull()) - - /** - * Sets [Builder.expiryDate] to an arbitrary JSON value. - * - * You should usually call [Builder.expiryDate] with a well-typed [ExpiryDate] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - - /** Alias for calling [expiryDate] with `ExpiryDate.ofString(string)`. */ - fun expiryDate(string: String) = expiryDate(ExpiryDate.ofString(string)) - - /** Alias for calling [expiryDate] with `ExpiryDate.ofBool(bool)`. */ - fun expiryDate(bool: Boolean) = expiryDate(ExpiryDate.ofBool(bool)) - - /** Properties sent to the provider along with the token */ - fun properties(properties: JsonValue) = apply { this.properties = properties } - - /** Information about the device the token is associated with. */ - fun tracking(tracking: Tracking?) = tracking(JsonField.ofNullable(tracking)) - - /** Alias for calling [Builder.tracking] with `tracking.orElse(null)`. */ - fun tracking(tracking: Optional) = tracking(tracking.getOrNull()) - - /** - * Sets [Builder.tracking] to an arbitrary JSON value. - * - * You should usually call [Builder.tracking] with a well-typed [Tracking] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tracking(tracking: JsonField) = apply { this.tracking = tracking } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UserToken]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .providerKey() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UserToken = - UserToken( - checkRequired("providerKey", providerKey), - token, - device, - expiryDate, - properties, - tracking, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UserToken = apply { - if (validated) { - return@apply - } - - providerKey().validate() - token() - device().ifPresent { it.validate() } - expiryDate().ifPresent { it.validate() } - tracking().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (providerKey.asKnown().getOrNull()?.validity() ?: 0) + - (if (token.asKnown().isPresent) 1 else 0) + - (device.asKnown().getOrNull()?.validity() ?: 0) + - (expiryDate.asKnown().getOrNull()?.validity() ?: 0) + - (tracking.asKnown().getOrNull()?.validity() ?: 0) - - class ProviderKey @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIREBASE_FCM = of("firebase-fcm") - - @JvmField val APN = of("apn") - - @JvmField val EXPO = of("expo") - - @JvmField val ONESIGNAL = of("onesignal") - - @JvmStatic fun of(value: String) = ProviderKey(JsonField.of(value)) - } - - /** An enum containing [ProviderKey]'s known values. */ - enum class Known { - FIREBASE_FCM, - APN, - EXPO, - ONESIGNAL, - } - - /** - * An enum containing [ProviderKey]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ProviderKey] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FIREBASE_FCM, - APN, - EXPO, - ONESIGNAL, - /** - * An enum member indicating that [ProviderKey] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FIREBASE_FCM -> Value.FIREBASE_FCM - APN -> Value.APN - EXPO -> Value.EXPO - ONESIGNAL -> Value.ONESIGNAL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws CourierInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - FIREBASE_FCM -> Known.FIREBASE_FCM - APN -> Known.APN - EXPO -> Known.EXPO - ONESIGNAL -> Known.ONESIGNAL - else -> throw CourierInvalidDataException("Unknown ProviderKey: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws CourierInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): ProviderKey = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ProviderKey && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Information about the device the token is associated with. */ - class Device - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adId: JsonField, - private val appId: JsonField, - private val deviceId: JsonField, - private val manufacturer: JsonField, - private val model: JsonField, - private val platform: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("ad_id") @ExcludeMissing adId: JsonField = JsonMissing.of(), - @JsonProperty("app_id") @ExcludeMissing appId: JsonField = JsonMissing.of(), - @JsonProperty("device_id") - @ExcludeMissing - deviceId: JsonField = JsonMissing.of(), - @JsonProperty("manufacturer") - @ExcludeMissing - manufacturer: JsonField = JsonMissing.of(), - @JsonProperty("model") @ExcludeMissing model: JsonField = JsonMissing.of(), - @JsonProperty("platform") @ExcludeMissing platform: JsonField = JsonMissing.of(), - ) : this(adId, appId, deviceId, manufacturer, model, platform, mutableMapOf()) - - /** - * Id of the advertising identifier - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun adId(): Optional = adId.getOptional("ad_id") - - /** - * Id of the application the token is used for - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun appId(): Optional = appId.getOptional("app_id") - - /** - * Id of the device the token is associated with - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun deviceId(): Optional = deviceId.getOptional("device_id") - - /** - * The device manufacturer - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun manufacturer(): Optional = manufacturer.getOptional("manufacturer") - - /** - * The device model - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun model(): Optional = model.getOptional("model") - - /** - * The device platform i.e. android, ios, web - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun platform(): Optional = platform.getOptional("platform") - - /** - * Returns the raw JSON value of [adId]. - * - * Unlike [adId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ad_id") @ExcludeMissing fun _adId(): JsonField = adId - - /** - * Returns the raw JSON value of [appId]. - * - * Unlike [appId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("app_id") @ExcludeMissing fun _appId(): JsonField = appId - - /** - * Returns the raw JSON value of [deviceId]. - * - * Unlike [deviceId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("device_id") @ExcludeMissing fun _deviceId(): JsonField = deviceId - - /** - * Returns the raw JSON value of [manufacturer]. - * - * Unlike [manufacturer], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("manufacturer") - @ExcludeMissing - fun _manufacturer(): JsonField = manufacturer - - /** - * Returns the raw JSON value of [model]. - * - * Unlike [model], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - - /** - * Returns the raw JSON value of [platform]. - * - * Unlike [platform], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("platform") @ExcludeMissing fun _platform(): JsonField = platform - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Device]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Device]. */ - class Builder internal constructor() { - - private var adId: JsonField = JsonMissing.of() - private var appId: JsonField = JsonMissing.of() - private var deviceId: JsonField = JsonMissing.of() - private var manufacturer: JsonField = JsonMissing.of() - private var model: JsonField = JsonMissing.of() - private var platform: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(device: Device) = apply { - adId = device.adId - appId = device.appId - deviceId = device.deviceId - manufacturer = device.manufacturer - model = device.model - platform = device.platform - additionalProperties = device.additionalProperties.toMutableMap() - } - - /** Id of the advertising identifier */ - fun adId(adId: String?) = adId(JsonField.ofNullable(adId)) - - /** Alias for calling [Builder.adId] with `adId.orElse(null)`. */ - fun adId(adId: Optional) = adId(adId.getOrNull()) - - /** - * Sets [Builder.adId] to an arbitrary JSON value. - * - * You should usually call [Builder.adId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun adId(adId: JsonField) = apply { this.adId = adId } - - /** Id of the application the token is used for */ - fun appId(appId: String?) = appId(JsonField.ofNullable(appId)) - - /** Alias for calling [Builder.appId] with `appId.orElse(null)`. */ - fun appId(appId: Optional) = appId(appId.getOrNull()) - - /** - * Sets [Builder.appId] to an arbitrary JSON value. - * - * You should usually call [Builder.appId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun appId(appId: JsonField) = apply { this.appId = appId } - - /** Id of the device the token is associated with */ - fun deviceId(deviceId: String?) = deviceId(JsonField.ofNullable(deviceId)) - - /** Alias for calling [Builder.deviceId] with `deviceId.orElse(null)`. */ - fun deviceId(deviceId: Optional) = deviceId(deviceId.getOrNull()) - - /** - * Sets [Builder.deviceId] to an arbitrary JSON value. - * - * You should usually call [Builder.deviceId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun deviceId(deviceId: JsonField) = apply { this.deviceId = deviceId } - - /** The device manufacturer */ - fun manufacturer(manufacturer: String?) = - manufacturer(JsonField.ofNullable(manufacturer)) - - /** Alias for calling [Builder.manufacturer] with `manufacturer.orElse(null)`. */ - fun manufacturer(manufacturer: Optional) = - manufacturer(manufacturer.getOrNull()) - - /** - * Sets [Builder.manufacturer] to an arbitrary JSON value. - * - * You should usually call [Builder.manufacturer] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun manufacturer(manufacturer: JsonField) = apply { - this.manufacturer = manufacturer - } - - /** The device model */ - fun model(model: String?) = model(JsonField.ofNullable(model)) - - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) - - /** - * Sets [Builder.model] to an arbitrary JSON value. - * - * You should usually call [Builder.model] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun model(model: JsonField) = apply { this.model = model } - - /** The device platform i.e. android, ios, web */ - fun platform(platform: String?) = platform(JsonField.ofNullable(platform)) - - /** Alias for calling [Builder.platform] with `platform.orElse(null)`. */ - fun platform(platform: Optional) = platform(platform.getOrNull()) - - /** - * Sets [Builder.platform] to an arbitrary JSON value. - * - * You should usually call [Builder.platform] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun platform(platform: JsonField) = apply { this.platform = platform } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Device]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Device = - Device( - adId, - appId, - deviceId, - manufacturer, - model, - platform, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Device = apply { - if (validated) { - return@apply - } - - adId() - appId() - deviceId() - manufacturer() - model() - platform() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (adId.asKnown().isPresent) 1 else 0) + - (if (appId.asKnown().isPresent) 1 else 0) + - (if (deviceId.asKnown().isPresent) 1 else 0) + - (if (manufacturer.asKnown().isPresent) 1 else 0) + - (if (model.asKnown().isPresent) 1 else 0) + - (if (platform.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Device && - adId == other.adId && - appId == other.appId && - deviceId == other.deviceId && - manufacturer == other.manufacturer && - model == other.model && - platform == other.platform && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(adId, appId, deviceId, manufacturer, model, platform, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Device{adId=$adId, appId=$appId, deviceId=$deviceId, manufacturer=$manufacturer, model=$model, platform=$platform, additionalProperties=$additionalProperties}" - } - - /** - * ISO 8601 formatted date the token expires. Defaults to 2 months. Set to false to disable - * expiration. - */ - @JsonDeserialize(using = ExpiryDate.Deserializer::class) - @JsonSerialize(using = ExpiryDate.Serializer::class) - class ExpiryDate - private constructor( - private val string: String? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun bool(): Optional = Optional.ofNullable(bool) - - fun isString(): Boolean = string != null - - fun isBool(): Boolean = bool != null - - fun asString(): String = string.getOrThrow("string") - - fun asBool(): Boolean = bool.getOrThrow("bool") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): ExpiryDate = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitString(string: String) {} - - override fun visitBool(bool: Boolean) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitBool(bool: Boolean) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ExpiryDate && string == other.string && bool == other.bool - } - - override fun hashCode(): Int = Objects.hash(string, bool) - - override fun toString(): String = - when { - string != null -> "ExpiryDate{string=$string}" - bool != null -> "ExpiryDate{bool=$bool}" - _json != null -> "ExpiryDate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid ExpiryDate") - } - - companion object { - - @JvmStatic fun ofString(string: String) = ExpiryDate(string = string) - - @JvmStatic fun ofBool(bool: Boolean) = ExpiryDate(bool = bool) - } - - /** - * An interface that defines how to map each variant of [ExpiryDate] to a value of type [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of [ExpiryDate] to a value of type [T]. - * - * An instance of [ExpiryDate] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. - * - * @throws CourierInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw CourierInvalidDataException("Unknown ExpiryDate: $json") - } - } - - internal class Deserializer : BaseDeserializer(ExpiryDate::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): ExpiryDate { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - ExpiryDate(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - ExpiryDate(bool = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). - 0 -> ExpiryDate(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(ExpiryDate::class) { - - override fun serialize( - value: ExpiryDate, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.bool != null -> generator.writeObject(value.bool) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid ExpiryDate") - } - } - } - } - - /** Information about the device the token is associated with. */ - class Tracking - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val ip: JsonField, - private val lat: JsonField, - private val long_: JsonField, - private val osVersion: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("ip") @ExcludeMissing ip: JsonField = JsonMissing.of(), - @JsonProperty("lat") @ExcludeMissing lat: JsonField = JsonMissing.of(), - @JsonProperty("long") @ExcludeMissing long_: JsonField = JsonMissing.of(), - @JsonProperty("os_version") - @ExcludeMissing - osVersion: JsonField = JsonMissing.of(), - ) : this(ip, lat, long_, osVersion, mutableMapOf()) - - /** - * The IP address of the device - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun ip(): Optional = ip.getOptional("ip") - - /** - * The latitude of the device - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun lat(): Optional = lat.getOptional("lat") - - /** - * The longitude of the device - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun long_(): Optional = long_.getOptional("long") - - /** - * The operating system version - * - * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun osVersion(): Optional = osVersion.getOptional("os_version") - - /** - * Returns the raw JSON value of [ip]. - * - * Unlike [ip], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("ip") @ExcludeMissing fun _ip(): JsonField = ip - - /** - * Returns the raw JSON value of [lat]. - * - * Unlike [lat], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("lat") @ExcludeMissing fun _lat(): JsonField = lat - - /** - * Returns the raw JSON value of [long_]. - * - * Unlike [long_], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("long") @ExcludeMissing fun _long_(): JsonField = long_ - - /** - * Returns the raw JSON value of [osVersion]. - * - * Unlike [osVersion], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("os_version") @ExcludeMissing fun _osVersion(): JsonField = osVersion - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Tracking]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tracking]. */ - class Builder internal constructor() { - - private var ip: JsonField = JsonMissing.of() - private var lat: JsonField = JsonMissing.of() - private var long_: JsonField = JsonMissing.of() - private var osVersion: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tracking: Tracking) = apply { - ip = tracking.ip - lat = tracking.lat - long_ = tracking.long_ - osVersion = tracking.osVersion - additionalProperties = tracking.additionalProperties.toMutableMap() - } - - /** The IP address of the device */ - fun ip(ip: String?) = ip(JsonField.ofNullable(ip)) - - /** Alias for calling [Builder.ip] with `ip.orElse(null)`. */ - fun ip(ip: Optional) = ip(ip.getOrNull()) - - /** - * Sets [Builder.ip] to an arbitrary JSON value. - * - * You should usually call [Builder.ip] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun ip(ip: JsonField) = apply { this.ip = ip } - - /** The latitude of the device */ - fun lat(lat: String?) = lat(JsonField.ofNullable(lat)) - - /** Alias for calling [Builder.lat] with `lat.orElse(null)`. */ - fun lat(lat: Optional) = lat(lat.getOrNull()) - - /** - * Sets [Builder.lat] to an arbitrary JSON value. - * - * You should usually call [Builder.lat] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun lat(lat: JsonField) = apply { this.lat = lat } - - /** The longitude of the device */ - fun long_(long_: String?) = long_(JsonField.ofNullable(long_)) - - /** Alias for calling [Builder.long_] with `long_.orElse(null)`. */ - fun long_(long_: Optional) = long_(long_.getOrNull()) - - /** - * Sets [Builder.long_] to an arbitrary JSON value. - * - * You should usually call [Builder.long_] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun long_(long_: JsonField) = apply { this.long_ = long_ } - - /** The operating system version */ - fun osVersion(osVersion: String?) = osVersion(JsonField.ofNullable(osVersion)) - - /** Alias for calling [Builder.osVersion] with `osVersion.orElse(null)`. */ - fun osVersion(osVersion: Optional) = osVersion(osVersion.getOrNull()) - - /** - * Sets [Builder.osVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.osVersion] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun osVersion(osVersion: JsonField) = apply { this.osVersion = osVersion } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tracking]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Tracking = - Tracking(ip, lat, long_, osVersion, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Tracking = apply { - if (validated) { - return@apply - } - - ip() - lat() - long_() - osVersion() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (ip.asKnown().isPresent) 1 else 0) + - (if (lat.asKnown().isPresent) 1 else 0) + - (if (long_.asKnown().isPresent) 1 else 0) + - (if (osVersion.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Tracking && - ip == other.ip && - lat == other.lat && - long_ == other.long_ && - osVersion == other.osVersion && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(ip, lat, long_, osVersion, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tracking{ip=$ip, lat=$lat, long_=$long_, osVersion=$osVersion, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is UserToken && - providerKey == other.providerKey && - token == other.token && - device == other.device && - expiryDate == other.expiryDate && - properties == other.properties && - tracking == other.tracking && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - providerKey, - token, - device, - expiryDate, - properties, - tracking, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UserToken{providerKey=$providerKey, token=$token, device=$device, expiryDate=$expiryDate, properties=$properties, tracking=$tracking, additionalProperties=$additionalProperties}" -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt deleted file mode 100644 index ab8ad68e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsync.kt +++ /dev/null @@ -1,389 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.audiences.Audience -import com.courier.api.models.audiences.AudienceDeleteParams -import com.courier.api.models.audiences.AudienceListMembersParams -import com.courier.api.models.audiences.AudienceListMembersResponse -import com.courier.api.models.audiences.AudienceListParams -import com.courier.api.models.audiences.AudienceListResponse -import com.courier.api.models.audiences.AudienceRetrieveParams -import com.courier.api.models.audiences.AudienceUpdateParams -import com.courier.api.models.audiences.AudienceUpdateResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface AudienceServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AudienceServiceAsync - - /** Returns the specified audience by id. */ - fun retrieve(audienceId: String): CompletableFuture = - retrieve(audienceId, AudienceRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - ): CompletableFuture = retrieve(audienceId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: AudienceRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(audienceId: String, requestOptions: RequestOptions): CompletableFuture = - retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) - - /** Creates or updates audience. */ - fun update(audienceId: String): CompletableFuture = - update(audienceId, AudienceUpdateParams.none()) - - /** @see update */ - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see update */ - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - ): CompletableFuture = update(audienceId, params, RequestOptions.none()) - - /** @see update */ - fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see update */ - fun update(params: AudienceUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - audienceId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - update(audienceId, AudienceUpdateParams.none(), requestOptions) - - /** Get the audiences associated with the authorization token. */ - fun list(): CompletableFuture = list(AudienceListParams.none()) - - /** @see list */ - fun list( - params: AudienceListParams = AudienceListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: AudienceListParams = AudienceListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(AudienceListParams.none(), requestOptions) - - /** Deletes the specified audience. */ - fun delete(audienceId: String): CompletableFuture = - delete(audienceId, AudienceDeleteParams.none()) - - /** @see delete */ - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see delete */ - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - ): CompletableFuture = delete(audienceId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: AudienceDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: AudienceDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(audienceId: String, requestOptions: RequestOptions): CompletableFuture = - delete(audienceId, AudienceDeleteParams.none(), requestOptions) - - /** Get list of members of an audience. */ - fun listMembers(audienceId: String): CompletableFuture = - listMembers(audienceId, AudienceListMembersParams.none()) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - ): CompletableFuture = - listMembers(audienceId, params, RequestOptions.none()) - - /** @see listMembers */ - fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see listMembers */ - fun listMembers( - params: AudienceListMembersParams - ): CompletableFuture = listMembers(params, RequestOptions.none()) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) - - /** - * A view of [AudienceServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): AudienceServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /audiences/{audience_id}`, but is otherwise the same - * as [AudienceServiceAsync.retrieve]. - */ - fun retrieve(audienceId: String): CompletableFuture> = - retrieve(audienceId, AudienceRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - ): CompletableFuture> = - retrieve(audienceId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve(params: AudienceRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /audiences/{audience_id}`, but is otherwise the same - * as [AudienceServiceAsync.update]. - */ - fun update(audienceId: String): CompletableFuture> = - update(audienceId, AudienceUpdateParams.none()) - - /** @see update */ - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see update */ - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - ): CompletableFuture> = - update(audienceId, params, RequestOptions.none()) - - /** @see update */ - fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see update */ - fun update( - params: AudienceUpdateParams - ): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - audienceId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - update(audienceId, AudienceUpdateParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /audiences`, but is otherwise the same as - * [AudienceServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(AudienceListParams.none()) - - /** @see list */ - fun list( - params: AudienceListParams = AudienceListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: AudienceListParams = AudienceListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(AudienceListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /audiences/{audience_id}`, but is otherwise the - * same as [AudienceServiceAsync.delete]. - */ - fun delete(audienceId: String): CompletableFuture = - delete(audienceId, AudienceDeleteParams.none()) - - /** @see delete */ - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see delete */ - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - ): CompletableFuture = delete(audienceId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: AudienceDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: AudienceDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - audienceId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - delete(audienceId, AudienceDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /audiences/{audience_id}/members`, but is otherwise - * the same as [AudienceServiceAsync.listMembers]. - */ - fun listMembers( - audienceId: String - ): CompletableFuture> = - listMembers(audienceId, AudienceListMembersParams.none()) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - ): CompletableFuture> = - listMembers(audienceId, params, RequestOptions.none()) - - /** @see listMembers */ - fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see listMembers */ - fun listMembers( - params: AudienceListMembersParams - ): CompletableFuture> = - listMembers(params, RequestOptions.none()) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt deleted file mode 100644 index 985db169..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AudienceServiceAsyncImpl.kt +++ /dev/null @@ -1,250 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.audiences.Audience -import com.courier.api.models.audiences.AudienceDeleteParams -import com.courier.api.models.audiences.AudienceListMembersParams -import com.courier.api.models.audiences.AudienceListMembersResponse -import com.courier.api.models.audiences.AudienceListParams -import com.courier.api.models.audiences.AudienceListResponse -import com.courier.api.models.audiences.AudienceRetrieveParams -import com.courier.api.models.audiences.AudienceUpdateParams -import com.courier.api.models.audiences.AudienceUpdateResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class AudienceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AudienceServiceAsync { - - private val withRawResponse: AudienceServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): AudienceServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AudienceServiceAsync = - AudienceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /audiences/{audience_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /audiences/{audience_id} - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: AudienceListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /audiences - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: AudienceDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /audiences/{audience_id} - withRawResponse().delete(params, requestOptions).thenAccept {} - - override fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /audiences/{audience_id}/members - withRawResponse().listMembers(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AudienceServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): AudienceServiceAsync.WithRawResponse = - AudienceServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: AudienceListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: AudienceDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - - private val listMembersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0), "members") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listMembersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt deleted file mode 100644 index 769cd892..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsync.kt +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.auditevents.AuditEvent -import com.courier.api.models.auditevents.AuditEventListParams -import com.courier.api.models.auditevents.AuditEventListResponse -import com.courier.api.models.auditevents.AuditEventRetrieveParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface AuditEventServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AuditEventServiceAsync - - /** Fetch a specific audit event by ID. */ - fun retrieve(auditEventId: String): CompletableFuture = - retrieve(auditEventId, AuditEventRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - ): CompletableFuture = retrieve(auditEventId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: AuditEventRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) - - /** Fetch the list of audit events */ - fun list(): CompletableFuture = list(AuditEventListParams.none()) - - /** @see list */ - fun list( - params: AuditEventListParams = AuditEventListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: AuditEventListParams = AuditEventListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(AuditEventListParams.none(), requestOptions) - - /** - * A view of [AuditEventServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): AuditEventServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /audit-events/{audit-event-id}`, but is otherwise - * the same as [AuditEventServiceAsync.retrieve]. - */ - fun retrieve(auditEventId: String): CompletableFuture> = - retrieve(auditEventId, AuditEventRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - ): CompletableFuture> = - retrieve(auditEventId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: AuditEventRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /audit-events`, but is otherwise the same as - * [AuditEventServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(AuditEventListParams.none()) - - /** @see list */ - fun list( - params: AuditEventListParams = AuditEventListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: AuditEventListParams = AuditEventListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(AuditEventListParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt deleted file mode 100644 index c4e3c20f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuditEventServiceAsyncImpl.kt +++ /dev/null @@ -1,128 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.auditevents.AuditEvent -import com.courier.api.models.auditevents.AuditEventListParams -import com.courier.api.models.auditevents.AuditEventListResponse -import com.courier.api.models.auditevents.AuditEventRetrieveParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class AuditEventServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AuditEventServiceAsync { - - private val withRawResponse: AuditEventServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): AuditEventServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AuditEventServiceAsync = - AuditEventServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /audit-events/{audit-event-id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: AuditEventListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /audit-events - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AuditEventServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): AuditEventServiceAsync.WithRawResponse = - AuditEventServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("auditEventId", params.auditEventId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audit-events", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: AuditEventListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audit-events") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt deleted file mode 100644 index 1f1cd65f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsync.kt +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.auth.AuthIssueTokenParams -import com.courier.api.models.auth.AuthIssueTokenResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface AuthServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AuthServiceAsync - - /** Returns a new access token. */ - fun issueToken(params: AuthIssueTokenParams): CompletableFuture = - issueToken(params, RequestOptions.none()) - - /** @see issueToken */ - fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [AuthServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AuthServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /auth/issue-token`, but is otherwise the same as - * [AuthServiceAsync.issueToken]. - */ - fun issueToken( - params: AuthIssueTokenParams - ): CompletableFuture> = - issueToken(params, RequestOptions.none()) - - /** @see issueToken */ - fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt deleted file mode 100644 index 25242e48..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AuthServiceAsyncImpl.kt +++ /dev/null @@ -1,86 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.auth.AuthIssueTokenParams -import com.courier.api.models.auth.AuthIssueTokenResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -class AuthServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AuthServiceAsync { - - private val withRawResponse: AuthServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): AuthServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AuthServiceAsync = - AuthServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /auth/issue-token - withRawResponse().issueToken(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AuthServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): AuthServiceAsync.WithRawResponse = - AuthServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val issueTokenHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("auth", "issue-token") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { issueTokenHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt deleted file mode 100644 index 8652504a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsync.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.services.async.automations.InvokeServiceAsync -import java.util.function.Consumer - -interface AutomationServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AutomationServiceAsync - - fun invoke(): InvokeServiceAsync - - /** - * A view of [AutomationServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): AutomationServiceAsync.WithRawResponse - - fun invoke(): InvokeServiceAsync.WithRawResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt deleted file mode 100644 index 1c512834..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/AutomationServiceAsyncImpl.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.services.async.automations.InvokeServiceAsync -import com.courier.api.services.async.automations.InvokeServiceAsyncImpl -import java.util.function.Consumer - -class AutomationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - AutomationServiceAsync { - - private val withRawResponse: AutomationServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val invoke: InvokeServiceAsync by lazy { InvokeServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): AutomationServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AutomationServiceAsync = - AutomationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun invoke(): InvokeServiceAsync = invoke - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AutomationServiceAsync.WithRawResponse { - - private val invoke: InvokeServiceAsync.WithRawResponse by lazy { - InvokeServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): AutomationServiceAsync.WithRawResponse = - AutomationServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun invoke(): InvokeServiceAsync.WithRawResponse = invoke - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt deleted file mode 100644 index ad4c399f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsync.kt +++ /dev/null @@ -1,302 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.brands.Brand -import com.courier.api.models.brands.BrandCreateParams -import com.courier.api.models.brands.BrandDeleteParams -import com.courier.api.models.brands.BrandListParams -import com.courier.api.models.brands.BrandListResponse -import com.courier.api.models.brands.BrandRetrieveParams -import com.courier.api.models.brands.BrandUpdateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BrandServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BrandServiceAsync - - /** Create a new brand */ - fun create(params: BrandCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BrandCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Fetch a specific brand by brand ID. */ - fun retrieve(brandId: String): CompletableFuture = - retrieve(brandId, BrandRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - ): CompletableFuture = retrieve(brandId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: BrandRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(brandId: String, requestOptions: RequestOptions): CompletableFuture = - retrieve(brandId, BrandRetrieveParams.none(), requestOptions) - - /** Replace an existing brand with the supplied values. */ - fun update(brandId: String, params: BrandUpdateParams): CompletableFuture = - update(brandId, params, RequestOptions.none()) - - /** @see update */ - fun update( - brandId: String, - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see update */ - fun update(params: BrandUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Get the list of brands. */ - fun list(): CompletableFuture = list(BrandListParams.none()) - - /** @see list */ - fun list( - params: BrandListParams = BrandListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: BrandListParams = BrandListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(BrandListParams.none(), requestOptions) - - /** Delete a brand by brand ID. */ - fun delete(brandId: String): CompletableFuture = - delete(brandId, BrandDeleteParams.none()) - - /** @see delete */ - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see delete */ - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - ): CompletableFuture = delete(brandId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: BrandDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: BrandDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(brandId: String, requestOptions: RequestOptions): CompletableFuture = - delete(brandId, BrandDeleteParams.none(), requestOptions) - - /** A view of [BrandServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): BrandServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /brands`, but is otherwise the same as - * [BrandServiceAsync.create]. - */ - fun create(params: BrandCreateParams): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BrandCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /brands/{brand_id}`, but is otherwise the same as - * [BrandServiceAsync.retrieve]. - */ - fun retrieve(brandId: String): CompletableFuture> = - retrieve(brandId, BrandRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - ): CompletableFuture> = - retrieve(brandId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve(params: BrandRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - brandId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(brandId, BrandRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /brands/{brand_id}`, but is otherwise the same as - * [BrandServiceAsync.update]. - */ - fun update( - brandId: String, - params: BrandUpdateParams, - ): CompletableFuture> = - update(brandId, params, RequestOptions.none()) - - /** @see update */ - fun update( - brandId: String, - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see update */ - fun update(params: BrandUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /brands`, but is otherwise the same as - * [BrandServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(BrandListParams.none()) - - /** @see list */ - fun list( - params: BrandListParams = BrandListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: BrandListParams = BrandListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(BrandListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /brands/{brand_id}`, but is otherwise the same as - * [BrandServiceAsync.delete]. - */ - fun delete(brandId: String): CompletableFuture = - delete(brandId, BrandDeleteParams.none()) - - /** @see delete */ - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see delete */ - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - ): CompletableFuture = delete(brandId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: BrandDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: BrandDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - brandId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - delete(brandId, BrandDeleteParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt deleted file mode 100644 index 661c84d4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BrandServiceAsyncImpl.kt +++ /dev/null @@ -1,243 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.brands.Brand -import com.courier.api.models.brands.BrandCreateParams -import com.courier.api.models.brands.BrandDeleteParams -import com.courier.api.models.brands.BrandListParams -import com.courier.api.models.brands.BrandListResponse -import com.courier.api.models.brands.BrandRetrieveParams -import com.courier.api.models.brands.BrandUpdateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BrandServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BrandServiceAsync { - - private val withRawResponse: BrandServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BrandServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BrandServiceAsync = - BrandServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun create( - params: BrandCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /brands - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /brands/{brand_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /brands/{brand_id} - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: BrandListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /brands - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: BrandDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /brands/{brand_id} - withRawResponse().delete(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BrandServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BrandServiceAsync.WithRawResponse = - BrandServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: BrandCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("brandId", params.brandId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("brandId", params.brandId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: BrandListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: BrandDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("brandId", params.brandId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt deleted file mode 100644 index 76a45a18..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsync.kt +++ /dev/null @@ -1,335 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.bulk.BulkAddUsersParams -import com.courier.api.models.bulk.BulkCreateJobParams -import com.courier.api.models.bulk.BulkCreateJobResponse -import com.courier.api.models.bulk.BulkListUsersParams -import com.courier.api.models.bulk.BulkListUsersResponse -import com.courier.api.models.bulk.BulkRetrieveJobParams -import com.courier.api.models.bulk.BulkRetrieveJobResponse -import com.courier.api.models.bulk.BulkRunJobParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BulkServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkServiceAsync - - /** Ingest user data into a Bulk Job */ - fun addUsers(jobId: String, params: BulkAddUsersParams): CompletableFuture = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams): CompletableFuture = - addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Create a bulk job */ - fun createJob(params: BulkCreateJobParams): CompletableFuture = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Get Bulk Job Users */ - fun listUsers(jobId: String): CompletableFuture = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): CompletableFuture = listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see listUsers */ - fun listUsers(params: BulkListUsersParams): CompletableFuture = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** Get a bulk job */ - fun retrieveJob(jobId: String): CompletableFuture = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): CompletableFuture = - retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieveJob */ - fun retrieveJob(params: BulkRetrieveJobParams): CompletableFuture = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** Run a bulk job */ - fun runJob(jobId: String): CompletableFuture = runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - ): CompletableFuture = runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see runJob */ - fun runJob(params: BulkRunJobParams): CompletableFuture = - runJob(params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(jobId: String, requestOptions: RequestOptions): CompletableFuture = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - - /** A view of [BulkServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}`, but is otherwise the same as - * [BulkServiceAsync.addUsers]. - */ - fun addUsers(jobId: String, params: BulkAddUsersParams): CompletableFuture = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams): CompletableFuture = - addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `post /bulk`, but is otherwise the same as - * [BulkServiceAsync.createJob]. - */ - fun createJob( - params: BulkCreateJobParams - ): CompletableFuture> = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}/users`, but is otherwise the same as - * [BulkServiceAsync.listUsers]. - */ - fun listUsers(jobId: String): CompletableFuture> = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): CompletableFuture> = - listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams - ): CompletableFuture> = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}`, but is otherwise the same as - * [BulkServiceAsync.retrieveJob]. - */ - fun retrieveJob( - jobId: String - ): CompletableFuture> = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): CompletableFuture> = - retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams - ): CompletableFuture> = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}/run`, but is otherwise the same as - * [BulkServiceAsync.runJob]. - */ - fun runJob(jobId: String): CompletableFuture = - runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - ): CompletableFuture = runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see runJob */ - fun runJob(params: BulkRunJobParams): CompletableFuture = - runJob(params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(jobId: String, requestOptions: RequestOptions): CompletableFuture = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt deleted file mode 100644 index 2dc2defd..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/BulkServiceAsyncImpl.kt +++ /dev/null @@ -1,243 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.bulk.BulkAddUsersParams -import com.courier.api.models.bulk.BulkCreateJobParams -import com.courier.api.models.bulk.BulkCreateJobResponse -import com.courier.api.models.bulk.BulkListUsersParams -import com.courier.api.models.bulk.BulkListUsersResponse -import com.courier.api.models.bulk.BulkRetrieveJobParams -import com.courier.api.models.bulk.BulkRetrieveJobResponse -import com.courier.api.models.bulk.BulkRunJobParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BulkServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BulkServiceAsync { - - private val withRawResponse: BulkServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BulkServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BulkServiceAsync = - BulkServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /bulk/{job_id} - withRawResponse().addUsers(params, requestOptions).thenAccept {} - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /bulk - withRawResponse().createJob(params, requestOptions).thenApply { it.parse() } - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /bulk/{job_id}/users - withRawResponse().listUsers(params, requestOptions).thenApply { it.parse() } - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /bulk/{job_id} - withRawResponse().retrieveJob(params, requestOptions).thenApply { it.parse() } - - override fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /bulk/{job_id}/run - withRawResponse().runJob(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BulkServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BulkServiceAsync.WithRawResponse = - BulkServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val addUsersHandler: Handler = emptyHandler() - - override fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { addUsersHandler.handle(it) } - } - } - } - - private val createJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listUsersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "users") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listUsersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val runJobHandler: Handler = emptyHandler() - - override fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "run") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { runJobHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt deleted file mode 100644 index 9f0c1299..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsync.kt +++ /dev/null @@ -1,66 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.inbound.InboundTrackEventParams -import com.courier.api.models.inbound.InboundTrackEventResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface InboundServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): InboundServiceAsync - - /** Courier Track Event */ - fun trackEvent(params: InboundTrackEventParams): CompletableFuture = - trackEvent(params, RequestOptions.none()) - - /** @see trackEvent */ - fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [InboundServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): InboundServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /inbound/courier`, but is otherwise the same as - * [InboundServiceAsync.trackEvent]. - */ - fun trackEvent( - params: InboundTrackEventParams - ): CompletableFuture> = - trackEvent(params, RequestOptions.none()) - - /** @see trackEvent */ - fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt deleted file mode 100644 index 7bc0b1c6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/InboundServiceAsyncImpl.kt +++ /dev/null @@ -1,86 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.inbound.InboundTrackEventParams -import com.courier.api.models.inbound.InboundTrackEventResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -class InboundServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - InboundServiceAsync { - - private val withRawResponse: InboundServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): InboundServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): InboundServiceAsync = - InboundServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /inbound/courier - withRawResponse().trackEvent(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - InboundServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): InboundServiceAsync.WithRawResponse = - InboundServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val trackEventHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("inbound", "courier") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { trackEventHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt deleted file mode 100644 index ecf11b2e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsync.kt +++ /dev/null @@ -1,319 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.lists.List -import com.courier.api.models.lists.ListDeleteParams -import com.courier.api.models.lists.ListListParams -import com.courier.api.models.lists.ListListResponse -import com.courier.api.models.lists.ListRestoreParams -import com.courier.api.models.lists.ListRetrieveParams -import com.courier.api.models.lists.ListUpdateParams -import com.courier.api.services.async.lists.SubscriptionServiceAsync -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface ListServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListServiceAsync - - fun subscriptions(): SubscriptionServiceAsync - - /** Returns a list based on the list ID provided. */ - fun retrieve(listId: String): CompletableFuture = - retrieve(listId, ListRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = retrieve(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): CompletableFuture = retrieve(listId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: ListRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(listId: String, requestOptions: RequestOptions): CompletableFuture = - retrieve(listId, ListRetrieveParams.none(), requestOptions) - - /** Create or replace an existing list with the supplied values. */ - fun update(listId: String, params: ListUpdateParams): CompletableFuture = - update(listId, params, RequestOptions.none()) - - /** @see update */ - fun update( - listId: String, - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see update */ - fun update(params: ListUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Returns all of the lists, with the ability to filter based on a pattern. */ - fun list(): CompletableFuture = list(ListListParams.none()) - - /** @see list */ - fun list( - params: ListListParams = ListListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list(params: ListListParams = ListListParams.none()): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(ListListParams.none(), requestOptions) - - /** Delete a list by list ID. */ - fun delete(listId: String): CompletableFuture = delete(listId, ListDeleteParams.none()) - - /** @see delete */ - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = delete(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see delete */ - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): CompletableFuture = delete(listId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: ListDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(listId: String, requestOptions: RequestOptions): CompletableFuture = - delete(listId, ListDeleteParams.none(), requestOptions) - - /** Restore a previously deleted list. */ - fun restore(listId: String, params: ListRestoreParams): CompletableFuture = - restore(listId, params, RequestOptions.none()) - - /** @see restore */ - fun restore( - listId: String, - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = restore(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see restore */ - fun restore(params: ListRestoreParams): CompletableFuture = - restore(params, RequestOptions.none()) - - /** @see restore */ - fun restore( - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [ListServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListServiceAsync.WithRawResponse - - fun subscriptions(): SubscriptionServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /lists/{list_id}`, but is otherwise the same as - * [ListServiceAsync.retrieve]. - */ - fun retrieve(listId: String): CompletableFuture> = - retrieve(listId, ListRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): CompletableFuture> = - retrieve(listId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve(params: ListRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - listId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(listId, ListRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /lists/{list_id}`, but is otherwise the same as - * [ListServiceAsync.update]. - */ - fun update(listId: String, params: ListUpdateParams): CompletableFuture = - update(listId, params, RequestOptions.none()) - - /** @see update */ - fun update( - listId: String, - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see update */ - fun update(params: ListUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `get /lists`, but is otherwise the same as - * [ListServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(ListListParams.none()) - - /** @see list */ - fun list( - params: ListListParams = ListListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: ListListParams = ListListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(ListListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /lists/{list_id}`, but is otherwise the same as - * [ListServiceAsync.delete]. - */ - fun delete(listId: String): CompletableFuture = - delete(listId, ListDeleteParams.none()) - - /** @see delete */ - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see delete */ - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): CompletableFuture = delete(listId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: ListDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - listId: String, - requestOptions: RequestOptions, - ): CompletableFuture = delete(listId, ListDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /lists/{list_id}/restore`, but is otherwise the same - * as [ListServiceAsync.restore]. - */ - fun restore(listId: String, params: ListRestoreParams): CompletableFuture = - restore(listId, params, RequestOptions.none()) - - /** @see restore */ - fun restore( - listId: String, - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - restore(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see restore */ - fun restore(params: ListRestoreParams): CompletableFuture = - restore(params, RequestOptions.none()) - - /** @see restore */ - fun restore( - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt deleted file mode 100644 index 5dc5052d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ListServiceAsyncImpl.kt +++ /dev/null @@ -1,248 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.lists.List -import com.courier.api.models.lists.ListDeleteParams -import com.courier.api.models.lists.ListListParams -import com.courier.api.models.lists.ListListResponse -import com.courier.api.models.lists.ListRestoreParams -import com.courier.api.models.lists.ListRetrieveParams -import com.courier.api.models.lists.ListUpdateParams -import com.courier.api.services.async.lists.SubscriptionServiceAsync -import com.courier.api.services.async.lists.SubscriptionServiceAsyncImpl -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ListServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ListServiceAsync { - - private val withRawResponse: ListServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val subscriptions: SubscriptionServiceAsync by lazy { - SubscriptionServiceAsyncImpl(clientOptions) - } - - override fun withRawResponse(): ListServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ListServiceAsync = - ListServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun subscriptions(): SubscriptionServiceAsync = subscriptions - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /lists/{list_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: ListUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /lists/{list_id} - withRawResponse().update(params, requestOptions).thenAccept {} - - override fun list( - params: ListListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /lists - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /lists/{list_id} - withRawResponse().delete(params, requestOptions).thenAccept {} - - override fun restore( - params: ListRestoreParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /lists/{list_id}/restore - withRawResponse().restore(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ListServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val subscriptions: SubscriptionServiceAsync.WithRawResponse by lazy { - SubscriptionServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): ListServiceAsync.WithRawResponse = - ListServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun subscriptions(): SubscriptionServiceAsync.WithRawResponse = subscriptions - - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: ListUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: ListListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - - private val restoreHandler: Handler = emptyHandler() - - override fun restore( - params: ListRestoreParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "restore") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { restoreHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt deleted file mode 100644 index 85e62f76..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsync.kt +++ /dev/null @@ -1,404 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.messages.MessageCancelParams -import com.courier.api.models.messages.MessageContentParams -import com.courier.api.models.messages.MessageContentResponse -import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageHistoryParams -import com.courier.api.models.messages.MessageHistoryResponse -import com.courier.api.models.messages.MessageListParams -import com.courier.api.models.messages.MessageListResponse -import com.courier.api.models.messages.MessageRetrieveParams -import com.courier.api.models.messages.MessageRetrieveResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface MessageServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): MessageServiceAsync - - /** Fetch the status of a message you've previously sent. */ - fun retrieve(messageId: String): CompletableFuture = - retrieve(messageId, MessageRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - ): CompletableFuture = - retrieve(messageId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: MessageRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(messageId, MessageRetrieveParams.none(), requestOptions) - - /** Fetch the statuses of messages you've previously sent. */ - fun list(): CompletableFuture = list(MessageListParams.none()) - - /** @see list */ - fun list( - params: MessageListParams = MessageListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: MessageListParams = MessageListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(MessageListParams.none(), requestOptions) - - /** - * Cancel a message that is currently in the process of being delivered. A well-formatted API - * call to the cancel message API will return either `200` status code for a successful - * cancellation or `409` status code for an unsuccessful cancellation. Both cases will include - * the actual message record in the response body (see details below). - */ - fun cancel(messageId: String): CompletableFuture = - cancel(messageId, MessageCancelParams.none()) - - /** @see cancel */ - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - cancel(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see cancel */ - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - ): CompletableFuture = cancel(messageId, params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see cancel */ - fun cancel(params: MessageCancelParams): CompletableFuture = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - cancel(messageId, MessageCancelParams.none(), requestOptions) - - /** Get message content */ - fun content(messageId: String): CompletableFuture = - content(messageId, MessageContentParams.none()) - - /** @see content */ - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - content(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see content */ - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - ): CompletableFuture = content(messageId, params, RequestOptions.none()) - - /** @see content */ - fun content( - params: MessageContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see content */ - fun content(params: MessageContentParams): CompletableFuture = - content(params, RequestOptions.none()) - - /** @see content */ - fun content( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - content(messageId, MessageContentParams.none(), requestOptions) - - /** Fetch the array of events of a message you've previously sent. */ - fun history(messageId: String): CompletableFuture = - history(messageId, MessageHistoryParams.none()) - - /** @see history */ - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - history(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see history */ - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - ): CompletableFuture = history(messageId, params, RequestOptions.none()) - - /** @see history */ - fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see history */ - fun history(params: MessageHistoryParams): CompletableFuture = - history(params, RequestOptions.none()) - - /** @see history */ - fun history( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - history(messageId, MessageHistoryParams.none(), requestOptions) - - /** - * A view of [MessageServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): MessageServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /messages/{message_id}`, but is otherwise the same - * as [MessageServiceAsync.retrieve]. - */ - fun retrieve( - messageId: String - ): CompletableFuture> = - retrieve(messageId, MessageRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - ): CompletableFuture> = - retrieve(messageId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: MessageRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(messageId, MessageRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /messages`, but is otherwise the same as - * [MessageServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(MessageListParams.none()) - - /** @see list */ - fun list( - params: MessageListParams = MessageListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: MessageListParams = MessageListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(MessageListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /messages/{message_id}/cancel`, but is otherwise - * the same as [MessageServiceAsync.cancel]. - */ - fun cancel(messageId: String): CompletableFuture> = - cancel(messageId, MessageCancelParams.none()) - - /** @see cancel */ - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - cancel(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see cancel */ - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - ): CompletableFuture> = - cancel(messageId, params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see cancel */ - fun cancel( - params: MessageCancelParams - ): CompletableFuture> = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - cancel(messageId, MessageCancelParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /messages/{message_id}/output`, but is otherwise the - * same as [MessageServiceAsync.content]. - */ - fun content(messageId: String): CompletableFuture> = - content(messageId, MessageContentParams.none()) - - /** @see content */ - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - content(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see content */ - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - ): CompletableFuture> = - content(messageId, params, RequestOptions.none()) - - /** @see content */ - fun content( - params: MessageContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see content */ - fun content( - params: MessageContentParams - ): CompletableFuture> = - content(params, RequestOptions.none()) - - /** @see content */ - fun content( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - content(messageId, MessageContentParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /messages/{message_id}/history`, but is otherwise - * the same as [MessageServiceAsync.history]. - */ - fun history(messageId: String): CompletableFuture> = - history(messageId, MessageHistoryParams.none()) - - /** @see history */ - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - history(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see history */ - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - ): CompletableFuture> = - history(messageId, params, RequestOptions.none()) - - /** @see history */ - fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see history */ - fun history( - params: MessageHistoryParams - ): CompletableFuture> = - history(params, RequestOptions.none()) - - /** @see history */ - fun history( - messageId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - history(messageId, MessageHistoryParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt deleted file mode 100644 index 6eb0b364..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/MessageServiceAsyncImpl.kt +++ /dev/null @@ -1,256 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.messages.MessageCancelParams -import com.courier.api.models.messages.MessageContentParams -import com.courier.api.models.messages.MessageContentResponse -import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageHistoryParams -import com.courier.api.models.messages.MessageHistoryResponse -import com.courier.api.models.messages.MessageListParams -import com.courier.api.models.messages.MessageListResponse -import com.courier.api.models.messages.MessageRetrieveParams -import com.courier.api.models.messages.MessageRetrieveResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class MessageServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - MessageServiceAsync { - - private val withRawResponse: MessageServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): MessageServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): MessageServiceAsync = - MessageServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /messages/{message_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: MessageListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /messages - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /messages/{message_id}/cancel - withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } - - override fun content( - params: MessageContentParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /messages/{message_id}/output - withRawResponse().content(params, requestOptions).thenApply { it.parse() } - - override fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /messages/{message_id}/history - withRawResponse().history(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MessageServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): MessageServiceAsync.WithRawResponse = - MessageServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: MessageListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0), "cancel") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { cancelHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val contentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun content( - params: MessageContentParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0), "output") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { contentHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val historyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0), "history") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { historyHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt deleted file mode 100644 index 91a3273e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsync.kt +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.NotificationListParams -import com.courier.api.models.notifications.NotificationListResponse -import com.courier.api.models.notifications.NotificationRetrieveContentParams -import com.courier.api.services.async.notifications.CheckServiceAsync -import com.courier.api.services.async.notifications.DraftServiceAsync -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface NotificationServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): NotificationServiceAsync - - fun draft(): DraftServiceAsync - - fun checks(): CheckServiceAsync - - fun list(): CompletableFuture = list(NotificationListParams.none()) - - /** @see list */ - fun list( - params: NotificationListParams = NotificationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: NotificationListParams = NotificationListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(NotificationListParams.none(), requestOptions) - - fun retrieveContent(id: String): CompletableFuture = - retrieveContent(id, NotificationRetrieveContentParams.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - ): CompletableFuture = - retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieveContent */ - fun retrieveContent( - params: NotificationRetrieveContentParams - ): CompletableFuture = retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) - - /** - * A view of [NotificationServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): NotificationServiceAsync.WithRawResponse - - fun draft(): DraftServiceAsync.WithRawResponse - - fun checks(): CheckServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /notifications`, but is otherwise the same as - * [NotificationServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(NotificationListParams.none()) - - /** @see list */ - fun list( - params: NotificationListParams = NotificationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: NotificationListParams = NotificationListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(NotificationListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /notifications/{id}/content`, but is otherwise the - * same as [NotificationServiceAsync.retrieveContent]. - */ - fun retrieveContent( - id: String - ): CompletableFuture> = - retrieveContent(id, NotificationRetrieveContentParams.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - ): CompletableFuture> = - retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieveContent */ - fun retrieveContent( - params: NotificationRetrieveContentParams - ): CompletableFuture> = - retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt deleted file mode 100644 index d35ef296..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/NotificationServiceAsyncImpl.kt +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.NotificationListParams -import com.courier.api.models.notifications.NotificationListResponse -import com.courier.api.models.notifications.NotificationRetrieveContentParams -import com.courier.api.services.async.notifications.CheckServiceAsync -import com.courier.api.services.async.notifications.CheckServiceAsyncImpl -import com.courier.api.services.async.notifications.DraftServiceAsync -import com.courier.api.services.async.notifications.DraftServiceAsyncImpl -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class NotificationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - NotificationServiceAsync { - - private val withRawResponse: NotificationServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val draft: DraftServiceAsync by lazy { DraftServiceAsyncImpl(clientOptions) } - - private val checks: CheckServiceAsync by lazy { CheckServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): NotificationServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): NotificationServiceAsync = - NotificationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun draft(): DraftServiceAsync = draft - - override fun checks(): CheckServiceAsync = checks - - override fun list( - params: NotificationListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /notifications - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /notifications/{id}/content - withRawResponse().retrieveContent(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - NotificationServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val draft: DraftServiceAsync.WithRawResponse by lazy { - DraftServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val checks: CheckServiceAsync.WithRawResponse by lazy { - CheckServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): NotificationServiceAsync.WithRawResponse = - NotificationServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun draft(): DraftServiceAsync.WithRawResponse = draft - - override fun checks(): CheckServiceAsync.WithRawResponse = checks - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: NotificationListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("notifications") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveContentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("id", params.id().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("notifications", params._pathParam(0), "content") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveContentHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt deleted file mode 100644 index 2eb46791..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsync.kt +++ /dev/null @@ -1,361 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.profiles.ProfileCreateParams -import com.courier.api.models.profiles.ProfileCreateResponse -import com.courier.api.models.profiles.ProfileDeleteParams -import com.courier.api.models.profiles.ProfileReplaceParams -import com.courier.api.models.profiles.ProfileReplaceResponse -import com.courier.api.models.profiles.ProfileRetrieveParams -import com.courier.api.models.profiles.ProfileRetrieveResponse -import com.courier.api.models.profiles.ProfileUpdateParams -import com.courier.api.services.async.profiles.ListServiceAsync -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface ProfileServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ProfileServiceAsync - - fun lists(): ListServiceAsync - - /** - * Merge the supplied values with an existing profile or create a new profile if one doesn't - * already exist. - */ - fun create( - userId: String, - params: ProfileCreateParams, - ): CompletableFuture = create(userId, params, RequestOptions.none()) - - /** @see create */ - fun create( - userId: String, - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - fun create(params: ProfileCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Returns the specified user profile. */ - fun retrieve(userId: String): CompletableFuture = - retrieve(userId, ProfileRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - ): CompletableFuture = retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: ProfileRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(userId, ProfileRetrieveParams.none(), requestOptions) - - /** Update a profile */ - fun update(userId: String, params: ProfileUpdateParams): CompletableFuture = - update(userId, params, RequestOptions.none()) - - /** @see update */ - fun update( - userId: String, - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see update */ - fun update(params: ProfileUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Deletes the specified user profile. */ - fun delete(userId: String): CompletableFuture = - delete(userId, ProfileDeleteParams.none()) - - /** @see delete */ - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - ): CompletableFuture = delete(userId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ProfileDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: ProfileDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(userId: String, requestOptions: RequestOptions): CompletableFuture = - delete(userId, ProfileDeleteParams.none(), requestOptions) - - /** - * When using `PUT`, be sure to include all the key-value pairs required by the recipient's - * profile. Any key-value pairs that exist in the profile but fail to be included in the `PUT` - * request will be removed from the profile. Remember, a `PUT` update is a full replacement of - * the data. For partial updates, use the - * [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. - */ - fun replace( - userId: String, - params: ProfileReplaceParams, - ): CompletableFuture = replace(userId, params, RequestOptions.none()) - - /** @see replace */ - fun replace( - userId: String, - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - replace(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see replace */ - fun replace(params: ProfileReplaceParams): CompletableFuture = - replace(params, RequestOptions.none()) - - /** @see replace */ - fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [ProfileServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): ProfileServiceAsync.WithRawResponse - - fun lists(): ListServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /profiles/{user_id}`, but is otherwise the same as - * [ProfileServiceAsync.create]. - */ - fun create( - userId: String, - params: ProfileCreateParams, - ): CompletableFuture> = - create(userId, params, RequestOptions.none()) - - /** @see create */ - fun create( - userId: String, - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - fun create( - params: ProfileCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /profiles/{user_id}`, but is otherwise the same as - * [ProfileServiceAsync.retrieve]. - */ - fun retrieve(userId: String): CompletableFuture> = - retrieve(userId, ProfileRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - ): CompletableFuture> = - retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: ProfileRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(userId, ProfileRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `patch /profiles/{user_id}`, but is otherwise the same as - * [ProfileServiceAsync.update]. - */ - fun update(userId: String, params: ProfileUpdateParams): CompletableFuture = - update(userId, params, RequestOptions.none()) - - /** @see update */ - fun update( - userId: String, - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see update */ - fun update(params: ProfileUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `delete /profiles/{user_id}`, but is otherwise the same - * as [ProfileServiceAsync.delete]. - */ - fun delete(userId: String): CompletableFuture = - delete(userId, ProfileDeleteParams.none()) - - /** @see delete */ - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - ): CompletableFuture = delete(userId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ProfileDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: ProfileDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - delete(userId, ProfileDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /profiles/{user_id}`, but is otherwise the same as - * [ProfileServiceAsync.replace]. - */ - fun replace( - userId: String, - params: ProfileReplaceParams, - ): CompletableFuture> = - replace(userId, params, RequestOptions.none()) - - /** @see replace */ - fun replace( - userId: String, - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - replace(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see replace */ - fun replace( - params: ProfileReplaceParams - ): CompletableFuture> = - replace(params, RequestOptions.none()) - - /** @see replace */ - fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt deleted file mode 100644 index 7a55ce13..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/ProfileServiceAsyncImpl.kt +++ /dev/null @@ -1,259 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.profiles.ProfileCreateParams -import com.courier.api.models.profiles.ProfileCreateResponse -import com.courier.api.models.profiles.ProfileDeleteParams -import com.courier.api.models.profiles.ProfileReplaceParams -import com.courier.api.models.profiles.ProfileReplaceResponse -import com.courier.api.models.profiles.ProfileRetrieveParams -import com.courier.api.models.profiles.ProfileRetrieveResponse -import com.courier.api.models.profiles.ProfileUpdateParams -import com.courier.api.services.async.profiles.ListServiceAsync -import com.courier.api.services.async.profiles.ListServiceAsyncImpl -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ProfileServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ProfileServiceAsync { - - private val withRawResponse: ProfileServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val lists: ListServiceAsync by lazy { ListServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): ProfileServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ProfileServiceAsync = - ProfileServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun lists(): ListServiceAsync = lists - - override fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /profiles/{user_id} - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /profiles/{user_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: ProfileUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // patch /profiles/{user_id} - withRawResponse().update(params, requestOptions).thenAccept {} - - override fun delete( - params: ProfileDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /profiles/{user_id} - withRawResponse().delete(params, requestOptions).thenAccept {} - - override fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /profiles/{user_id} - withRawResponse().replace(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProfileServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val lists: ListServiceAsync.WithRawResponse by lazy { - ListServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): ProfileServiceAsync.WithRawResponse = - ProfileServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun lists(): ListServiceAsync.WithRawResponse = lists - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: ProfileUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: ProfileDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt deleted file mode 100644 index 7034b980..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsync.kt +++ /dev/null @@ -1,110 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.models.requests.RequestArchiveParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface RequestServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): RequestServiceAsync - - /** Archive message */ - fun archive(requestId: String): CompletableFuture = - archive(requestId, RequestArchiveParams.none()) - - /** @see archive */ - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - archive(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see archive */ - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - ): CompletableFuture = archive(requestId, params, RequestOptions.none()) - - /** @see archive */ - fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see archive */ - fun archive(params: RequestArchiveParams): CompletableFuture = - archive(params, RequestOptions.none()) - - /** @see archive */ - fun archive(requestId: String, requestOptions: RequestOptions): CompletableFuture = - archive(requestId, RequestArchiveParams.none(), requestOptions) - - /** - * A view of [RequestServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): RequestServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `put /requests/{request_id}/archive`, but is otherwise - * the same as [RequestServiceAsync.archive]. - */ - fun archive(requestId: String): CompletableFuture = - archive(requestId, RequestArchiveParams.none()) - - /** @see archive */ - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - archive(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see archive */ - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - ): CompletableFuture = archive(requestId, params, RequestOptions.none()) - - /** @see archive */ - fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see archive */ - fun archive(params: RequestArchiveParams): CompletableFuture = - archive(params, RequestOptions.none()) - - /** @see archive */ - fun archive( - requestId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - archive(requestId, RequestArchiveParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt deleted file mode 100644 index acd685d4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/RequestServiceAsyncImpl.kt +++ /dev/null @@ -1,82 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.requests.RequestArchiveParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class RequestServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - RequestServiceAsync { - - private val withRawResponse: RequestServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): RequestServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): RequestServiceAsync = - RequestServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /requests/{request_id}/archive - withRawResponse().archive(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RequestServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): RequestServiceAsync.WithRawResponse = - RequestServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val archiveHandler: Handler = emptyHandler() - - override fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("requestId", params.requestId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("requests", params._pathParam(0), "archive") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { archiveHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt index 3d9e4a0e..6e194a5c 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt @@ -5,8 +5,8 @@ package com.courier.api.services.async import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.SendMessageResponse +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -25,14 +25,14 @@ interface SendServiceAsync { fun withOptions(modifier: Consumer): SendServiceAsync /** Use the send API to send a message to one or more recipients. */ - fun message(params: SendMessageParams): CompletableFuture = - message(params, RequestOptions.none()) + fun sendMessage(params: SendSendMessageParams): CompletableFuture = + sendMessage(params, RequestOptions.none()) - /** @see message */ - fun message( - params: SendMessageParams, + /** @see sendMessage */ + fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** A view of [SendServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -46,17 +46,17 @@ interface SendServiceAsync { /** * Returns a raw HTTP response for `post /send`, but is otherwise the same as - * [SendServiceAsync.message]. + * [SendServiceAsync.sendMessage]. */ - fun message( - params: SendMessageParams - ): CompletableFuture> = - message(params, RequestOptions.none()) - - /** @see message */ - fun message( - params: SendMessageParams, + fun sendMessage( + params: SendSendMessageParams + ): CompletableFuture> = + sendMessage(params, RequestOptions.none()) + + /** @see sendMessage */ + fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt index 9d5042b7..67cf12db 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt @@ -15,8 +15,8 @@ import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepareAsync -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.SendMessageResponse +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -32,12 +32,12 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): SendServiceAsync = SendServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun message( - params: SendMessageParams, + override fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /send - withRawResponse().message(params, requestOptions).thenApply { it.parse() } + withRawResponse().sendMessage(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SendServiceAsync.WithRawResponse { @@ -52,13 +52,13 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - private val messageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val sendMessageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun message( - params: SendMessageParams, + override fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -73,7 +73,7 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { messageHandler.handle(it) } + .use { sendMessageHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt deleted file mode 100644 index ce07f17e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsync.kt +++ /dev/null @@ -1,371 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.tenants.Tenant -import com.courier.api.models.tenants.TenantDeleteParams -import com.courier.api.models.tenants.TenantListParams -import com.courier.api.models.tenants.TenantListResponse -import com.courier.api.models.tenants.TenantListUsersParams -import com.courier.api.models.tenants.TenantListUsersResponse -import com.courier.api.models.tenants.TenantRetrieveParams -import com.courier.api.models.tenants.TenantUpdateParams -import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsync -import com.courier.api.services.async.tenants.TemplateServiceAsync -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface TenantServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TenantServiceAsync - - fun defaultPreferences(): DefaultPreferenceServiceAsync - - fun templates(): TemplateServiceAsync - - /** Get a Tenant */ - fun retrieve(tenantId: String): CompletableFuture = - retrieve(tenantId, TenantRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - ): CompletableFuture = retrieve(tenantId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: TenantRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(tenantId: String, requestOptions: RequestOptions): CompletableFuture = - retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) - - /** Create or Replace a Tenant */ - fun update(tenantId: String, params: TenantUpdateParams): CompletableFuture = - update(tenantId, params, RequestOptions.none()) - - /** @see update */ - fun update( - tenantId: String, - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see update */ - fun update(params: TenantUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Get a List of Tenants */ - fun list(): CompletableFuture = list(TenantListParams.none()) - - /** @see list */ - fun list( - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: TenantListParams = TenantListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(TenantListParams.none(), requestOptions) - - /** Delete a Tenant */ - fun delete(tenantId: String): CompletableFuture = - delete(tenantId, TenantDeleteParams.none()) - - /** @see delete */ - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see delete */ - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - ): CompletableFuture = delete(tenantId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TenantDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: TenantDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(tenantId: String, requestOptions: RequestOptions): CompletableFuture = - delete(tenantId, TenantDeleteParams.none(), requestOptions) - - /** Get Users in Tenant */ - fun listUsers(tenantId: String): CompletableFuture = - listUsers(tenantId, TenantListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - ): CompletableFuture = - listUsers(tenantId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see listUsers */ - fun listUsers(params: TenantListUsersParams): CompletableFuture = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - listUsers(tenantId, TenantListUsersParams.none(), requestOptions) - - /** - * A view of [TenantServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): TenantServiceAsync.WithRawResponse - - fun defaultPreferences(): DefaultPreferenceServiceAsync.WithRawResponse - - fun templates(): TemplateServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}`, but is otherwise the same as - * [TenantServiceAsync.retrieve]. - */ - fun retrieve(tenantId: String): CompletableFuture> = - retrieve(tenantId, TenantRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - ): CompletableFuture> = - retrieve(tenantId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve(params: TenantRetrieveParams): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /tenants/{tenant_id}`, but is otherwise the same as - * [TenantServiceAsync.update]. - */ - fun update( - tenantId: String, - params: TenantUpdateParams, - ): CompletableFuture> = - update(tenantId, params, RequestOptions.none()) - - /** @see update */ - fun update( - tenantId: String, - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see update */ - fun update(params: TenantUpdateParams): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /tenants`, but is otherwise the same as - * [TenantServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(TenantListParams.none()) - - /** @see list */ - fun list( - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: TenantListParams = TenantListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(TenantListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /tenants/{tenant_id}`, but is otherwise the same - * as [TenantServiceAsync.delete]. - */ - fun delete(tenantId: String): CompletableFuture = - delete(tenantId, TenantDeleteParams.none()) - - /** @see delete */ - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see delete */ - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - ): CompletableFuture = delete(tenantId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TenantDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: TenantDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - tenantId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - delete(tenantId, TenantDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}/users`, but is otherwise the - * same as [TenantServiceAsync.listUsers]. - */ - fun listUsers( - tenantId: String - ): CompletableFuture> = - listUsers(tenantId, TenantListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - ): CompletableFuture> = - listUsers(tenantId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see listUsers */ - fun listUsers( - params: TenantListUsersParams - ): CompletableFuture> = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - listUsers(tenantId, TenantListUsersParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt deleted file mode 100644 index 44e59a6b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TenantServiceAsyncImpl.kt +++ /dev/null @@ -1,274 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.tenants.Tenant -import com.courier.api.models.tenants.TenantDeleteParams -import com.courier.api.models.tenants.TenantListParams -import com.courier.api.models.tenants.TenantListResponse -import com.courier.api.models.tenants.TenantListUsersParams -import com.courier.api.models.tenants.TenantListUsersResponse -import com.courier.api.models.tenants.TenantRetrieveParams -import com.courier.api.models.tenants.TenantUpdateParams -import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsync -import com.courier.api.services.async.tenants.DefaultPreferenceServiceAsyncImpl -import com.courier.api.services.async.tenants.TemplateServiceAsync -import com.courier.api.services.async.tenants.TemplateServiceAsyncImpl -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TenantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TenantServiceAsync { - - private val withRawResponse: TenantServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val defaultPreferences: DefaultPreferenceServiceAsync by lazy { - DefaultPreferenceServiceAsyncImpl(clientOptions) - } - - private val templates: TemplateServiceAsync by lazy { TemplateServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): TenantServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TenantServiceAsync = - TenantServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun defaultPreferences(): DefaultPreferenceServiceAsync = defaultPreferences - - override fun templates(): TemplateServiceAsync = templates - - override fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /tenants/{tenant_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /tenants/{tenant_id} - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /tenants - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: TenantDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /tenants/{tenant_id} - withRawResponse().delete(params, requestOptions).thenAccept {} - - override fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /tenants/{tenant_id}/users - withRawResponse().listUsers(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TenantServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val defaultPreferences: DefaultPreferenceServiceAsync.WithRawResponse by lazy { - DefaultPreferenceServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val templates: TemplateServiceAsync.WithRawResponse by lazy { - TemplateServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): TenantServiceAsync.WithRawResponse = - TenantServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun defaultPreferences(): DefaultPreferenceServiceAsync.WithRawResponse = - defaultPreferences - - override fun templates(): TemplateServiceAsync.WithRawResponse = templates - - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: TenantDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - - private val listUsersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0), "users") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listUsersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt deleted file mode 100644 index 656926cd..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsync.kt +++ /dev/null @@ -1,142 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.translations.TranslationRetrieveParams -import com.courier.api.models.translations.TranslationUpdateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface TranslationServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TranslationServiceAsync - - /** Get translations by locale */ - fun retrieve(locale: String, params: TranslationRetrieveParams): CompletableFuture = - retrieve(locale, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - locale: String, - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: TranslationRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Update a translation */ - fun update(locale: String, params: TranslationUpdateParams): CompletableFuture = - update(locale, params, RequestOptions.none()) - - /** @see update */ - fun update( - locale: String, - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see update */ - fun update(params: TranslationUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [TranslationServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): TranslationServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /translations/{domain}/{locale}`, but is otherwise - * the same as [TranslationServiceAsync.retrieve]. - */ - fun retrieve( - locale: String, - params: TranslationRetrieveParams, - ): CompletableFuture> = - retrieve(locale, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - locale: String, - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - params: TranslationRetrieveParams - ): CompletableFuture> = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `put /translations/{domain}/{locale}`, but is otherwise - * the same as [TranslationServiceAsync.update]. - */ - fun update( - locale: String, - params: TranslationUpdateParams, - ): CompletableFuture = update(locale, params, RequestOptions.none()) - - /** @see update */ - fun update( - locale: String, - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see update */ - fun update(params: TranslationUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt deleted file mode 100644 index dc89350c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/TranslationServiceAsyncImpl.kt +++ /dev/null @@ -1,118 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.stringHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.translations.TranslationRetrieveParams -import com.courier.api.models.translations.TranslationUpdateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TranslationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TranslationServiceAsync { - - private val withRawResponse: TranslationServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TranslationServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TranslationServiceAsync = - TranslationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /translations/{domain}/{locale} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /translations/{domain}/{locale} - withRawResponse().update(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TranslationServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TranslationServiceAsync.WithRawResponse = - TranslationServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = stringHandler() - - override fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("locale", params.locale().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { retrieveHandler.handle(it) } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("locale", params.locale().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt deleted file mode 100644 index d1cf7a26..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsync.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.services.async.users.PreferenceServiceAsync -import com.courier.api.services.async.users.TenantServiceAsync -import com.courier.api.services.async.users.TokenServiceAsync -import java.util.function.Consumer - -interface UserServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): UserServiceAsync - - fun preferences(): PreferenceServiceAsync - - fun tenants(): TenantServiceAsync - - fun tokens(): TokenServiceAsync - - /** A view of [UserServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): UserServiceAsync.WithRawResponse - - fun preferences(): PreferenceServiceAsync.WithRawResponse - - fun tenants(): TenantServiceAsync.WithRawResponse - - fun tokens(): TokenServiceAsync.WithRawResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt deleted file mode 100644 index 16f4a2d3..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/UserServiceAsyncImpl.kt +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.core.ClientOptions -import com.courier.api.services.async.users.PreferenceServiceAsync -import com.courier.api.services.async.users.PreferenceServiceAsyncImpl -import com.courier.api.services.async.users.TenantServiceAsync -import com.courier.api.services.async.users.TenantServiceAsyncImpl -import com.courier.api.services.async.users.TokenServiceAsync -import com.courier.api.services.async.users.TokenServiceAsyncImpl -import java.util.function.Consumer - -class UserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - UserServiceAsync { - - private val withRawResponse: UserServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val preferences: PreferenceServiceAsync by lazy { - PreferenceServiceAsyncImpl(clientOptions) - } - - private val tenants: TenantServiceAsync by lazy { TenantServiceAsyncImpl(clientOptions) } - - private val tokens: TokenServiceAsync by lazy { TokenServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): UserServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): UserServiceAsync = - UserServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun preferences(): PreferenceServiceAsync = preferences - - override fun tenants(): TenantServiceAsync = tenants - - override fun tokens(): TokenServiceAsync = tokens - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - UserServiceAsync.WithRawResponse { - - private val preferences: PreferenceServiceAsync.WithRawResponse by lazy { - PreferenceServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val tenants: TenantServiceAsync.WithRawResponse by lazy { - TenantServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - private val tokens: TokenServiceAsync.WithRawResponse by lazy { - TokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): UserServiceAsync.WithRawResponse = - UserServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun preferences(): PreferenceServiceAsync.WithRawResponse = preferences - - override fun tenants(): TenantServiceAsync.WithRawResponse = tenants - - override fun tokens(): TokenServiceAsync.WithRawResponse = tokens - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt deleted file mode 100644 index 0c6046a7..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsync.kt +++ /dev/null @@ -1,127 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.automations - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.automations.invoke.AutomationInvokeResponse -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams -import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface InvokeServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): InvokeServiceAsync - - /** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of - * automation steps. For information about what steps are available, checkout the ad hoc - * automation guide [here](https://www.courier.com/docs/automations/steps/). - */ - fun invokeAdHoc(params: InvokeInvokeAdHocParams): CompletableFuture = - invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Invoke an automation run from an automation template. */ - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - ): CompletableFuture = - invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams - ): CompletableFuture = invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [InvokeServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): InvokeServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as - * [InvokeServiceAsync.invokeAdHoc]. - */ - fun invokeAdHoc( - params: InvokeInvokeAdHocParams - ): CompletableFuture> = - invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise - * the same as [InvokeServiceAsync.invokeByTemplate]. - */ - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - ): CompletableFuture> = - invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams - ): CompletableFuture> = - invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt deleted file mode 100644 index 5f95c7e1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncImpl.kt +++ /dev/null @@ -1,130 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.automations - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.automations.invoke.AutomationInvokeResponse -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams -import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class InvokeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - InvokeServiceAsync { - - private val withRawResponse: InvokeServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): InvokeServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): InvokeServiceAsync = - InvokeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /automations/invoke - withRawResponse().invokeAdHoc(params, requestOptions).thenApply { it.parse() } - - override fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /automations/{templateId}/invoke - withRawResponse().invokeByTemplate(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - InvokeServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): InvokeServiceAsync.WithRawResponse = - InvokeServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val invokeAdHocHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { invokeAdHocHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val invokeByTemplateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("templateId", params.templateId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", params._pathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { invokeByTemplateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt deleted file mode 100644 index 956ebf8a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsync.kt +++ /dev/null @@ -1,331 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.lists - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.lists.subscriptions.SubscriptionAddParams -import com.courier.api.models.lists.subscriptions.SubscriptionListParams -import com.courier.api.models.lists.subscriptions.SubscriptionListResponse -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams -import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface SubscriptionServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): SubscriptionServiceAsync - - /** Get the list's subscriptions. */ - fun list(listId: String): CompletableFuture = - list(listId, SubscriptionListParams.none()) - - /** @see list */ - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - list(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see list */ - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - ): CompletableFuture = list(listId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list(params: SubscriptionListParams): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - listId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - list(listId, SubscriptionListParams.none(), requestOptions) - - /** - * Subscribes additional users to the list, without modifying existing subscriptions. If the - * list does not exist, it will be automatically created. - */ - fun add(listId: String, params: SubscriptionAddParams): CompletableFuture = - add(listId, params, RequestOptions.none()) - - /** @see add */ - fun add( - listId: String, - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = add(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see add */ - fun add(params: SubscriptionAddParams): CompletableFuture = - add(params, RequestOptions.none()) - - /** @see add */ - fun add( - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Subscribes the users to the list, overwriting existing subscriptions. If the list does not - * exist, it will be automatically created. - */ - fun subscribe(listId: String, params: SubscriptionSubscribeParams): CompletableFuture = - subscribe(listId, params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - listId: String, - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - subscribe(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see subscribe */ - fun subscribe(params: SubscriptionSubscribeParams): CompletableFuture = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Subscribe a user to an existing list (note: if the List does not exist, it will be - * automatically created). - */ - fun subscribeUser( - userId: String, - params: SubscriptionSubscribeUserParams, - ): CompletableFuture = subscribeUser(userId, params, RequestOptions.none()) - - /** @see subscribeUser */ - fun subscribeUser( - userId: String, - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribeUser */ - fun subscribeUser(params: SubscriptionSubscribeUserParams): CompletableFuture = - subscribeUser(params, RequestOptions.none()) - - /** @see subscribeUser */ - fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Delete a subscription to a list by list ID and user ID. */ - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - ): CompletableFuture = unsubscribeUser(userId, params, RequestOptions.none()) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see unsubscribeUser */ - fun unsubscribeUser(params: SubscriptionUnsubscribeUserParams): CompletableFuture = - unsubscribeUser(params, RequestOptions.none()) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [SubscriptionServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): SubscriptionServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /lists/{list_id}/subscriptions`, but is otherwise - * the same as [SubscriptionServiceAsync.list]. - */ - fun list(listId: String): CompletableFuture> = - list(listId, SubscriptionListParams.none()) - - /** @see list */ - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see list */ - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - ): CompletableFuture> = - list(listId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: SubscriptionListParams - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - listId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - list(listId, SubscriptionListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /lists/{list_id}/subscriptions`, but is otherwise - * the same as [SubscriptionServiceAsync.add]. - */ - fun add(listId: String, params: SubscriptionAddParams): CompletableFuture = - add(listId, params, RequestOptions.none()) - - /** @see add */ - fun add( - listId: String, - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - add(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see add */ - fun add(params: SubscriptionAddParams): CompletableFuture = - add(params, RequestOptions.none()) - - /** @see add */ - fun add( - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions`, but is otherwise - * the same as [SubscriptionServiceAsync.subscribe]. - */ - fun subscribe( - listId: String, - params: SubscriptionSubscribeParams, - ): CompletableFuture = subscribe(listId, params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - listId: String, - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - subscribe(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see subscribe */ - fun subscribe(params: SubscriptionSubscribeParams): CompletableFuture = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions/{user_id}`, but is - * otherwise the same as [SubscriptionServiceAsync.subscribeUser]. - */ - fun subscribeUser( - userId: String, - params: SubscriptionSubscribeUserParams, - ): CompletableFuture = subscribeUser(userId, params, RequestOptions.none()) - - /** @see subscribeUser */ - fun subscribeUser( - userId: String, - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribeUser */ - fun subscribeUser( - params: SubscriptionSubscribeUserParams - ): CompletableFuture = subscribeUser(params, RequestOptions.none()) - - /** @see subscribeUser */ - fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `delete /lists/{list_id}/subscriptions/{user_id}`, but is - * otherwise the same as [SubscriptionServiceAsync.unsubscribeUser]. - */ - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - ): CompletableFuture = unsubscribeUser(userId, params, RequestOptions.none()) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams - ): CompletableFuture = unsubscribeUser(params, RequestOptions.none()) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt deleted file mode 100644 index f6740caa..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncImpl.kt +++ /dev/null @@ -1,241 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.lists - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.lists.subscriptions.SubscriptionAddParams -import com.courier.api.models.lists.subscriptions.SubscriptionListParams -import com.courier.api.models.lists.subscriptions.SubscriptionListResponse -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams -import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class SubscriptionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - SubscriptionServiceAsync { - - private val withRawResponse: SubscriptionServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): SubscriptionServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): SubscriptionServiceAsync = - SubscriptionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /lists/{list_id}/subscriptions - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun add( - params: SubscriptionAddParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /lists/{list_id}/subscriptions - withRawResponse().add(params, requestOptions).thenAccept {} - - override fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /lists/{list_id}/subscriptions - withRawResponse().subscribe(params, requestOptions).thenAccept {} - - override fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /lists/{list_id}/subscriptions/{user_id} - withRawResponse().subscribeUser(params, requestOptions).thenAccept {} - - override fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /lists/{list_id}/subscriptions/{user_id} - withRawResponse().unsubscribeUser(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - SubscriptionServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): SubscriptionServiceAsync.WithRawResponse = - SubscriptionServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "subscriptions") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val addHandler: Handler = emptyHandler() - - override fun add( - params: SubscriptionAddParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "subscriptions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { addHandler.handle(it) } - } - } - } - - private val subscribeHandler: Handler = emptyHandler() - - override fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "subscriptions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { subscribeHandler.handle(it) } - } - } - } - - private val subscribeUserHandler: Handler = emptyHandler() - - override fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "lists", - params._pathParam(0), - "subscriptions", - params._pathParam(1), - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { subscribeUserHandler.handle(it) } - } - } - } - - private val unsubscribeUserHandler: Handler = emptyHandler() - - override fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "lists", - params._pathParam(0), - "subscriptions", - params._pathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { unsubscribeUserHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt deleted file mode 100644 index 4999a60e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsync.kt +++ /dev/null @@ -1,193 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.notifications.checks.CheckDeleteParams -import com.courier.api.models.notifications.checks.CheckListParams -import com.courier.api.models.notifications.checks.CheckListResponse -import com.courier.api.models.notifications.checks.CheckUpdateParams -import com.courier.api.models.notifications.checks.CheckUpdateResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface CheckServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CheckServiceAsync - - fun update( - submissionId: String, - params: CheckUpdateParams, - ): CompletableFuture = update(submissionId, params, RequestOptions.none()) - - /** @see update */ - fun update( - submissionId: String, - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see update */ - fun update(params: CheckUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - fun list(submissionId: String, params: CheckListParams): CompletableFuture = - list(submissionId, params, RequestOptions.none()) - - /** @see list */ - fun list( - submissionId: String, - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - list(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see list */ - fun list(params: CheckListParams): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - fun delete(submissionId: String, params: CheckDeleteParams): CompletableFuture = - delete(submissionId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - submissionId: String, - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see delete */ - fun delete(params: CheckDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [CheckServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): CheckServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `put /notifications/{id}/{submissionId}/checks`, but is - * otherwise the same as [CheckServiceAsync.update]. - */ - fun update( - submissionId: String, - params: CheckUpdateParams, - ): CompletableFuture> = - update(submissionId, params, RequestOptions.none()) - - /** @see update */ - fun update( - submissionId: String, - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - update(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see update */ - fun update( - params: CheckUpdateParams - ): CompletableFuture> = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /notifications/{id}/{submissionId}/checks`, but is - * otherwise the same as [CheckServiceAsync.list]. - */ - fun list( - submissionId: String, - params: CheckListParams, - ): CompletableFuture> = - list(submissionId, params, RequestOptions.none()) - - /** @see list */ - fun list( - submissionId: String, - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see list */ - fun list(params: CheckListParams): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `delete /notifications/{id}/{submissionId}/checks`, but - * is otherwise the same as [CheckServiceAsync.delete]. - */ - fun delete( - submissionId: String, - params: CheckDeleteParams, - ): CompletableFuture = delete(submissionId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - submissionId: String, - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see delete */ - fun delete(params: CheckDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt deleted file mode 100644 index dc7c63b4..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncImpl.kt +++ /dev/null @@ -1,184 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.notifications.checks.CheckDeleteParams -import com.courier.api.models.notifications.checks.CheckListParams -import com.courier.api.models.notifications.checks.CheckListResponse -import com.courier.api.models.notifications.checks.CheckUpdateParams -import com.courier.api.models.notifications.checks.CheckUpdateResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class CheckServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - CheckServiceAsync { - - private val withRawResponse: CheckServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): CheckServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): CheckServiceAsync = - CheckServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /notifications/{id}/{submissionId}/checks - withRawResponse().update(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: CheckListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /notifications/{id}/{submissionId}/checks - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: CheckDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /notifications/{id}/{submissionId}/checks - withRawResponse().delete(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - CheckServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): CheckServiceAsync.WithRawResponse = - CheckServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("submissionId", params.submissionId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "notifications", - params._pathParam(0), - params._pathParam(1), - "checks", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: CheckListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("submissionId", params.submissionId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "notifications", - params._pathParam(0), - params._pathParam(1), - "checks", - ) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: CheckDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("submissionId", params.submissionId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "notifications", - params._pathParam(0), - params._pathParam(1), - "checks", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt deleted file mode 100644 index b0e47a1d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsync.kt +++ /dev/null @@ -1,118 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.draft.DraftRetrieveContentParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface DraftServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): DraftServiceAsync - - fun retrieveContent(id: String): CompletableFuture = - retrieveContent(id, DraftRetrieveContentParams.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - ): CompletableFuture = - retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieveContent */ - fun retrieveContent( - params: DraftRetrieveContentParams - ): CompletableFuture = retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) - - /** A view of [DraftServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): DraftServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /notifications/{id}/draft/content`, but is otherwise - * the same as [DraftServiceAsync.retrieveContent]. - */ - fun retrieveContent( - id: String - ): CompletableFuture> = - retrieveContent(id, DraftRetrieveContentParams.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - ): CompletableFuture> = - retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieveContent */ - fun retrieveContent( - params: DraftRetrieveContentParams - ): CompletableFuture> = - retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt deleted file mode 100644 index ea4dc0c9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncImpl.kt +++ /dev/null @@ -1,89 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.draft.DraftRetrieveContentParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class DraftServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - DraftServiceAsync { - - private val withRawResponse: DraftServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): DraftServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): DraftServiceAsync = - DraftServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /notifications/{id}/draft/content - withRawResponse().retrieveContent(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DraftServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): DraftServiceAsync.WithRawResponse = - DraftServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveContentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("id", params.id().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("notifications", params._pathParam(0), "draft", "content") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveContentHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt deleted file mode 100644 index b0cd0fc1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsync.kt +++ /dev/null @@ -1,250 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.profiles - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.profiles.lists.ListDeleteParams -import com.courier.api.models.profiles.lists.ListDeleteResponse -import com.courier.api.models.profiles.lists.ListRetrieveParams -import com.courier.api.models.profiles.lists.ListRetrieveResponse -import com.courier.api.models.profiles.lists.ListSubscribeParams -import com.courier.api.models.profiles.lists.ListSubscribeResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface ListServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListServiceAsync - - /** Returns the subscribed lists for a specified user. */ - fun retrieve(userId: String): CompletableFuture = - retrieve(userId, ListRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): CompletableFuture = retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: ListRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(userId, ListRetrieveParams.none(), requestOptions) - - /** Removes all list subscriptions for given user. */ - fun delete(userId: String): CompletableFuture = - delete(userId, ListDeleteParams.none()) - - /** @see delete */ - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): CompletableFuture = delete(userId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see delete */ - fun delete(params: ListDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - delete(userId, ListDeleteParams.none(), requestOptions) - - /** - * Subscribes the given user to one or more lists. If the list does not exist, it will be - * created. - */ - fun subscribe( - userId: String, - params: ListSubscribeParams, - ): CompletableFuture = subscribe(userId, params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - userId: String, - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - subscribe(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribe */ - fun subscribe(params: ListSubscribeParams): CompletableFuture = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [ListServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /profiles/{user_id}/lists`, but is otherwise the - * same as [ListServiceAsync.retrieve]. - */ - fun retrieve(userId: String): CompletableFuture> = - retrieve(userId, ListRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): CompletableFuture> = - retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(userId, ListRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /profiles/{user_id}/lists`, but is otherwise the - * same as [ListServiceAsync.delete]. - */ - fun delete(userId: String): CompletableFuture> = - delete(userId, ListDeleteParams.none()) - - /** @see delete */ - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): CompletableFuture> = - delete(userId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see delete */ - fun delete( - params: ListDeleteParams - ): CompletableFuture> = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - delete(userId, ListDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /profiles/{user_id}/lists`, but is otherwise the - * same as [ListServiceAsync.subscribe]. - */ - fun subscribe( - userId: String, - params: ListSubscribeParams, - ): CompletableFuture> = - subscribe(userId, params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - userId: String, - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - subscribe(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribe */ - fun subscribe( - params: ListSubscribeParams - ): CompletableFuture> = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt deleted file mode 100644 index 335501eb..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncImpl.kt +++ /dev/null @@ -1,176 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.profiles - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.profiles.lists.ListDeleteParams -import com.courier.api.models.profiles.lists.ListDeleteResponse -import com.courier.api.models.profiles.lists.ListRetrieveParams -import com.courier.api.models.profiles.lists.ListRetrieveResponse -import com.courier.api.models.profiles.lists.ListSubscribeParams -import com.courier.api.models.profiles.lists.ListSubscribeResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ListServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ListServiceAsync { - - private val withRawResponse: ListServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): ListServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ListServiceAsync = - ListServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /profiles/{user_id}/lists - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /profiles/{user_id}/lists - withRawResponse().delete(params, requestOptions).thenApply { it.parse() } - - override fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /profiles/{user_id}/lists - withRawResponse().subscribe(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ListServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): ListServiceAsync.WithRawResponse = - ListServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0), "lists") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0), "lists") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val subscribeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0), "lists") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { subscribeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt deleted file mode 100644 index 84205cef..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsync.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.services.async.tenants.defaultpreferences.ItemServiceAsync -import java.util.function.Consumer - -interface DefaultPreferenceServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): DefaultPreferenceServiceAsync - - fun items(): ItemServiceAsync - - /** - * A view of [DefaultPreferenceServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): DefaultPreferenceServiceAsync.WithRawResponse - - fun items(): ItemServiceAsync.WithRawResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt deleted file mode 100644 index aaf7b742..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/DefaultPreferenceServiceAsyncImpl.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.services.async.tenants.defaultpreferences.ItemServiceAsync -import com.courier.api.services.async.tenants.defaultpreferences.ItemServiceAsyncImpl -import java.util.function.Consumer - -class DefaultPreferenceServiceAsyncImpl -internal constructor(private val clientOptions: ClientOptions) : DefaultPreferenceServiceAsync { - - private val withRawResponse: DefaultPreferenceServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val items: ItemServiceAsync by lazy { ItemServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): DefaultPreferenceServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions( - modifier: Consumer - ): DefaultPreferenceServiceAsync = - DefaultPreferenceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun items(): ItemServiceAsync = items - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DefaultPreferenceServiceAsync.WithRawResponse { - - private val items: ItemServiceAsync.WithRawResponse by lazy { - ItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): DefaultPreferenceServiceAsync.WithRawResponse = - DefaultPreferenceServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun items(): ItemServiceAsync.WithRawResponse = items - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt deleted file mode 100644 index 57f29c9f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsync.kt +++ /dev/null @@ -1,174 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation -import com.courier.api.models.tenants.templates.TemplateListParams -import com.courier.api.models.tenants.templates.TemplateListResponse -import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface TemplateServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TemplateServiceAsync - - /** Get a Template in Tenant */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - ): CompletableFuture = - retrieve(templateId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: TemplateRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** List Templates in Tenant */ - fun list(tenantId: String): CompletableFuture = - list(tenantId, TemplateListParams.none()) - - /** @see list */ - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - list(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see list */ - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - ): CompletableFuture = list(tenantId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TemplateListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list(params: TemplateListParams): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - tenantId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - list(tenantId, TemplateListParams.none(), requestOptions) - - /** - * A view of [TemplateServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): TemplateServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates/{template_id}`, but - * is otherwise the same as [TemplateServiceAsync.retrieve]. - */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - ): CompletableFuture> = - retrieve(templateId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - params: TemplateRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise - * the same as [TemplateServiceAsync.list]. - */ - fun list(tenantId: String): CompletableFuture> = - list(tenantId, TemplateListParams.none()) - - /** @see list */ - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see list */ - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - ): CompletableFuture> = - list(tenantId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TemplateListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: TemplateListParams - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - tenantId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - list(tenantId, TemplateListParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt deleted file mode 100644 index 7cf0f7a1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncImpl.kt +++ /dev/null @@ -1,136 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation -import com.courier.api.models.tenants.templates.TemplateListParams -import com.courier.api.models.tenants.templates.TemplateListResponse -import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TemplateServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TemplateServiceAsync { - - private val withRawResponse: TemplateServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TemplateServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TemplateServiceAsync = - TemplateServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /tenants/{tenant_id}/templates/{template_id} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: TemplateListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /tenants/{tenant_id}/templates - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TemplateServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TemplateServiceAsync.WithRawResponse = - TemplateServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("templateId", params.templateId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "tenants", - params._pathParam(0), - "templates", - params._pathParam(1), - ) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: TemplateListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0), "templates") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt deleted file mode 100644 index 61f6939b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsync.kt +++ /dev/null @@ -1,133 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants.defaultpreferences - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams -import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface ItemServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ItemServiceAsync - - /** Create or Replace Default Preferences For Topic */ - fun update(topicId: String, params: ItemUpdateParams): CompletableFuture = - update(topicId, params, RequestOptions.none()) - - /** @see update */ - fun update( - topicId: String, - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see update */ - fun update(params: ItemUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Remove Default Preferences For Topic */ - fun delete(topicId: String, params: ItemDeleteParams): CompletableFuture = - delete(topicId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - topicId: String, - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see delete */ - fun delete(params: ItemDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [ItemServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ItemServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `put - * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as - * [ItemServiceAsync.update]. - */ - fun update(topicId: String, params: ItemUpdateParams): CompletableFuture = - update(topicId, params, RequestOptions.none()) - - /** @see update */ - fun update( - topicId: String, - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see update */ - fun update(params: ItemUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `delete - * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as - * [ItemServiceAsync.delete]. - */ - fun delete(topicId: String, params: ItemDeleteParams): CompletableFuture = - delete(topicId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - topicId: String, - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see delete */ - fun delete(params: ItemDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt deleted file mode 100644 index 5c23862e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncImpl.kt +++ /dev/null @@ -1,129 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants.defaultpreferences - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams -import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - ItemServiceAsync { - - private val withRawResponse: ItemServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): ItemServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ItemServiceAsync = - ItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun update( - params: ItemUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /tenants/{tenant_id}/default_preferences/items/{topic_id} - withRawResponse().update(params, requestOptions).thenAccept {} - - override fun delete( - params: ItemDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /tenants/{tenant_id}/default_preferences/items/{topic_id} - withRawResponse().delete(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ItemServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): ItemServiceAsync.WithRawResponse = - ItemServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: ItemUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "tenants", - params._pathParam(0), - "default_preferences", - "items", - params._pathParam(1), - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: ItemDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "tenants", - params._pathParam(0), - "default_preferences", - "items", - params._pathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt deleted file mode 100644 index 2dc74c2c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsync.kt +++ /dev/null @@ -1,239 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.users.preferences.PreferenceRetrieveParams -import com.courier.api.models.users.preferences.PreferenceRetrieveResponse -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface PreferenceServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): PreferenceServiceAsync - - /** Fetch all user preferences. */ - fun retrieve(userId: String): CompletableFuture = - retrieve(userId, PreferenceRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - ): CompletableFuture = - retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see retrieve */ - fun retrieve(params: PreferenceRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) - - /** Fetch user preferences for a specific subscription topic. */ - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - ): CompletableFuture = - retrieveTopic(topicId, params, RequestOptions.none()) - - /** @see retrieveTopic */ - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see retrieveTopic */ - fun retrieveTopic( - params: PreferenceRetrieveTopicParams - ): CompletableFuture = - retrieveTopic(params, RequestOptions.none()) - - /** @see retrieveTopic */ - fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Update or Create user preferences for a specific subscription topic. */ - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - ): CompletableFuture = - updateOrCreateTopic(topicId, params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams - ): CompletableFuture = - updateOrCreateTopic(params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [PreferenceServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): PreferenceServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/preferences`, but is otherwise the - * same as [PreferenceServiceAsync.retrieve]. - */ - fun retrieve( - userId: String - ): CompletableFuture> = - retrieve(userId, PreferenceRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - ): CompletableFuture> = - retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see retrieve */ - fun retrieve( - params: PreferenceRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /users/{user_id}/preferences/{topic_id}`, but is - * otherwise the same as [PreferenceServiceAsync.retrieveTopic]. - */ - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - ): CompletableFuture> = - retrieveTopic(topicId, params, RequestOptions.none()) - - /** @see retrieveTopic */ - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see retrieveTopic */ - fun retrieveTopic( - params: PreferenceRetrieveTopicParams - ): CompletableFuture> = - retrieveTopic(params, RequestOptions.none()) - - /** @see retrieveTopic */ - fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `put /users/{user_id}/preferences/{topic_id}`, but is - * otherwise the same as [PreferenceServiceAsync.updateOrCreateTopic]. - */ - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - ): CompletableFuture> = - updateOrCreateTopic(topicId, params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams - ): CompletableFuture> = - updateOrCreateTopic(params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt deleted file mode 100644 index 1684d06d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncImpl.kt +++ /dev/null @@ -1,185 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.users.preferences.PreferenceRetrieveParams -import com.courier.api.models.users.preferences.PreferenceRetrieveResponse -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class PreferenceServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - PreferenceServiceAsync { - - private val withRawResponse: PreferenceServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): PreferenceServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): PreferenceServiceAsync = - PreferenceServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /users/{user_id}/preferences - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /users/{user_id}/preferences/{topic_id} - withRawResponse().retrieveTopic(params, requestOptions).thenApply { it.parse() } - - override fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /users/{user_id}/preferences/{topic_id} - withRawResponse().updateOrCreateTopic(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PreferenceServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): PreferenceServiceAsync.WithRawResponse = - PreferenceServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "preferences") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val retrieveTopicHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "users", - params._pathParam(0), - "preferences", - params._pathParam(1), - ) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveTopicHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateOrCreateTopicHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "users", - params._pathParam(0), - "preferences", - params._pathParam(1), - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { updateOrCreateTopicHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt deleted file mode 100644 index ccf0bb85..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsync.kt +++ /dev/null @@ -1,345 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.users.tenants.TenantAddMultipleParams -import com.courier.api.models.users.tenants.TenantAddSingleParams -import com.courier.api.models.users.tenants.TenantListParams -import com.courier.api.models.users.tenants.TenantListResponse -import com.courier.api.models.users.tenants.TenantRemoveAllParams -import com.courier.api.models.users.tenants.TenantRemoveSingleParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface TenantServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TenantServiceAsync - - /** Returns a paginated list of user tenant associations. */ - fun list(userId: String): CompletableFuture = - list(userId, TenantListParams.none()) - - /** @see list */ - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - ): CompletableFuture = list(userId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TenantListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list(params: TenantListParams): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = list(userId, TenantListParams.none(), requestOptions) - - /** - * This endpoint is used to add a user to multiple tenants in one call. A custom profile can - * also be supplied for each tenant. This profile will be merged with the user's main profile - * when sending to the user with that tenant. - */ - fun addMultiple(userId: String, params: TenantAddMultipleParams): CompletableFuture = - addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - fun addMultiple(params: TenantAddMultipleParams): CompletableFuture = - addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * This endpoint is used to add a single tenant. - * - * A custom profile can also be supplied with the tenant. This profile will be merged with the - * user's main profile when sending to the user with that tenant. - */ - fun addSingle(tenantId: String, params: TenantAddSingleParams): CompletableFuture = - addSingle(tenantId, params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - tenantId: String, - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see addSingle */ - fun addSingle(params: TenantAddSingleParams): CompletableFuture = - addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Removes a user from any tenants they may have been associated with. */ - fun removeAll(userId: String): CompletableFuture = - removeAll(userId, TenantRemoveAllParams.none()) - - /** @see removeAll */ - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - removeAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see removeAll */ - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - ): CompletableFuture = removeAll(userId, params, RequestOptions.none()) - - /** @see removeAll */ - fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see removeAll */ - fun removeAll(params: TenantRemoveAllParams): CompletableFuture = - removeAll(params, RequestOptions.none()) - - /** @see removeAll */ - fun removeAll(userId: String, requestOptions: RequestOptions): CompletableFuture = - removeAll(userId, TenantRemoveAllParams.none(), requestOptions) - - /** Removes a user from the supplied tenant. */ - fun removeSingle(tenantId: String, params: TenantRemoveSingleParams): CompletableFuture = - removeSingle(tenantId, params, RequestOptions.none()) - - /** @see removeSingle */ - fun removeSingle( - tenantId: String, - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see removeSingle */ - fun removeSingle(params: TenantRemoveSingleParams): CompletableFuture = - removeSingle(params, RequestOptions.none()) - - /** @see removeSingle */ - fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * A view of [TenantServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): TenantServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tenants`, but is otherwise the same - * as [TenantServiceAsync.list]. - */ - fun list(userId: String): CompletableFuture> = - list(userId, TenantListParams.none()) - - /** @see list */ - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - ): CompletableFuture> = - list(userId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TenantListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list(params: TenantListParams): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - list(userId, TenantListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tenants`, but is otherwise the same - * as [TenantServiceAsync.addMultiple]. - */ - fun addMultiple( - userId: String, - params: TenantAddMultipleParams, - ): CompletableFuture = addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - fun addMultiple(params: TenantAddMultipleParams): CompletableFuture = - addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tenants/{tenant_id}`, but is - * otherwise the same as [TenantServiceAsync.addSingle]. - */ - fun addSingle( - tenantId: String, - params: TenantAddSingleParams, - ): CompletableFuture = addSingle(tenantId, params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - tenantId: String, - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see addSingle */ - fun addSingle(params: TenantAddSingleParams): CompletableFuture = - addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `delete /users/{user_id}/tenants`, but is otherwise the - * same as [TenantServiceAsync.removeAll]. - */ - fun removeAll(userId: String): CompletableFuture = - removeAll(userId, TenantRemoveAllParams.none()) - - /** @see removeAll */ - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - removeAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see removeAll */ - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - ): CompletableFuture = removeAll(userId, params, RequestOptions.none()) - - /** @see removeAll */ - fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see removeAll */ - fun removeAll(params: TenantRemoveAllParams): CompletableFuture = - removeAll(params, RequestOptions.none()) - - /** @see removeAll */ - fun removeAll( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - removeAll(userId, TenantRemoveAllParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /users/{user_id}/tenants/{tenant_id}`, but is - * otherwise the same as [TenantServiceAsync.removeSingle]. - */ - fun removeSingle( - tenantId: String, - params: TenantRemoveSingleParams, - ): CompletableFuture = removeSingle(tenantId, params, RequestOptions.none()) - - /** @see removeSingle */ - fun removeSingle( - tenantId: String, - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see removeSingle */ - fun removeSingle(params: TenantRemoveSingleParams): CompletableFuture = - removeSingle(params, RequestOptions.none()) - - /** @see removeSingle */ - fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt deleted file mode 100644 index 4387c7b2..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TenantServiceAsyncImpl.kt +++ /dev/null @@ -1,231 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.users.tenants.TenantAddMultipleParams -import com.courier.api.models.users.tenants.TenantAddSingleParams -import com.courier.api.models.users.tenants.TenantListParams -import com.courier.api.models.users.tenants.TenantListResponse -import com.courier.api.models.users.tenants.TenantRemoveAllParams -import com.courier.api.models.users.tenants.TenantRemoveSingleParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TenantServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TenantServiceAsync { - - private val withRawResponse: TenantServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TenantServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TenantServiceAsync = - TenantServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /users/{user_id}/tenants - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /users/{user_id}/tenants - withRawResponse().addMultiple(params, requestOptions).thenAccept {} - - override fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /users/{user_id}/tenants/{tenant_id} - withRawResponse().addSingle(params, requestOptions).thenAccept {} - - override fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /users/{user_id}/tenants - withRawResponse().removeAll(params, requestOptions).thenAccept {} - - override fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /users/{user_id}/tenants/{tenant_id} - withRawResponse().removeSingle(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TenantServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TenantServiceAsync.WithRawResponse = - TenantServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val addMultipleHandler: Handler = emptyHandler() - - override fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { addMultipleHandler.handle(it) } - } - } - } - - private val addSingleHandler: Handler = emptyHandler() - - override fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { addSingleHandler.handle(it) } - } - } - } - - private val removeAllHandler: Handler = emptyHandler() - - override fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { removeAllHandler.handle(it) } - } - } - } - - private val removeSingleHandler: Handler = emptyHandler() - - override fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { removeSingleHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt deleted file mode 100644 index 0e63f364..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsync.kt +++ /dev/null @@ -1,382 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.users.tokens.TokenAddMultipleParams -import com.courier.api.models.users.tokens.TokenAddSingleParams -import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveParams -import com.courier.api.models.users.tokens.TokenRetrieveResponse -import com.courier.api.models.users.tokens.TokenUpdateParams -import com.courier.api.models.users.tokens.UserToken -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface TokenServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TokenServiceAsync - - /** Get single token available for a `:token` */ - fun retrieve( - token: String, - params: TokenRetrieveParams, - ): CompletableFuture = retrieve(token, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - token: String, - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - retrieve(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: TokenRetrieveParams): CompletableFuture = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Apply a JSON Patch (RFC 6902) to the specified token. */ - fun update(token: String, params: TokenUpdateParams): CompletableFuture = - update(token, params, RequestOptions.none()) - - /** @see update */ - fun update( - token: String, - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = update(params.toBuilder().token(token).build(), requestOptions) - - /** @see update */ - fun update(params: TokenUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Gets all tokens available for a :user_id */ - fun list(userId: String): CompletableFuture> = - list(userId, TokenListParams.none()) - - /** @see list */ - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - ): CompletableFuture> = list(userId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TokenListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list(params: TokenListParams): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(userId: String, requestOptions: RequestOptions): CompletableFuture> = - list(userId, TokenListParams.none(), requestOptions) - - /** Delete User Token */ - fun delete(token: String, params: TokenDeleteParams): CompletableFuture = - delete(token, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - token: String, - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = delete(params.toBuilder().token(token).build(), requestOptions) - - /** @see delete */ - fun delete(params: TokenDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** Adds multiple tokens to a user and overwrites matching existing tokens. */ - fun addMultiple(userId: String): CompletableFuture = - addMultiple(userId, TokenAddMultipleParams.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - ): CompletableFuture = addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see addMultiple */ - fun addMultiple(params: TokenAddMultipleParams): CompletableFuture = - addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple(userId: String, requestOptions: RequestOptions): CompletableFuture = - addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) - - /** Adds a single token to a user and overwrites a matching existing token. */ - fun addSingle(pathToken: String, params: TokenAddSingleParams): CompletableFuture = - addSingle(pathToken, params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - pathToken: String, - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) - - /** @see addSingle */ - fun addSingle(params: TokenAddSingleParams): CompletableFuture = - addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** A view of [TokenServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): TokenServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenServiceAsync.retrieve]. - */ - fun retrieve( - token: String, - params: TokenRetrieveParams, - ): CompletableFuture> = - retrieve(token, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - token: String, - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - retrieve(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - params: TokenRetrieveParams - ): CompletableFuture> = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `patch /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenServiceAsync.update]. - */ - fun update(token: String, params: TokenUpdateParams): CompletableFuture = - update(token, params, RequestOptions.none()) - - /** @see update */ - fun update( - token: String, - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - update(params.toBuilder().token(token).build(), requestOptions) - - /** @see update */ - fun update(params: TokenUpdateParams): CompletableFuture = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tokens`, but is otherwise the same - * as [TokenServiceAsync.list]. - */ - fun list(userId: String): CompletableFuture>> = - list(userId, TokenListParams.none()) - - /** @see list */ - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> = - list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - ): CompletableFuture>> = - list(userId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TokenListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture>> - - /** @see list */ - fun list(params: TokenListParams): CompletableFuture>> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture>> = - list(userId, TokenListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /users/{user_id}/tokens/{token}`, but is - * otherwise the same as [TokenServiceAsync.delete]. - */ - fun delete(token: String, params: TokenDeleteParams): CompletableFuture = - delete(token, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - token: String, - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - delete(params.toBuilder().token(token).build(), requestOptions) - - /** @see delete */ - fun delete(params: TokenDeleteParams): CompletableFuture = - delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tokens`, but is otherwise the same - * as [TokenServiceAsync.addMultiple]. - */ - fun addMultiple(userId: String): CompletableFuture = - addMultiple(userId, TokenAddMultipleParams.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - ): CompletableFuture = addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see addMultiple */ - fun addMultiple(params: TokenAddMultipleParams): CompletableFuture = - addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenServiceAsync.addSingle]. - */ - fun addSingle( - pathToken: String, - params: TokenAddSingleParams, - ): CompletableFuture = addSingle(pathToken, params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - pathToken: String, - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) - - /** @see addSingle */ - fun addSingle(params: TokenAddSingleParams): CompletableFuture = - addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt deleted file mode 100644 index a0d80bf1..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/users/TokenServiceAsyncImpl.kt +++ /dev/null @@ -1,273 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepareAsync -import com.courier.api.models.users.tokens.TokenAddMultipleParams -import com.courier.api.models.users.tokens.TokenAddSingleParams -import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveParams -import com.courier.api.models.users.tokens.TokenRetrieveResponse -import com.courier.api.models.users.tokens.TokenUpdateParams -import com.courier.api.models.users.tokens.UserToken -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - TokenServiceAsync { - - private val withRawResponse: TokenServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TokenServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TokenServiceAsync = - TokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /users/{user_id}/tokens/{token} - withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } - - override fun update( - params: TokenUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // patch /users/{user_id}/tokens/{token} - withRawResponse().update(params, requestOptions).thenAccept {} - - override fun list( - params: TokenListParams, - requestOptions: RequestOptions, - ): CompletableFuture> = - // get /users/{user_id}/tokens - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun delete( - params: TokenDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // delete /users/{user_id}/tokens/{token} - withRawResponse().delete(params, requestOptions).thenAccept {} - - override fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /users/{user_id}/tokens - withRawResponse().addMultiple(params, requestOptions).thenAccept {} - - override fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // put /users/{user_id}/tokens/{token} - withRawResponse().addSingle(params, requestOptions).thenAccept {} - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TokenServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TokenServiceAsync.WithRawResponse = - TokenServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: TokenUpdateParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - } - - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - - override fun list( - params: TokenListParams, - requestOptions: RequestOptions, - ): CompletableFuture>> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } - } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: TokenDeleteParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } - - private val addMultipleHandler: Handler = emptyHandler() - - override fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { addMultipleHandler.handle(it) } - } - } - } - - private val addSingleHandler: Handler = emptyHandler() - - override fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions, - ): CompletableFuture { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("pathToken", params.pathToken().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response.use { addSingleHandler.handle(it) } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt deleted file mode 100644 index 3f264962..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceService.kt +++ /dev/null @@ -1,382 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.audiences.Audience -import com.courier.api.models.audiences.AudienceDeleteParams -import com.courier.api.models.audiences.AudienceListMembersParams -import com.courier.api.models.audiences.AudienceListMembersResponse -import com.courier.api.models.audiences.AudienceListParams -import com.courier.api.models.audiences.AudienceListResponse -import com.courier.api.models.audiences.AudienceRetrieveParams -import com.courier.api.models.audiences.AudienceUpdateParams -import com.courier.api.models.audiences.AudienceUpdateResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface AudienceService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AudienceService - - /** Returns the specified audience by id. */ - fun retrieve(audienceId: String): Audience = retrieve(audienceId, AudienceRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): Audience = retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - ): Audience = retrieve(audienceId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Audience - - /** @see retrieve */ - fun retrieve(params: AudienceRetrieveParams): Audience = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(audienceId: String, requestOptions: RequestOptions): Audience = - retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) - - /** Creates or updates audience. */ - fun update(audienceId: String): AudienceUpdateResponse = - update(audienceId, AudienceUpdateParams.none()) - - /** @see update */ - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AudienceUpdateResponse = - update(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see update */ - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - ): AudienceUpdateResponse = update(audienceId, params, RequestOptions.none()) - - /** @see update */ - fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AudienceUpdateResponse - - /** @see update */ - fun update(params: AudienceUpdateParams): AudienceUpdateResponse = - update(params, RequestOptions.none()) - - /** @see update */ - fun update(audienceId: String, requestOptions: RequestOptions): AudienceUpdateResponse = - update(audienceId, AudienceUpdateParams.none(), requestOptions) - - /** Get the audiences associated with the authorization token. */ - fun list(): AudienceListResponse = list(AudienceListParams.none()) - - /** @see list */ - fun list( - params: AudienceListParams = AudienceListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AudienceListResponse - - /** @see list */ - fun list(params: AudienceListParams = AudienceListParams.none()): AudienceListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): AudienceListResponse = - list(AudienceListParams.none(), requestOptions) - - /** Deletes the specified audience. */ - fun delete(audienceId: String) = delete(audienceId, AudienceDeleteParams.none()) - - /** @see delete */ - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see delete */ - fun delete(audienceId: String, params: AudienceDeleteParams = AudienceDeleteParams.none()) = - delete(audienceId, params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: AudienceDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see delete */ - fun delete(params: AudienceDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(audienceId: String, requestOptions: RequestOptions) = - delete(audienceId, AudienceDeleteParams.none(), requestOptions) - - /** Get list of members of an audience. */ - fun listMembers(audienceId: String): AudienceListMembersResponse = - listMembers(audienceId, AudienceListMembersParams.none()) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AudienceListMembersResponse = - listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - ): AudienceListMembersResponse = listMembers(audienceId, params, RequestOptions.none()) - - /** @see listMembers */ - fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AudienceListMembersResponse - - /** @see listMembers */ - fun listMembers(params: AudienceListMembersParams): AudienceListMembersResponse = - listMembers(params, RequestOptions.none()) - - /** @see listMembers */ - fun listMembers( - audienceId: String, - requestOptions: RequestOptions, - ): AudienceListMembersResponse = - listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) - - /** A view of [AudienceService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AudienceService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /audiences/{audience_id}`, but is otherwise the same - * as [AudienceService.retrieve]. - */ - @MustBeClosed - fun retrieve(audienceId: String): HttpResponseFor = - retrieve(audienceId, AudienceRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - audienceId: String, - params: AudienceRetrieveParams = AudienceRetrieveParams.none(), - ): HttpResponseFor = retrieve(audienceId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: AudienceRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - audienceId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(audienceId, AudienceRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /audiences/{audience_id}`, but is otherwise the same - * as [AudienceService.update]. - */ - @MustBeClosed - fun update(audienceId: String): HttpResponseFor = - update(audienceId, AudienceUpdateParams.none()) - - /** @see update */ - @MustBeClosed - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update( - audienceId: String, - params: AudienceUpdateParams = AudienceUpdateParams.none(), - ): HttpResponseFor = - update(audienceId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see update */ - @MustBeClosed - fun update(params: AudienceUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - audienceId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - update(audienceId, AudienceUpdateParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /audiences`, but is otherwise the same as - * [AudienceService.list]. - */ - @MustBeClosed - fun list(): HttpResponseFor = list(AudienceListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: AudienceListParams = AudienceListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: AudienceListParams = AudienceListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(AudienceListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /audiences/{audience_id}`, but is otherwise the - * same as [AudienceService.delete]. - */ - @MustBeClosed - fun delete(audienceId: String): HttpResponse = - delete(audienceId, AudienceDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - audienceId: String, - params: AudienceDeleteParams = AudienceDeleteParams.none(), - ): HttpResponse = delete(audienceId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: AudienceDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see delete */ - @MustBeClosed - fun delete(params: AudienceDeleteParams): HttpResponse = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete(audienceId: String, requestOptions: RequestOptions): HttpResponse = - delete(audienceId, AudienceDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /audiences/{audience_id}/members`, but is otherwise - * the same as [AudienceService.listMembers]. - */ - @MustBeClosed - fun listMembers(audienceId: String): HttpResponseFor = - listMembers(audienceId, AudienceListMembersParams.none()) - - /** @see listMembers */ - @MustBeClosed - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - listMembers(params.toBuilder().audienceId(audienceId).build(), requestOptions) - - /** @see listMembers */ - @MustBeClosed - fun listMembers( - audienceId: String, - params: AudienceListMembersParams = AudienceListMembersParams.none(), - ): HttpResponseFor = - listMembers(audienceId, params, RequestOptions.none()) - - /** @see listMembers */ - @MustBeClosed - fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see listMembers */ - @MustBeClosed - fun listMembers( - params: AudienceListMembersParams - ): HttpResponseFor = listMembers(params, RequestOptions.none()) - - /** @see listMembers */ - @MustBeClosed - fun listMembers( - audienceId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - listMembers(audienceId, AudienceListMembersParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt deleted file mode 100644 index 9237a544..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AudienceServiceImpl.kt +++ /dev/null @@ -1,232 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.audiences.Audience -import com.courier.api.models.audiences.AudienceDeleteParams -import com.courier.api.models.audiences.AudienceListMembersParams -import com.courier.api.models.audiences.AudienceListMembersResponse -import com.courier.api.models.audiences.AudienceListParams -import com.courier.api.models.audiences.AudienceListResponse -import com.courier.api.models.audiences.AudienceRetrieveParams -import com.courier.api.models.audiences.AudienceUpdateParams -import com.courier.api.models.audiences.AudienceUpdateResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class AudienceServiceImpl internal constructor(private val clientOptions: ClientOptions) : - AudienceService { - - private val withRawResponse: AudienceService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): AudienceService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AudienceService = - AudienceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions, - ): Audience = - // get /audiences/{audience_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions, - ): AudienceUpdateResponse = - // put /audiences/{audience_id} - withRawResponse().update(params, requestOptions).parse() - - override fun list( - params: AudienceListParams, - requestOptions: RequestOptions, - ): AudienceListResponse = - // get /audiences - withRawResponse().list(params, requestOptions).parse() - - override fun delete(params: AudienceDeleteParams, requestOptions: RequestOptions) { - // delete /audiences/{audience_id} - withRawResponse().delete(params, requestOptions) - } - - override fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions, - ): AudienceListMembersResponse = - // get /audiences/{audience_id}/members - withRawResponse().listMembers(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AudienceService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): AudienceService.WithRawResponse = - AudienceServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: AudienceRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: AudienceUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: AudienceListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: AudienceDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - - private val listMembersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listMembers( - params: AudienceListMembersParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("audienceId", params.audienceId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audiences", params._pathParam(0), "members") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listMembersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt deleted file mode 100644 index e3cc33a9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventService.kt +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.auditevents.AuditEvent -import com.courier.api.models.auditevents.AuditEventListParams -import com.courier.api.models.auditevents.AuditEventListResponse -import com.courier.api.models.auditevents.AuditEventRetrieveParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface AuditEventService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AuditEventService - - /** Fetch a specific audit event by ID. */ - fun retrieve(auditEventId: String): AuditEvent = - retrieve(auditEventId, AuditEventRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AuditEvent = retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - ): AuditEvent = retrieve(auditEventId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AuditEvent - - /** @see retrieve */ - fun retrieve(params: AuditEventRetrieveParams): AuditEvent = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(auditEventId: String, requestOptions: RequestOptions): AuditEvent = - retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) - - /** Fetch the list of audit events */ - fun list(): AuditEventListResponse = list(AuditEventListParams.none()) - - /** @see list */ - fun list( - params: AuditEventListParams = AuditEventListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): AuditEventListResponse - - /** @see list */ - fun list(params: AuditEventListParams = AuditEventListParams.none()): AuditEventListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): AuditEventListResponse = - list(AuditEventListParams.none(), requestOptions) - - /** A view of [AuditEventService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): AuditEventService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /audit-events/{audit-event-id}`, but is otherwise - * the same as [AuditEventService.retrieve]. - */ - @MustBeClosed - fun retrieve(auditEventId: String): HttpResponseFor = - retrieve(auditEventId, AuditEventRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().auditEventId(auditEventId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - auditEventId: String, - params: AuditEventRetrieveParams = AuditEventRetrieveParams.none(), - ): HttpResponseFor = retrieve(auditEventId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: AuditEventRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - auditEventId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(auditEventId, AuditEventRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /audit-events`, but is otherwise the same as - * [AuditEventService.list]. - */ - @MustBeClosed - fun list(): HttpResponseFor = list(AuditEventListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: AuditEventListParams = AuditEventListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: AuditEventListParams = AuditEventListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(AuditEventListParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt deleted file mode 100644 index 16b2e8f8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuditEventServiceImpl.kt +++ /dev/null @@ -1,121 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.auditevents.AuditEvent -import com.courier.api.models.auditevents.AuditEventListParams -import com.courier.api.models.auditevents.AuditEventListResponse -import com.courier.api.models.auditevents.AuditEventRetrieveParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class AuditEventServiceImpl internal constructor(private val clientOptions: ClientOptions) : - AuditEventService { - - private val withRawResponse: AuditEventService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): AuditEventService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AuditEventService = - AuditEventServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions, - ): AuditEvent = - // get /audit-events/{audit-event-id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun list( - params: AuditEventListParams, - requestOptions: RequestOptions, - ): AuditEventListResponse = - // get /audit-events - withRawResponse().list(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AuditEventService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): AuditEventService.WithRawResponse = - AuditEventServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: AuditEventRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("auditEventId", params.auditEventId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audit-events", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: AuditEventListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("audit-events") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt deleted file mode 100644 index e7e40d3d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthService.kt +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.auth.AuthIssueTokenParams -import com.courier.api.models.auth.AuthIssueTokenResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface AuthService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AuthService - - /** Returns a new access token. */ - fun issueToken(params: AuthIssueTokenParams): AuthIssueTokenResponse = - issueToken(params, RequestOptions.none()) - - /** @see issueToken */ - fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AuthIssueTokenResponse - - /** A view of [AuthService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AuthService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /auth/issue-token`, but is otherwise the same as - * [AuthService.issueToken]. - */ - @MustBeClosed - fun issueToken(params: AuthIssueTokenParams): HttpResponseFor = - issueToken(params, RequestOptions.none()) - - /** @see issueToken */ - @MustBeClosed - fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt deleted file mode 100644 index c3ba94ee..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AuthServiceImpl.kt +++ /dev/null @@ -1,81 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.auth.AuthIssueTokenParams -import com.courier.api.models.auth.AuthIssueTokenResponse -import java.util.function.Consumer - -class AuthServiceImpl internal constructor(private val clientOptions: ClientOptions) : AuthService { - - private val withRawResponse: AuthService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): AuthService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AuthService = - AuthServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions, - ): AuthIssueTokenResponse = - // post /auth/issue-token - withRawResponse().issueToken(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AuthService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): AuthService.WithRawResponse = - AuthServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val issueTokenHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun issueToken( - params: AuthIssueTokenParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("auth", "issue-token") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { issueTokenHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt deleted file mode 100644 index a8f13875..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationService.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.automations.InvokeService -import java.util.function.Consumer - -interface AutomationService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): AutomationService - - fun invoke(): InvokeService - - /** A view of [AutomationService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): AutomationService.WithRawResponse - - fun invoke(): InvokeService.WithRawResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt deleted file mode 100644 index e70e5232..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/AutomationServiceImpl.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.automations.InvokeService -import com.courier.api.services.blocking.automations.InvokeServiceImpl -import java.util.function.Consumer - -class AutomationServiceImpl internal constructor(private val clientOptions: ClientOptions) : - AutomationService { - - private val withRawResponse: AutomationService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val invoke: InvokeService by lazy { InvokeServiceImpl(clientOptions) } - - override fun withRawResponse(): AutomationService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): AutomationService = - AutomationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun invoke(): InvokeService = invoke - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - AutomationService.WithRawResponse { - - private val invoke: InvokeService.WithRawResponse by lazy { - InvokeServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): AutomationService.WithRawResponse = - AutomationServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun invoke(): InvokeService.WithRawResponse = invoke - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt deleted file mode 100644 index 1dc03837..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandService.kt +++ /dev/null @@ -1,287 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.brands.Brand -import com.courier.api.models.brands.BrandCreateParams -import com.courier.api.models.brands.BrandDeleteParams -import com.courier.api.models.brands.BrandListParams -import com.courier.api.models.brands.BrandListResponse -import com.courier.api.models.brands.BrandRetrieveParams -import com.courier.api.models.brands.BrandUpdateParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface BrandService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BrandService - - /** Create a new brand */ - fun create(params: BrandCreateParams): Brand = create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BrandCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Brand - - /** Fetch a specific brand by brand ID. */ - fun retrieve(brandId: String): Brand = retrieve(brandId, BrandRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): Brand = retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(brandId: String, params: BrandRetrieveParams = BrandRetrieveParams.none()): Brand = - retrieve(brandId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Brand - - /** @see retrieve */ - fun retrieve(params: BrandRetrieveParams): Brand = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(brandId: String, requestOptions: RequestOptions): Brand = - retrieve(brandId, BrandRetrieveParams.none(), requestOptions) - - /** Replace an existing brand with the supplied values. */ - fun update(brandId: String, params: BrandUpdateParams): Brand = - update(brandId, params, RequestOptions.none()) - - /** @see update */ - fun update( - brandId: String, - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Brand = update(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see update */ - fun update(params: BrandUpdateParams): Brand = update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Brand - - /** Get the list of brands. */ - fun list(): BrandListResponse = list(BrandListParams.none()) - - /** @see list */ - fun list( - params: BrandListParams = BrandListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BrandListResponse - - /** @see list */ - fun list(params: BrandListParams = BrandListParams.none()): BrandListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): BrandListResponse = - list(BrandListParams.none(), requestOptions) - - /** Delete a brand by brand ID. */ - fun delete(brandId: String) = delete(brandId, BrandDeleteParams.none()) - - /** @see delete */ - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see delete */ - fun delete(brandId: String, params: BrandDeleteParams = BrandDeleteParams.none()) = - delete(brandId, params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: BrandDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see delete */ - fun delete(params: BrandDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(brandId: String, requestOptions: RequestOptions) = - delete(brandId, BrandDeleteParams.none(), requestOptions) - - /** A view of [BrandService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BrandService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /brands`, but is otherwise the same as - * [BrandService.create]. - */ - @MustBeClosed - fun create(params: BrandCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: BrandCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /brands/{brand_id}`, but is otherwise the same as - * [BrandService.retrieve]. - */ - @MustBeClosed - fun retrieve(brandId: String): HttpResponseFor = - retrieve(brandId, BrandRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - brandId: String, - params: BrandRetrieveParams = BrandRetrieveParams.none(), - ): HttpResponseFor = retrieve(brandId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: BrandRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve(brandId: String, requestOptions: RequestOptions): HttpResponseFor = - retrieve(brandId, BrandRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /brands/{brand_id}`, but is otherwise the same as - * [BrandService.update]. - */ - @MustBeClosed - fun update(brandId: String, params: BrandUpdateParams): HttpResponseFor = - update(brandId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - brandId: String, - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: BrandUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /brands`, but is otherwise the same as - * [BrandService.list]. - */ - @MustBeClosed fun list(): HttpResponseFor = list(BrandListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: BrandListParams = BrandListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: BrandListParams = BrandListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(BrandListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /brands/{brand_id}`, but is otherwise the same as - * [BrandService.delete]. - */ - @MustBeClosed - fun delete(brandId: String): HttpResponse = delete(brandId, BrandDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().brandId(brandId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - brandId: String, - params: BrandDeleteParams = BrandDeleteParams.none(), - ): HttpResponse = delete(brandId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: BrandDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see delete */ - @MustBeClosed - fun delete(params: BrandDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete(brandId: String, requestOptions: RequestOptions): HttpResponse = - delete(brandId, BrandDeleteParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt deleted file mode 100644 index c9fd104a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BrandServiceImpl.kt +++ /dev/null @@ -1,213 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.brands.Brand -import com.courier.api.models.brands.BrandCreateParams -import com.courier.api.models.brands.BrandDeleteParams -import com.courier.api.models.brands.BrandListParams -import com.courier.api.models.brands.BrandListResponse -import com.courier.api.models.brands.BrandRetrieveParams -import com.courier.api.models.brands.BrandUpdateParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BrandServiceImpl internal constructor(private val clientOptions: ClientOptions) : - BrandService { - - private val withRawResponse: BrandService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BrandService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BrandService = - BrandServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun create(params: BrandCreateParams, requestOptions: RequestOptions): Brand = - // post /brands - withRawResponse().create(params, requestOptions).parse() - - override fun retrieve(params: BrandRetrieveParams, requestOptions: RequestOptions): Brand = - // get /brands/{brand_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update(params: BrandUpdateParams, requestOptions: RequestOptions): Brand = - // put /brands/{brand_id} - withRawResponse().update(params, requestOptions).parse() - - override fun list(params: BrandListParams, requestOptions: RequestOptions): BrandListResponse = - // get /brands - withRawResponse().list(params, requestOptions).parse() - - override fun delete(params: BrandDeleteParams, requestOptions: RequestOptions) { - // delete /brands/{brand_id} - withRawResponse().delete(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BrandService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BrandService.WithRawResponse = - BrandServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: BrandCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: BrandRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("brandId", params.brandId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: BrandUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("brandId", params.brandId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: BrandListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: BrandDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("brandId", params.brandId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("brands", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt deleted file mode 100644 index d59522f8..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkService.kt +++ /dev/null @@ -1,328 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.bulk.BulkAddUsersParams -import com.courier.api.models.bulk.BulkCreateJobParams -import com.courier.api.models.bulk.BulkCreateJobResponse -import com.courier.api.models.bulk.BulkListUsersParams -import com.courier.api.models.bulk.BulkListUsersResponse -import com.courier.api.models.bulk.BulkRetrieveJobParams -import com.courier.api.models.bulk.BulkRetrieveJobResponse -import com.courier.api.models.bulk.BulkRunJobParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface BulkService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkService - - /** Ingest user data into a Bulk Job */ - fun addUsers(jobId: String, params: BulkAddUsersParams) = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams) = addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - fun addUsers(params: BulkAddUsersParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Create a bulk job */ - fun createJob(params: BulkCreateJobParams): BulkCreateJobResponse = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkCreateJobResponse - - /** Get Bulk Job Users */ - fun listUsers(jobId: String): BulkListUsersResponse = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkListUsersResponse = listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): BulkListUsersResponse = listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkListUsersResponse - - /** @see listUsers */ - fun listUsers(params: BulkListUsersParams): BulkListUsersResponse = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers(jobId: String, requestOptions: RequestOptions): BulkListUsersResponse = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** Get a bulk job */ - fun retrieveJob(jobId: String): BulkRetrieveJobResponse = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkRetrieveJobResponse = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): BulkRetrieveJobResponse = retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BulkRetrieveJobResponse - - /** @see retrieveJob */ - fun retrieveJob(params: BulkRetrieveJobParams): BulkRetrieveJobResponse = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - fun retrieveJob(jobId: String, requestOptions: RequestOptions): BulkRetrieveJobResponse = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** Run a bulk job */ - fun runJob(jobId: String) = runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - fun runJob(jobId: String, params: BulkRunJobParams = BulkRunJobParams.none()) = - runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(params: BulkRunJobParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see runJob */ - fun runJob(params: BulkRunJobParams) = runJob(params, RequestOptions.none()) - - /** @see runJob */ - fun runJob(jobId: String, requestOptions: RequestOptions) = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - - /** A view of [BulkService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BulkService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}`, but is otherwise the same as - * [BulkService.addUsers]. - */ - @MustBeClosed - fun addUsers(jobId: String, params: BulkAddUsersParams): HttpResponse = - addUsers(jobId, params, RequestOptions.none()) - - /** @see addUsers */ - @MustBeClosed - fun addUsers( - jobId: String, - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = addUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see addUsers */ - @MustBeClosed - fun addUsers(params: BulkAddUsersParams): HttpResponse = - addUsers(params, RequestOptions.none()) - - /** @see addUsers */ - @MustBeClosed - fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `post /bulk`, but is otherwise the same as - * [BulkService.createJob]. - */ - @MustBeClosed - fun createJob(params: BulkCreateJobParams): HttpResponseFor = - createJob(params, RequestOptions.none()) - - /** @see createJob */ - @MustBeClosed - fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}/users`, but is otherwise the same as - * [BulkService.listUsers]. - */ - @MustBeClosed - fun listUsers(jobId: String): HttpResponseFor = - listUsers(jobId, BulkListUsersParams.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - listUsers(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - jobId: String, - params: BulkListUsersParams = BulkListUsersParams.none(), - ): HttpResponseFor = listUsers(jobId, params, RequestOptions.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see listUsers */ - @MustBeClosed - fun listUsers(params: BulkListUsersParams): HttpResponseFor = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - listUsers(jobId, BulkListUsersParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /bulk/{job_id}`, but is otherwise the same as - * [BulkService.retrieveJob]. - */ - @MustBeClosed - fun retrieveJob(jobId: String): HttpResponseFor = - retrieveJob(jobId, BulkRetrieveJobParams.none()) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - jobId: String, - params: BulkRetrieveJobParams = BulkRetrieveJobParams.none(), - ): HttpResponseFor = - retrieveJob(jobId, params, RequestOptions.none()) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob(params: BulkRetrieveJobParams): HttpResponseFor = - retrieveJob(params, RequestOptions.none()) - - /** @see retrieveJob */ - @MustBeClosed - fun retrieveJob( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieveJob(jobId, BulkRetrieveJobParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /bulk/{job_id}/run`, but is otherwise the same as - * [BulkService.runJob]. - */ - @MustBeClosed - fun runJob(jobId: String): HttpResponse = runJob(jobId, BulkRunJobParams.none()) - - /** @see runJob */ - @MustBeClosed - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = runJob(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see runJob */ - @MustBeClosed - fun runJob( - jobId: String, - params: BulkRunJobParams = BulkRunJobParams.none(), - ): HttpResponse = runJob(jobId, params, RequestOptions.none()) - - /** @see runJob */ - @MustBeClosed - fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see runJob */ - @MustBeClosed - fun runJob(params: BulkRunJobParams): HttpResponse = runJob(params, RequestOptions.none()) - - /** @see runJob */ - @MustBeClosed - fun runJob(jobId: String, requestOptions: RequestOptions): HttpResponse = - runJob(jobId, BulkRunJobParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt deleted file mode 100644 index 41cc3b56..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/BulkServiceImpl.kt +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.bulk.BulkAddUsersParams -import com.courier.api.models.bulk.BulkCreateJobParams -import com.courier.api.models.bulk.BulkCreateJobResponse -import com.courier.api.models.bulk.BulkListUsersParams -import com.courier.api.models.bulk.BulkListUsersResponse -import com.courier.api.models.bulk.BulkRetrieveJobParams -import com.courier.api.models.bulk.BulkRetrieveJobResponse -import com.courier.api.models.bulk.BulkRunJobParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BulkServiceImpl internal constructor(private val clientOptions: ClientOptions) : BulkService { - - private val withRawResponse: BulkService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BulkService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BulkService = - BulkServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun addUsers(params: BulkAddUsersParams, requestOptions: RequestOptions) { - // post /bulk/{job_id} - withRawResponse().addUsers(params, requestOptions) - } - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): BulkCreateJobResponse = - // post /bulk - withRawResponse().createJob(params, requestOptions).parse() - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): BulkListUsersResponse = - // get /bulk/{job_id}/users - withRawResponse().listUsers(params, requestOptions).parse() - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): BulkRetrieveJobResponse = - // get /bulk/{job_id} - withRawResponse().retrieveJob(params, requestOptions).parse() - - override fun runJob(params: BulkRunJobParams, requestOptions: RequestOptions) { - // post /bulk/{job_id}/run - withRawResponse().runJob(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BulkService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BulkService.WithRawResponse = - BulkServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val addUsersHandler: Handler = emptyHandler() - - override fun addUsers( - params: BulkAddUsersParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { addUsersHandler.handle(it) } - } - } - - private val createJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun createJob( - params: BulkCreateJobParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listUsersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listUsers( - params: BulkListUsersParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "users") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listUsersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveJobHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveJob( - params: BulkRetrieveJobParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveJobHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val runJobHandler: Handler = emptyHandler() - - override fun runJob( - params: BulkRunJobParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("bulk", params._pathParam(0), "run") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { runJobHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt deleted file mode 100644 index 5c8dd95a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundService.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.inbound.InboundTrackEventParams -import com.courier.api.models.inbound.InboundTrackEventResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface InboundService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): InboundService - - /** Courier Track Event */ - fun trackEvent(params: InboundTrackEventParams): InboundTrackEventResponse = - trackEvent(params, RequestOptions.none()) - - /** @see trackEvent */ - fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): InboundTrackEventResponse - - /** A view of [InboundService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): InboundService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /inbound/courier`, but is otherwise the same as - * [InboundService.trackEvent]. - */ - @MustBeClosed - fun trackEvent( - params: InboundTrackEventParams - ): HttpResponseFor = trackEvent(params, RequestOptions.none()) - - /** @see trackEvent */ - @MustBeClosed - fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt deleted file mode 100644 index dff28335..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/InboundServiceImpl.kt +++ /dev/null @@ -1,82 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.inbound.InboundTrackEventParams -import com.courier.api.models.inbound.InboundTrackEventResponse -import java.util.function.Consumer - -class InboundServiceImpl internal constructor(private val clientOptions: ClientOptions) : - InboundService { - - private val withRawResponse: InboundService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): InboundService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): InboundService = - InboundServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions, - ): InboundTrackEventResponse = - // post /inbound/courier - withRawResponse().trackEvent(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - InboundService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): InboundService.WithRawResponse = - InboundServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val trackEventHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun trackEvent( - params: InboundTrackEventParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("inbound", "courier") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { trackEventHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt deleted file mode 100644 index bec58f03..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListService.kt +++ /dev/null @@ -1,308 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.lists.List -import com.courier.api.models.lists.ListDeleteParams -import com.courier.api.models.lists.ListListParams -import com.courier.api.models.lists.ListListResponse -import com.courier.api.models.lists.ListRestoreParams -import com.courier.api.models.lists.ListRetrieveParams -import com.courier.api.models.lists.ListUpdateParams -import com.courier.api.services.blocking.lists.SubscriptionService -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface ListService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListService - - fun subscriptions(): SubscriptionService - - /** Returns a list based on the list ID provided. */ - fun retrieve(listId: String): List = retrieve(listId, ListRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): List = retrieve(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(listId: String, params: ListRetrieveParams = ListRetrieveParams.none()): List = - retrieve(listId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): List - - /** @see retrieve */ - fun retrieve(params: ListRetrieveParams): List = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(listId: String, requestOptions: RequestOptions): List = - retrieve(listId, ListRetrieveParams.none(), requestOptions) - - /** Create or replace an existing list with the supplied values. */ - fun update(listId: String, params: ListUpdateParams) = - update(listId, params, RequestOptions.none()) - - /** @see update */ - fun update( - listId: String, - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = update(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see update */ - fun update(params: ListUpdateParams) = update(params, RequestOptions.none()) - - /** @see update */ - fun update(params: ListUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Returns all of the lists, with the ability to filter based on a pattern. */ - fun list(): ListListResponse = list(ListListParams.none()) - - /** @see list */ - fun list( - params: ListListParams = ListListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ListListResponse - - /** @see list */ - fun list(params: ListListParams = ListListParams.none()): ListListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): ListListResponse = - list(ListListParams.none(), requestOptions) - - /** Delete a list by list ID. */ - fun delete(listId: String) = delete(listId, ListDeleteParams.none()) - - /** @see delete */ - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see delete */ - fun delete(listId: String, params: ListDeleteParams = ListDeleteParams.none()) = - delete(listId, params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: ListDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see delete */ - fun delete(params: ListDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(listId: String, requestOptions: RequestOptions) = - delete(listId, ListDeleteParams.none(), requestOptions) - - /** Restore a previously deleted list. */ - fun restore(listId: String, params: ListRestoreParams) = - restore(listId, params, RequestOptions.none()) - - /** @see restore */ - fun restore( - listId: String, - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = restore(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see restore */ - fun restore(params: ListRestoreParams) = restore(params, RequestOptions.none()) - - /** @see restore */ - fun restore(params: ListRestoreParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** A view of [ListService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListService.WithRawResponse - - fun subscriptions(): SubscriptionService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /lists/{list_id}`, but is otherwise the same as - * [ListService.retrieve]. - */ - @MustBeClosed - fun retrieve(listId: String): HttpResponseFor = - retrieve(listId, ListRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - listId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): HttpResponseFor = retrieve(listId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: ListRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve(listId: String, requestOptions: RequestOptions): HttpResponseFor = - retrieve(listId, ListRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /lists/{list_id}`, but is otherwise the same as - * [ListService.update]. - */ - @MustBeClosed - fun update(listId: String, params: ListUpdateParams): HttpResponse = - update(listId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - listId: String, - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = update(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: ListUpdateParams): HttpResponse = update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: ListUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `get /lists`, but is otherwise the same as - * [ListService.list]. - */ - @MustBeClosed fun list(): HttpResponseFor = list(ListListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: ListListParams = ListListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: ListListParams = ListListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(ListListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /lists/{list_id}`, but is otherwise the same as - * [ListService.delete]. - */ - @MustBeClosed - fun delete(listId: String): HttpResponse = delete(listId, ListDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - listId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): HttpResponse = delete(listId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see delete */ - @MustBeClosed - fun delete(params: ListDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete(listId: String, requestOptions: RequestOptions): HttpResponse = - delete(listId, ListDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /lists/{list_id}/restore`, but is otherwise the same - * as [ListService.restore]. - */ - @MustBeClosed - fun restore(listId: String, params: ListRestoreParams): HttpResponse = - restore(listId, params, RequestOptions.none()) - - /** @see restore */ - @MustBeClosed - fun restore( - listId: String, - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = restore(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see restore */ - @MustBeClosed - fun restore(params: ListRestoreParams): HttpResponse = - restore(params, RequestOptions.none()) - - /** @see restore */ - @MustBeClosed - fun restore( - params: ListRestoreParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt deleted file mode 100644 index 68e42a9e..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ListServiceImpl.kt +++ /dev/null @@ -1,219 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.lists.List -import com.courier.api.models.lists.ListDeleteParams -import com.courier.api.models.lists.ListListParams -import com.courier.api.models.lists.ListListResponse -import com.courier.api.models.lists.ListRestoreParams -import com.courier.api.models.lists.ListRetrieveParams -import com.courier.api.models.lists.ListUpdateParams -import com.courier.api.services.blocking.lists.SubscriptionService -import com.courier.api.services.blocking.lists.SubscriptionServiceImpl -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ListServiceImpl internal constructor(private val clientOptions: ClientOptions) : ListService { - - private val withRawResponse: ListService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val subscriptions: SubscriptionService by lazy { - SubscriptionServiceImpl(clientOptions) - } - - override fun withRawResponse(): ListService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ListService = - ListServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun subscriptions(): SubscriptionService = subscriptions - - override fun retrieve(params: ListRetrieveParams, requestOptions: RequestOptions): List = - // get /lists/{list_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update(params: ListUpdateParams, requestOptions: RequestOptions) { - // put /lists/{list_id} - withRawResponse().update(params, requestOptions) - } - - override fun list(params: ListListParams, requestOptions: RequestOptions): ListListResponse = - // get /lists - withRawResponse().list(params, requestOptions).parse() - - override fun delete(params: ListDeleteParams, requestOptions: RequestOptions) { - // delete /lists/{list_id} - withRawResponse().delete(params, requestOptions) - } - - override fun restore(params: ListRestoreParams, requestOptions: RequestOptions) { - // put /lists/{list_id}/restore - withRawResponse().restore(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ListService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val subscriptions: SubscriptionService.WithRawResponse by lazy { - SubscriptionServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): ListService.WithRawResponse = - ListServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun subscriptions(): SubscriptionService.WithRawResponse = subscriptions - - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: ListUpdateParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: ListListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - - private val restoreHandler: Handler = emptyHandler() - - override fun restore( - params: ListRestoreParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "restore") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { restoreHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt deleted file mode 100644 index 81ff9644..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageService.kt +++ /dev/null @@ -1,396 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.messages.MessageCancelParams -import com.courier.api.models.messages.MessageContentParams -import com.courier.api.models.messages.MessageContentResponse -import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageHistoryParams -import com.courier.api.models.messages.MessageHistoryResponse -import com.courier.api.models.messages.MessageListParams -import com.courier.api.models.messages.MessageListResponse -import com.courier.api.models.messages.MessageRetrieveParams -import com.courier.api.models.messages.MessageRetrieveResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface MessageService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): MessageService - - /** Fetch the status of a message you've previously sent. */ - fun retrieve(messageId: String): MessageRetrieveResponse = - retrieve(messageId, MessageRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageRetrieveResponse = - retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - ): MessageRetrieveResponse = retrieve(messageId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: MessageRetrieveParams): MessageRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(messageId: String, requestOptions: RequestOptions): MessageRetrieveResponse = - retrieve(messageId, MessageRetrieveParams.none(), requestOptions) - - /** Fetch the statuses of messages you've previously sent. */ - fun list(): MessageListResponse = list(MessageListParams.none()) - - /** @see list */ - fun list( - params: MessageListParams = MessageListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageListResponse - - /** @see list */ - fun list(params: MessageListParams = MessageListParams.none()): MessageListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): MessageListResponse = - list(MessageListParams.none(), requestOptions) - - /** - * Cancel a message that is currently in the process of being delivered. A well-formatted API - * call to the cancel message API will return either `200` status code for a successful - * cancellation or `409` status code for an unsuccessful cancellation. Both cases will include - * the actual message record in the response body (see details below). - */ - fun cancel(messageId: String): MessageDetails = cancel(messageId, MessageCancelParams.none()) - - /** @see cancel */ - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageDetails = cancel(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see cancel */ - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - ): MessageDetails = cancel(messageId, params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageDetails - - /** @see cancel */ - fun cancel(params: MessageCancelParams): MessageDetails = cancel(params, RequestOptions.none()) - - /** @see cancel */ - fun cancel(messageId: String, requestOptions: RequestOptions): MessageDetails = - cancel(messageId, MessageCancelParams.none(), requestOptions) - - /** Get message content */ - fun content(messageId: String): MessageContentResponse = - content(messageId, MessageContentParams.none()) - - /** @see content */ - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageContentResponse = - content(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see content */ - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - ): MessageContentResponse = content(messageId, params, RequestOptions.none()) - - /** @see content */ - fun content( - params: MessageContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageContentResponse - - /** @see content */ - fun content(params: MessageContentParams): MessageContentResponse = - content(params, RequestOptions.none()) - - /** @see content */ - fun content(messageId: String, requestOptions: RequestOptions): MessageContentResponse = - content(messageId, MessageContentParams.none(), requestOptions) - - /** Fetch the array of events of a message you've previously sent. */ - fun history(messageId: String): MessageHistoryResponse = - history(messageId, MessageHistoryParams.none()) - - /** @see history */ - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageHistoryResponse = - history(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see history */ - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - ): MessageHistoryResponse = history(messageId, params, RequestOptions.none()) - - /** @see history */ - fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): MessageHistoryResponse - - /** @see history */ - fun history(params: MessageHistoryParams): MessageHistoryResponse = - history(params, RequestOptions.none()) - - /** @see history */ - fun history(messageId: String, requestOptions: RequestOptions): MessageHistoryResponse = - history(messageId, MessageHistoryParams.none(), requestOptions) - - /** A view of [MessageService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): MessageService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /messages/{message_id}`, but is otherwise the same - * as [MessageService.retrieve]. - */ - @MustBeClosed - fun retrieve(messageId: String): HttpResponseFor = - retrieve(messageId, MessageRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - messageId: String, - params: MessageRetrieveParams = MessageRetrieveParams.none(), - ): HttpResponseFor = - retrieve(messageId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: MessageRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - messageId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(messageId, MessageRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /messages`, but is otherwise the same as - * [MessageService.list]. - */ - @MustBeClosed - fun list(): HttpResponseFor = list(MessageListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: MessageListParams = MessageListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: MessageListParams = MessageListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(MessageListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /messages/{message_id}/cancel`, but is otherwise - * the same as [MessageService.cancel]. - */ - @MustBeClosed - fun cancel(messageId: String): HttpResponseFor = - cancel(messageId, MessageCancelParams.none()) - - /** @see cancel */ - @MustBeClosed - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - cancel(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see cancel */ - @MustBeClosed - fun cancel( - messageId: String, - params: MessageCancelParams = MessageCancelParams.none(), - ): HttpResponseFor = cancel(messageId, params, RequestOptions.none()) - - /** @see cancel */ - @MustBeClosed - fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see cancel */ - @MustBeClosed - fun cancel(params: MessageCancelParams): HttpResponseFor = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - @MustBeClosed - fun cancel( - messageId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - cancel(messageId, MessageCancelParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /messages/{message_id}/output`, but is otherwise the - * same as [MessageService.content]. - */ - @MustBeClosed - fun content(messageId: String): HttpResponseFor = - content(messageId, MessageContentParams.none()) - - /** @see content */ - @MustBeClosed - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - content(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see content */ - @MustBeClosed - fun content( - messageId: String, - params: MessageContentParams = MessageContentParams.none(), - ): HttpResponseFor = - content(messageId, params, RequestOptions.none()) - - /** @see content */ - @MustBeClosed - fun content( - params: MessageContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see content */ - @MustBeClosed - fun content(params: MessageContentParams): HttpResponseFor = - content(params, RequestOptions.none()) - - /** @see content */ - @MustBeClosed - fun content( - messageId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - content(messageId, MessageContentParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /messages/{message_id}/history`, but is otherwise - * the same as [MessageService.history]. - */ - @MustBeClosed - fun history(messageId: String): HttpResponseFor = - history(messageId, MessageHistoryParams.none()) - - /** @see history */ - @MustBeClosed - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - history(params.toBuilder().messageId(messageId).build(), requestOptions) - - /** @see history */ - @MustBeClosed - fun history( - messageId: String, - params: MessageHistoryParams = MessageHistoryParams.none(), - ): HttpResponseFor = - history(messageId, params, RequestOptions.none()) - - /** @see history */ - @MustBeClosed - fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see history */ - @MustBeClosed - fun history(params: MessageHistoryParams): HttpResponseFor = - history(params, RequestOptions.none()) - - /** @see history */ - @MustBeClosed - fun history( - messageId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - history(messageId, MessageHistoryParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt deleted file mode 100644 index 5428d5e2..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/MessageServiceImpl.kt +++ /dev/null @@ -1,240 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.messages.MessageCancelParams -import com.courier.api.models.messages.MessageContentParams -import com.courier.api.models.messages.MessageContentResponse -import com.courier.api.models.messages.MessageDetails -import com.courier.api.models.messages.MessageHistoryParams -import com.courier.api.models.messages.MessageHistoryResponse -import com.courier.api.models.messages.MessageListParams -import com.courier.api.models.messages.MessageListResponse -import com.courier.api.models.messages.MessageRetrieveParams -import com.courier.api.models.messages.MessageRetrieveResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class MessageServiceImpl internal constructor(private val clientOptions: ClientOptions) : - MessageService { - - private val withRawResponse: MessageService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): MessageService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): MessageService = - MessageServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions, - ): MessageRetrieveResponse = - // get /messages/{message_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun list( - params: MessageListParams, - requestOptions: RequestOptions, - ): MessageListResponse = - // get /messages - withRawResponse().list(params, requestOptions).parse() - - override fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions, - ): MessageDetails = - // post /messages/{message_id}/cancel - withRawResponse().cancel(params, requestOptions).parse() - - override fun content( - params: MessageContentParams, - requestOptions: RequestOptions, - ): MessageContentResponse = - // get /messages/{message_id}/output - withRawResponse().content(params, requestOptions).parse() - - override fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions, - ): MessageHistoryResponse = - // get /messages/{message_id}/history - withRawResponse().history(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - MessageService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): MessageService.WithRawResponse = - MessageServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: MessageRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: MessageListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun cancel( - params: MessageCancelParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0), "cancel") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { cancelHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val contentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun content( - params: MessageContentParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0), "output") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { contentHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val historyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun history( - params: MessageHistoryParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("messageId", params.messageId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("messages", params._pathParam(0), "history") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { historyHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt deleted file mode 100644 index 6820f7d6..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationService.kt +++ /dev/null @@ -1,171 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.NotificationListParams -import com.courier.api.models.notifications.NotificationListResponse -import com.courier.api.models.notifications.NotificationRetrieveContentParams -import com.courier.api.services.blocking.notifications.CheckService -import com.courier.api.services.blocking.notifications.DraftService -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface NotificationService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): NotificationService - - fun draft(): DraftService - - fun checks(): CheckService - - fun list(): NotificationListResponse = list(NotificationListParams.none()) - - /** @see list */ - fun list( - params: NotificationListParams = NotificationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): NotificationListResponse - - /** @see list */ - fun list( - params: NotificationListParams = NotificationListParams.none() - ): NotificationListResponse = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): NotificationListResponse = - list(NotificationListParams.none(), requestOptions) - - fun retrieveContent(id: String): NotificationGetContent = - retrieveContent(id, NotificationRetrieveContentParams.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): NotificationGetContent = retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - ): NotificationGetContent = retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): NotificationGetContent - - /** @see retrieveContent */ - fun retrieveContent(params: NotificationRetrieveContentParams): NotificationGetContent = - retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent(id: String, requestOptions: RequestOptions): NotificationGetContent = - retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) - - /** - * A view of [NotificationService] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): NotificationService.WithRawResponse - - fun draft(): DraftService.WithRawResponse - - fun checks(): CheckService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /notifications`, but is otherwise the same as - * [NotificationService.list]. - */ - @MustBeClosed - fun list(): HttpResponseFor = list(NotificationListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: NotificationListParams = NotificationListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: NotificationListParams = NotificationListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(NotificationListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /notifications/{id}/content`, but is otherwise the - * same as [NotificationService.retrieveContent]. - */ - @MustBeClosed - fun retrieveContent(id: String): HttpResponseFor = - retrieveContent(id, NotificationRetrieveContentParams.none()) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - id: String, - params: NotificationRetrieveContentParams = NotificationRetrieveContentParams.none(), - ): HttpResponseFor = - retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - params: NotificationRetrieveContentParams - ): HttpResponseFor = retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - id: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieveContent(id, NotificationRetrieveContentParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt deleted file mode 100644 index a8a940c3..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/NotificationServiceImpl.kt +++ /dev/null @@ -1,145 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.NotificationListParams -import com.courier.api.models.notifications.NotificationListResponse -import com.courier.api.models.notifications.NotificationRetrieveContentParams -import com.courier.api.services.blocking.notifications.CheckService -import com.courier.api.services.blocking.notifications.CheckServiceImpl -import com.courier.api.services.blocking.notifications.DraftService -import com.courier.api.services.blocking.notifications.DraftServiceImpl -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class NotificationServiceImpl internal constructor(private val clientOptions: ClientOptions) : - NotificationService { - - private val withRawResponse: NotificationService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val draft: DraftService by lazy { DraftServiceImpl(clientOptions) } - - private val checks: CheckService by lazy { CheckServiceImpl(clientOptions) } - - override fun withRawResponse(): NotificationService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): NotificationService = - NotificationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun draft(): DraftService = draft - - override fun checks(): CheckService = checks - - override fun list( - params: NotificationListParams, - requestOptions: RequestOptions, - ): NotificationListResponse = - // get /notifications - withRawResponse().list(params, requestOptions).parse() - - override fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions, - ): NotificationGetContent = - // get /notifications/{id}/content - withRawResponse().retrieveContent(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - NotificationService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val draft: DraftService.WithRawResponse by lazy { - DraftServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val checks: CheckService.WithRawResponse by lazy { - CheckServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): NotificationService.WithRawResponse = - NotificationServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun draft(): DraftService.WithRawResponse = draft - - override fun checks(): CheckService.WithRawResponse = checks - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: NotificationListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("notifications") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveContentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveContent( - params: NotificationRetrieveContentParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("id", params.id().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("notifications", params._pathParam(0), "content") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveContentHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt deleted file mode 100644 index 0f639b57..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileService.kt +++ /dev/null @@ -1,346 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.profiles.ProfileCreateParams -import com.courier.api.models.profiles.ProfileCreateResponse -import com.courier.api.models.profiles.ProfileDeleteParams -import com.courier.api.models.profiles.ProfileReplaceParams -import com.courier.api.models.profiles.ProfileReplaceResponse -import com.courier.api.models.profiles.ProfileRetrieveParams -import com.courier.api.models.profiles.ProfileRetrieveResponse -import com.courier.api.models.profiles.ProfileUpdateParams -import com.courier.api.services.blocking.profiles.ListService -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface ProfileService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ProfileService - - fun lists(): ListService - - /** - * Merge the supplied values with an existing profile or create a new profile if one doesn't - * already exist. - */ - fun create(userId: String, params: ProfileCreateParams): ProfileCreateResponse = - create(userId, params, RequestOptions.none()) - - /** @see create */ - fun create( - userId: String, - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProfileCreateResponse = create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - fun create(params: ProfileCreateParams): ProfileCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProfileCreateResponse - - /** Returns the specified user profile. */ - fun retrieve(userId: String): ProfileRetrieveResponse = - retrieve(userId, ProfileRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ProfileRetrieveResponse = retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - ): ProfileRetrieveResponse = retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProfileRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: ProfileRetrieveParams): ProfileRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(userId: String, requestOptions: RequestOptions): ProfileRetrieveResponse = - retrieve(userId, ProfileRetrieveParams.none(), requestOptions) - - /** Update a profile */ - fun update(userId: String, params: ProfileUpdateParams) = - update(userId, params, RequestOptions.none()) - - /** @see update */ - fun update( - userId: String, - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = update(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see update */ - fun update(params: ProfileUpdateParams) = update(params, RequestOptions.none()) - - /** @see update */ - fun update(params: ProfileUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Deletes the specified user profile. */ - fun delete(userId: String) = delete(userId, ProfileDeleteParams.none()) - - /** @see delete */ - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - fun delete(userId: String, params: ProfileDeleteParams = ProfileDeleteParams.none()) = - delete(userId, params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: ProfileDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see delete */ - fun delete(params: ProfileDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(userId: String, requestOptions: RequestOptions) = - delete(userId, ProfileDeleteParams.none(), requestOptions) - - /** - * When using `PUT`, be sure to include all the key-value pairs required by the recipient's - * profile. Any key-value pairs that exist in the profile but fail to be included in the `PUT` - * request will be removed from the profile. Remember, a `PUT` update is a full replacement of - * the data. For partial updates, use the - * [Patch](https://www.courier.com/docs/reference/profiles/patch/) request. - */ - fun replace(userId: String, params: ProfileReplaceParams): ProfileReplaceResponse = - replace(userId, params, RequestOptions.none()) - - /** @see replace */ - fun replace( - userId: String, - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProfileReplaceResponse = replace(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see replace */ - fun replace(params: ProfileReplaceParams): ProfileReplaceResponse = - replace(params, RequestOptions.none()) - - /** @see replace */ - fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ProfileReplaceResponse - - /** A view of [ProfileService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ProfileService.WithRawResponse - - fun lists(): ListService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /profiles/{user_id}`, but is otherwise the same as - * [ProfileService.create]. - */ - @MustBeClosed - fun create( - userId: String, - params: ProfileCreateParams, - ): HttpResponseFor = create(userId, params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - userId: String, - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - create(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see create */ - @MustBeClosed - fun create(params: ProfileCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /profiles/{user_id}`, but is otherwise the same as - * [ProfileService.retrieve]. - */ - @MustBeClosed - fun retrieve(userId: String): HttpResponseFor = - retrieve(userId, ProfileRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - params: ProfileRetrieveParams = ProfileRetrieveParams.none(), - ): HttpResponseFor = - retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: ProfileRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(userId, ProfileRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `patch /profiles/{user_id}`, but is otherwise the same as - * [ProfileService.update]. - */ - @MustBeClosed - fun update(userId: String, params: ProfileUpdateParams): HttpResponse = - update(userId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - userId: String, - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = update(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: ProfileUpdateParams): HttpResponse = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: ProfileUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `delete /profiles/{user_id}`, but is otherwise the same - * as [ProfileService.delete]. - */ - @MustBeClosed - fun delete(userId: String): HttpResponse = delete(userId, ProfileDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - userId: String, - params: ProfileDeleteParams = ProfileDeleteParams.none(), - ): HttpResponse = delete(userId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: ProfileDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see delete */ - @MustBeClosed - fun delete(params: ProfileDeleteParams): HttpResponse = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete(userId: String, requestOptions: RequestOptions): HttpResponse = - delete(userId, ProfileDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /profiles/{user_id}`, but is otherwise the same as - * [ProfileService.replace]. - */ - @MustBeClosed - fun replace( - userId: String, - params: ProfileReplaceParams, - ): HttpResponseFor = replace(userId, params, RequestOptions.none()) - - /** @see replace */ - @MustBeClosed - fun replace( - userId: String, - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - replace(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see replace */ - @MustBeClosed - fun replace(params: ProfileReplaceParams): HttpResponseFor = - replace(params, RequestOptions.none()) - - /** @see replace */ - @MustBeClosed - fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt deleted file mode 100644 index 042ba30a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/ProfileServiceImpl.kt +++ /dev/null @@ -1,239 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.profiles.ProfileCreateParams -import com.courier.api.models.profiles.ProfileCreateResponse -import com.courier.api.models.profiles.ProfileDeleteParams -import com.courier.api.models.profiles.ProfileReplaceParams -import com.courier.api.models.profiles.ProfileReplaceResponse -import com.courier.api.models.profiles.ProfileRetrieveParams -import com.courier.api.models.profiles.ProfileRetrieveResponse -import com.courier.api.models.profiles.ProfileUpdateParams -import com.courier.api.services.blocking.profiles.ListService -import com.courier.api.services.blocking.profiles.ListServiceImpl -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ProfileServiceImpl internal constructor(private val clientOptions: ClientOptions) : - ProfileService { - - private val withRawResponse: ProfileService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val lists: ListService by lazy { ListServiceImpl(clientOptions) } - - override fun withRawResponse(): ProfileService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ProfileService = - ProfileServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun lists(): ListService = lists - - override fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions, - ): ProfileCreateResponse = - // post /profiles/{user_id} - withRawResponse().create(params, requestOptions).parse() - - override fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions, - ): ProfileRetrieveResponse = - // get /profiles/{user_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update(params: ProfileUpdateParams, requestOptions: RequestOptions) { - // patch /profiles/{user_id} - withRawResponse().update(params, requestOptions) - } - - override fun delete(params: ProfileDeleteParams, requestOptions: RequestOptions) { - // delete /profiles/{user_id} - withRawResponse().delete(params, requestOptions) - } - - override fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions, - ): ProfileReplaceResponse = - // put /profiles/{user_id} - withRawResponse().replace(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ProfileService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val lists: ListService.WithRawResponse by lazy { - ListServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): ProfileService.WithRawResponse = - ProfileServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun lists(): ListService.WithRawResponse = lists - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: ProfileCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: ProfileRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: ProfileUpdateParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: ProfileDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - - private val replaceHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun replace( - params: ProfileReplaceParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { replaceHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt deleted file mode 100644 index e9df5849..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestService.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.models.requests.RequestArchiveParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface RequestService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): RequestService - - /** Archive message */ - fun archive(requestId: String) = archive(requestId, RequestArchiveParams.none()) - - /** @see archive */ - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = archive(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see archive */ - fun archive(requestId: String, params: RequestArchiveParams = RequestArchiveParams.none()) = - archive(requestId, params, RequestOptions.none()) - - /** @see archive */ - fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** @see archive */ - fun archive(params: RequestArchiveParams) = archive(params, RequestOptions.none()) - - /** @see archive */ - fun archive(requestId: String, requestOptions: RequestOptions) = - archive(requestId, RequestArchiveParams.none(), requestOptions) - - /** A view of [RequestService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): RequestService.WithRawResponse - - /** - * Returns a raw HTTP response for `put /requests/{request_id}/archive`, but is otherwise - * the same as [RequestService.archive]. - */ - @MustBeClosed - fun archive(requestId: String): HttpResponse = - archive(requestId, RequestArchiveParams.none()) - - /** @see archive */ - @MustBeClosed - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = archive(params.toBuilder().requestId(requestId).build(), requestOptions) - - /** @see archive */ - @MustBeClosed - fun archive( - requestId: String, - params: RequestArchiveParams = RequestArchiveParams.none(), - ): HttpResponse = archive(requestId, params, RequestOptions.none()) - - /** @see archive */ - @MustBeClosed - fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see archive */ - @MustBeClosed - fun archive(params: RequestArchiveParams): HttpResponse = - archive(params, RequestOptions.none()) - - /** @see archive */ - @MustBeClosed - fun archive(requestId: String, requestOptions: RequestOptions): HttpResponse = - archive(requestId, RequestArchiveParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt deleted file mode 100644 index 275e31e5..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/RequestServiceImpl.kt +++ /dev/null @@ -1,76 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.requests.RequestArchiveParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class RequestServiceImpl internal constructor(private val clientOptions: ClientOptions) : - RequestService { - - private val withRawResponse: RequestService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): RequestService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): RequestService = - RequestServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun archive(params: RequestArchiveParams, requestOptions: RequestOptions) { - // put /requests/{request_id}/archive - withRawResponse().archive(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - RequestService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): RequestService.WithRawResponse = - RequestServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val archiveHandler: Handler = emptyHandler() - - override fun archive( - params: RequestArchiveParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("requestId", params.requestId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("requests", params._pathParam(0), "archive") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { archiveHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt index b4fd838f..ac6f2552 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt @@ -5,8 +5,8 @@ package com.courier.api.services.blocking import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.SendMessageResponse +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -25,14 +25,14 @@ interface SendService { fun withOptions(modifier: Consumer): SendService /** Use the send API to send a message to one or more recipients. */ - fun message(params: SendMessageParams): SendMessageResponse = - message(params, RequestOptions.none()) + fun sendMessage(params: SendSendMessageParams): SendSendMessageResponse = + sendMessage(params, RequestOptions.none()) - /** @see message */ - fun message( - params: SendMessageParams, + /** @see sendMessage */ + fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SendMessageResponse + ): SendSendMessageResponse /** A view of [SendService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -46,17 +46,17 @@ interface SendService { /** * Returns a raw HTTP response for `post /send`, but is otherwise the same as - * [SendService.message]. + * [SendService.sendMessage]. */ @MustBeClosed - fun message(params: SendMessageParams): HttpResponseFor = - message(params, RequestOptions.none()) + fun sendMessage(params: SendSendMessageParams): HttpResponseFor = + sendMessage(params, RequestOptions.none()) - /** @see message */ + /** @see sendMessage */ @MustBeClosed - fun message( - params: SendMessageParams, + fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt index 00735db5..74328ce2 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt @@ -15,8 +15,8 @@ import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepare -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.SendMessageResponse +import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendSendMessageResponse import java.util.function.Consumer class SendServiceImpl internal constructor(private val clientOptions: ClientOptions) : SendService { @@ -30,12 +30,12 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): SendService = SendServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun message( - params: SendMessageParams, + override fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions, - ): SendMessageResponse = + ): SendSendMessageResponse = // post /send - withRawResponse().message(params, requestOptions).parse() + withRawResponse().sendMessage(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SendService.WithRawResponse { @@ -50,13 +50,13 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) - private val messageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val sendMessageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun message( - params: SendMessageParams, + override fun sendMessage( + params: SendSendMessageParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -69,7 +69,7 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { messageHandler.handle(it) } + .use { sendMessageHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt deleted file mode 100644 index e5d1d513..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantService.kt +++ /dev/null @@ -1,354 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.tenants.Tenant -import com.courier.api.models.tenants.TenantDeleteParams -import com.courier.api.models.tenants.TenantListParams -import com.courier.api.models.tenants.TenantListResponse -import com.courier.api.models.tenants.TenantListUsersParams -import com.courier.api.models.tenants.TenantListUsersResponse -import com.courier.api.models.tenants.TenantRetrieveParams -import com.courier.api.models.tenants.TenantUpdateParams -import com.courier.api.services.blocking.tenants.DefaultPreferenceService -import com.courier.api.services.blocking.tenants.TemplateService -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface TenantService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TenantService - - fun defaultPreferences(): DefaultPreferenceService - - fun templates(): TemplateService - - /** Get a Tenant */ - fun retrieve(tenantId: String): Tenant = retrieve(tenantId, TenantRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): Tenant = retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - ): Tenant = retrieve(tenantId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Tenant - - /** @see retrieve */ - fun retrieve(params: TenantRetrieveParams): Tenant = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(tenantId: String, requestOptions: RequestOptions): Tenant = - retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) - - /** Create or Replace a Tenant */ - fun update(tenantId: String, params: TenantUpdateParams): Tenant = - update(tenantId, params, RequestOptions.none()) - - /** @see update */ - fun update( - tenantId: String, - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Tenant = update(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see update */ - fun update(params: TenantUpdateParams): Tenant = update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): Tenant - - /** Get a List of Tenants */ - fun list(): TenantListResponse = list(TenantListParams.none()) - - /** @see list */ - fun list( - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): TenantListResponse - - /** @see list */ - fun list(params: TenantListParams = TenantListParams.none()): TenantListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): TenantListResponse = - list(TenantListParams.none(), requestOptions) - - /** Delete a Tenant */ - fun delete(tenantId: String) = delete(tenantId, TenantDeleteParams.none()) - - /** @see delete */ - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see delete */ - fun delete(tenantId: String, params: TenantDeleteParams = TenantDeleteParams.none()) = - delete(tenantId, params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: TenantDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** @see delete */ - fun delete(params: TenantDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(tenantId: String, requestOptions: RequestOptions) = - delete(tenantId, TenantDeleteParams.none(), requestOptions) - - /** Get Users in Tenant */ - fun listUsers(tenantId: String): TenantListUsersResponse = - listUsers(tenantId, TenantListUsersParams.none()) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): TenantListUsersResponse = - listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see listUsers */ - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - ): TenantListUsersResponse = listUsers(tenantId, params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TenantListUsersResponse - - /** @see listUsers */ - fun listUsers(params: TenantListUsersParams): TenantListUsersResponse = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - fun listUsers(tenantId: String, requestOptions: RequestOptions): TenantListUsersResponse = - listUsers(tenantId, TenantListUsersParams.none(), requestOptions) - - /** A view of [TenantService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TenantService.WithRawResponse - - fun defaultPreferences(): DefaultPreferenceService.WithRawResponse - - fun templates(): TemplateService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}`, but is otherwise the same as - * [TenantService.retrieve]. - */ - @MustBeClosed - fun retrieve(tenantId: String): HttpResponseFor = - retrieve(tenantId, TenantRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - tenantId: String, - params: TenantRetrieveParams = TenantRetrieveParams.none(), - ): HttpResponseFor = retrieve(tenantId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: TenantRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve(tenantId: String, requestOptions: RequestOptions): HttpResponseFor = - retrieve(tenantId, TenantRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /tenants/{tenant_id}`, but is otherwise the same as - * [TenantService.update]. - */ - @MustBeClosed - fun update(tenantId: String, params: TenantUpdateParams): HttpResponseFor = - update(tenantId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - tenantId: String, - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: TenantUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /tenants`, but is otherwise the same as - * [TenantService.list]. - */ - @MustBeClosed - fun list(): HttpResponseFor = list(TenantListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list( - params: TenantListParams = TenantListParams.none() - ): HttpResponseFor = list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(TenantListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /tenants/{tenant_id}`, but is otherwise the same - * as [TenantService.delete]. - */ - @MustBeClosed - fun delete(tenantId: String): HttpResponse = delete(tenantId, TenantDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - tenantId: String, - params: TenantDeleteParams = TenantDeleteParams.none(), - ): HttpResponse = delete(tenantId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: TenantDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see delete */ - @MustBeClosed - fun delete(params: TenantDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete(tenantId: String, requestOptions: RequestOptions): HttpResponse = - delete(tenantId, TenantDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}/users`, but is otherwise the - * same as [TenantService.listUsers]. - */ - @MustBeClosed - fun listUsers(tenantId: String): HttpResponseFor = - listUsers(tenantId, TenantListUsersParams.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - listUsers(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - tenantId: String, - params: TenantListUsersParams = TenantListUsersParams.none(), - ): HttpResponseFor = - listUsers(tenantId, params, RequestOptions.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see listUsers */ - @MustBeClosed - fun listUsers(params: TenantListUsersParams): HttpResponseFor = - listUsers(params, RequestOptions.none()) - - /** @see listUsers */ - @MustBeClosed - fun listUsers( - tenantId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - listUsers(tenantId, TenantListUsersParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt deleted file mode 100644 index 4ebe012a..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TenantServiceImpl.kt +++ /dev/null @@ -1,250 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.tenants.Tenant -import com.courier.api.models.tenants.TenantDeleteParams -import com.courier.api.models.tenants.TenantListParams -import com.courier.api.models.tenants.TenantListResponse -import com.courier.api.models.tenants.TenantListUsersParams -import com.courier.api.models.tenants.TenantListUsersResponse -import com.courier.api.models.tenants.TenantRetrieveParams -import com.courier.api.models.tenants.TenantUpdateParams -import com.courier.api.services.blocking.tenants.DefaultPreferenceService -import com.courier.api.services.blocking.tenants.DefaultPreferenceServiceImpl -import com.courier.api.services.blocking.tenants.TemplateService -import com.courier.api.services.blocking.tenants.TemplateServiceImpl -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TenantServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TenantService { - - private val withRawResponse: TenantService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val defaultPreferences: DefaultPreferenceService by lazy { - DefaultPreferenceServiceImpl(clientOptions) - } - - private val templates: TemplateService by lazy { TemplateServiceImpl(clientOptions) } - - override fun withRawResponse(): TenantService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TenantService = - TenantServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun defaultPreferences(): DefaultPreferenceService = defaultPreferences - - override fun templates(): TemplateService = templates - - override fun retrieve(params: TenantRetrieveParams, requestOptions: RequestOptions): Tenant = - // get /tenants/{tenant_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update(params: TenantUpdateParams, requestOptions: RequestOptions): Tenant = - // put /tenants/{tenant_id} - withRawResponse().update(params, requestOptions).parse() - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): TenantListResponse = - // get /tenants - withRawResponse().list(params, requestOptions).parse() - - override fun delete(params: TenantDeleteParams, requestOptions: RequestOptions) { - // delete /tenants/{tenant_id} - withRawResponse().delete(params, requestOptions) - } - - override fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions, - ): TenantListUsersResponse = - // get /tenants/{tenant_id}/users - withRawResponse().listUsers(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TenantService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val defaultPreferences: DefaultPreferenceService.WithRawResponse by lazy { - DefaultPreferenceServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val templates: TemplateService.WithRawResponse by lazy { - TemplateServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): TenantService.WithRawResponse = - TenantServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun defaultPreferences(): DefaultPreferenceService.WithRawResponse = - defaultPreferences - - override fun templates(): TemplateService.WithRawResponse = templates - - private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TenantRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: TenantUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: TenantDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - - private val listUsersHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun listUsers( - params: TenantListUsersParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0), "users") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listUsersHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt deleted file mode 100644 index ab880724..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationService.kt +++ /dev/null @@ -1,140 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.translations.TranslationRetrieveParams -import com.courier.api.models.translations.TranslationUpdateParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface TranslationService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TranslationService - - /** Get translations by locale */ - fun retrieve(locale: String, params: TranslationRetrieveParams): String = - retrieve(locale, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - locale: String, - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): String = retrieve(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: TranslationRetrieveParams): String = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): String - - /** Update a translation */ - fun update(locale: String, params: TranslationUpdateParams) = - update(locale, params, RequestOptions.none()) - - /** @see update */ - fun update( - locale: String, - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = update(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see update */ - fun update(params: TranslationUpdateParams) = update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** - * A view of [TranslationService] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): TranslationService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /translations/{domain}/{locale}`, but is otherwise - * the same as [TranslationService.retrieve]. - */ - @MustBeClosed - fun retrieve(locale: String, params: TranslationRetrieveParams): HttpResponseFor = - retrieve(locale, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - locale: String, - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: TranslationRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `put /translations/{domain}/{locale}`, but is otherwise - * the same as [TranslationService.update]. - */ - @MustBeClosed - fun update(locale: String, params: TranslationUpdateParams): HttpResponse = - update(locale, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - locale: String, - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = update(params.toBuilder().locale(locale).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: TranslationUpdateParams): HttpResponse = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt deleted file mode 100644 index c85efd33..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/TranslationServiceImpl.kt +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.stringHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.translations.TranslationRetrieveParams -import com.courier.api.models.translations.TranslationUpdateParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TranslationServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TranslationService { - - private val withRawResponse: TranslationService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TranslationService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TranslationService = - TranslationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions, - ): String = - // get /translations/{domain}/{locale} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update(params: TranslationUpdateParams, requestOptions: RequestOptions) { - // put /translations/{domain}/{locale} - withRawResponse().update(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TranslationService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TranslationService.WithRawResponse = - TranslationServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = stringHandler() - - override fun retrieve( - params: TranslationRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("locale", params.locale().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { retrieveHandler.handle(it) } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: TranslationUpdateParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("locale", params.locale().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("translations", params._pathParam(0), params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt deleted file mode 100644 index 6c224ad7..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserService.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.users.PreferenceService -import com.courier.api.services.blocking.users.TenantService -import com.courier.api.services.blocking.users.TokenService -import java.util.function.Consumer - -interface UserService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): UserService - - fun preferences(): PreferenceService - - fun tenants(): TenantService - - fun tokens(): TokenService - - /** A view of [UserService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): UserService.WithRawResponse - - fun preferences(): PreferenceService.WithRawResponse - - fun tenants(): TenantService.WithRawResponse - - fun tokens(): TokenService.WithRawResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt deleted file mode 100644 index eb048d51..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/UserServiceImpl.kt +++ /dev/null @@ -1,65 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.users.PreferenceService -import com.courier.api.services.blocking.users.PreferenceServiceImpl -import com.courier.api.services.blocking.users.TenantService -import com.courier.api.services.blocking.users.TenantServiceImpl -import com.courier.api.services.blocking.users.TokenService -import com.courier.api.services.blocking.users.TokenServiceImpl -import java.util.function.Consumer - -class UserServiceImpl internal constructor(private val clientOptions: ClientOptions) : UserService { - - private val withRawResponse: UserService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val preferences: PreferenceService by lazy { PreferenceServiceImpl(clientOptions) } - - private val tenants: TenantService by lazy { TenantServiceImpl(clientOptions) } - - private val tokens: TokenService by lazy { TokenServiceImpl(clientOptions) } - - override fun withRawResponse(): UserService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): UserService = - UserServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun preferences(): PreferenceService = preferences - - override fun tenants(): TenantService = tenants - - override fun tokens(): TokenService = tokens - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - UserService.WithRawResponse { - - private val preferences: PreferenceService.WithRawResponse by lazy { - PreferenceServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val tenants: TenantService.WithRawResponse by lazy { - TenantServiceImpl.WithRawResponseImpl(clientOptions) - } - - private val tokens: TokenService.WithRawResponse by lazy { - TokenServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): UserService.WithRawResponse = - UserServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun preferences(): PreferenceService.WithRawResponse = preferences - - override fun tenants(): TenantService.WithRawResponse = tenants - - override fun tokens(): TokenService.WithRawResponse = tokens - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt deleted file mode 100644 index 14b7bf3c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeService.kt +++ /dev/null @@ -1,126 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.automations - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.automations.invoke.AutomationInvokeResponse -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams -import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface InvokeService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): InvokeService - - /** - * Invoke an ad hoc automation run. This endpoint accepts a JSON payload with a series of - * automation steps. For information about what steps are available, checkout the ad hoc - * automation guide [here](https://www.courier.com/docs/automations/steps/). - */ - fun invokeAdHoc(params: InvokeInvokeAdHocParams): AutomationInvokeResponse = - invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AutomationInvokeResponse - - /** Invoke an automation run from an automation template. */ - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - ): AutomationInvokeResponse = invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AutomationInvokeResponse = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - fun invokeByTemplate(params: InvokeInvokeByTemplateParams): AutomationInvokeResponse = - invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): AutomationInvokeResponse - - /** A view of [InvokeService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): InvokeService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /automations/invoke`, but is otherwise the same as - * [InvokeService.invokeAdHoc]. - */ - @MustBeClosed - fun invokeAdHoc( - params: InvokeInvokeAdHocParams - ): HttpResponseFor = invokeAdHoc(params, RequestOptions.none()) - - /** @see invokeAdHoc */ - @MustBeClosed - fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `post /automations/{templateId}/invoke`, but is otherwise - * the same as [InvokeService.invokeByTemplate]. - */ - @MustBeClosed - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - ): HttpResponseFor = - invokeByTemplate(templateId, params, RequestOptions.none()) - - /** @see invokeByTemplate */ - @MustBeClosed - fun invokeByTemplate( - templateId: String, - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - invokeByTemplate(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see invokeByTemplate */ - @MustBeClosed - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams - ): HttpResponseFor = - invokeByTemplate(params, RequestOptions.none()) - - /** @see invokeByTemplate */ - @MustBeClosed - fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt deleted file mode 100644 index 1501be4c..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/automations/InvokeServiceImpl.kt +++ /dev/null @@ -1,123 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.automations - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.automations.invoke.AutomationInvokeResponse -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams -import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class InvokeServiceImpl internal constructor(private val clientOptions: ClientOptions) : - InvokeService { - - private val withRawResponse: InvokeService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): InvokeService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): InvokeService = - InvokeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions, - ): AutomationInvokeResponse = - // post /automations/invoke - withRawResponse().invokeAdHoc(params, requestOptions).parse() - - override fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions, - ): AutomationInvokeResponse = - // post /automations/{templateId}/invoke - withRawResponse().invokeByTemplate(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - InvokeService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): InvokeService.WithRawResponse = - InvokeServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val invokeAdHocHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeAdHoc( - params: InvokeInvokeAdHocParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { invokeAdHocHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val invokeByTemplateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun invokeByTemplate( - params: InvokeInvokeByTemplateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("templateId", params.templateId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("automations", params._pathParam(0), "invoke") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { invokeByTemplateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt deleted file mode 100644 index 0b0d9a43..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionService.kt +++ /dev/null @@ -1,321 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.lists - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.lists.subscriptions.SubscriptionAddParams -import com.courier.api.models.lists.subscriptions.SubscriptionListParams -import com.courier.api.models.lists.subscriptions.SubscriptionListResponse -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams -import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface SubscriptionService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): SubscriptionService - - /** Get the list's subscriptions. */ - fun list(listId: String): SubscriptionListResponse = list(listId, SubscriptionListParams.none()) - - /** @see list */ - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionListResponse = list(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see list */ - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - ): SubscriptionListResponse = list(listId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): SubscriptionListResponse - - /** @see list */ - fun list(params: SubscriptionListParams): SubscriptionListResponse = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(listId: String, requestOptions: RequestOptions): SubscriptionListResponse = - list(listId, SubscriptionListParams.none(), requestOptions) - - /** - * Subscribes additional users to the list, without modifying existing subscriptions. If the - * list does not exist, it will be automatically created. - */ - fun add(listId: String, params: SubscriptionAddParams) = - add(listId, params, RequestOptions.none()) - - /** @see add */ - fun add( - listId: String, - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = add(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see add */ - fun add(params: SubscriptionAddParams) = add(params, RequestOptions.none()) - - /** @see add */ - fun add(params: SubscriptionAddParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** - * Subscribes the users to the list, overwriting existing subscriptions. If the list does not - * exist, it will be automatically created. - */ - fun subscribe(listId: String, params: SubscriptionSubscribeParams) = - subscribe(listId, params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - listId: String, - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = subscribe(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see subscribe */ - fun subscribe(params: SubscriptionSubscribeParams) = subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** - * Subscribe a user to an existing list (note: if the List does not exist, it will be - * automatically created). - */ - fun subscribeUser(userId: String, params: SubscriptionSubscribeUserParams) = - subscribeUser(userId, params, RequestOptions.none()) - - /** @see subscribeUser */ - fun subscribeUser( - userId: String, - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribeUser */ - fun subscribeUser(params: SubscriptionSubscribeUserParams) = - subscribeUser(params, RequestOptions.none()) - - /** @see subscribeUser */ - fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** Delete a subscription to a list by list ID and user ID. */ - fun unsubscribeUser(userId: String, params: SubscriptionUnsubscribeUserParams) = - unsubscribeUser(userId, params, RequestOptions.none()) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see unsubscribeUser */ - fun unsubscribeUser(params: SubscriptionUnsubscribeUserParams) = - unsubscribeUser(params, RequestOptions.none()) - - /** @see unsubscribeUser */ - fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** - * A view of [SubscriptionService] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): SubscriptionService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /lists/{list_id}/subscriptions`, but is otherwise - * the same as [SubscriptionService.list]. - */ - @MustBeClosed - fun list(listId: String): HttpResponseFor = - list(listId, SubscriptionListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - list(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list( - listId: String, - params: SubscriptionListParams = SubscriptionListParams.none(), - ): HttpResponseFor = list(listId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: SubscriptionListParams): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - listId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - list(listId, SubscriptionListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /lists/{list_id}/subscriptions`, but is otherwise - * the same as [SubscriptionService.add]. - */ - @MustBeClosed - fun add(listId: String, params: SubscriptionAddParams): HttpResponse = - add(listId, params, RequestOptions.none()) - - /** @see add */ - @MustBeClosed - fun add( - listId: String, - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = add(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see add */ - @MustBeClosed - fun add(params: SubscriptionAddParams): HttpResponse = add(params, RequestOptions.none()) - - /** @see add */ - @MustBeClosed - fun add( - params: SubscriptionAddParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions`, but is otherwise - * the same as [SubscriptionService.subscribe]. - */ - @MustBeClosed - fun subscribe(listId: String, params: SubscriptionSubscribeParams): HttpResponse = - subscribe(listId, params, RequestOptions.none()) - - /** @see subscribe */ - @MustBeClosed - fun subscribe( - listId: String, - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = subscribe(params.toBuilder().listId(listId).build(), requestOptions) - - /** @see subscribe */ - @MustBeClosed - fun subscribe(params: SubscriptionSubscribeParams): HttpResponse = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - @MustBeClosed - fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `put /lists/{list_id}/subscriptions/{user_id}`, but is - * otherwise the same as [SubscriptionService.subscribeUser]. - */ - @MustBeClosed - fun subscribeUser(userId: String, params: SubscriptionSubscribeUserParams): HttpResponse = - subscribeUser(userId, params, RequestOptions.none()) - - /** @see subscribeUser */ - @MustBeClosed - fun subscribeUser( - userId: String, - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = subscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribeUser */ - @MustBeClosed - fun subscribeUser(params: SubscriptionSubscribeUserParams): HttpResponse = - subscribeUser(params, RequestOptions.none()) - - /** @see subscribeUser */ - @MustBeClosed - fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `delete /lists/{list_id}/subscriptions/{user_id}`, but is - * otherwise the same as [SubscriptionService.unsubscribeUser]. - */ - @MustBeClosed - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - ): HttpResponse = unsubscribeUser(userId, params, RequestOptions.none()) - - /** @see unsubscribeUser */ - @MustBeClosed - fun unsubscribeUser( - userId: String, - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = unsubscribeUser(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see unsubscribeUser */ - @MustBeClosed - fun unsubscribeUser(params: SubscriptionUnsubscribeUserParams): HttpResponse = - unsubscribeUser(params, RequestOptions.none()) - - /** @see unsubscribeUser */ - @MustBeClosed - fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt deleted file mode 100644 index 62e4bab9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceImpl.kt +++ /dev/null @@ -1,223 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.lists - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.lists.subscriptions.SubscriptionAddParams -import com.courier.api.models.lists.subscriptions.SubscriptionListParams -import com.courier.api.models.lists.subscriptions.SubscriptionListResponse -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams -import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class SubscriptionServiceImpl internal constructor(private val clientOptions: ClientOptions) : - SubscriptionService { - - private val withRawResponse: SubscriptionService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): SubscriptionService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): SubscriptionService = - SubscriptionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions, - ): SubscriptionListResponse = - // get /lists/{list_id}/subscriptions - withRawResponse().list(params, requestOptions).parse() - - override fun add(params: SubscriptionAddParams, requestOptions: RequestOptions) { - // post /lists/{list_id}/subscriptions - withRawResponse().add(params, requestOptions) - } - - override fun subscribe(params: SubscriptionSubscribeParams, requestOptions: RequestOptions) { - // put /lists/{list_id}/subscriptions - withRawResponse().subscribe(params, requestOptions) - } - - override fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions, - ) { - // put /lists/{list_id}/subscriptions/{user_id} - withRawResponse().subscribeUser(params, requestOptions) - } - - override fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions, - ) { - // delete /lists/{list_id}/subscriptions/{user_id} - withRawResponse().unsubscribeUser(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - SubscriptionService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): SubscriptionService.WithRawResponse = - SubscriptionServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: SubscriptionListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "subscriptions") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val addHandler: Handler = emptyHandler() - - override fun add( - params: SubscriptionAddParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "subscriptions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { addHandler.handle(it) } - } - } - - private val subscribeHandler: Handler = emptyHandler() - - override fun subscribe( - params: SubscriptionSubscribeParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("listId", params.listId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("lists", params._pathParam(0), "subscriptions") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { subscribeHandler.handle(it) } - } - } - - private val subscribeUserHandler: Handler = emptyHandler() - - override fun subscribeUser( - params: SubscriptionSubscribeUserParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "lists", - params._pathParam(0), - "subscriptions", - params._pathParam(1), - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { subscribeUserHandler.handle(it) } - } - } - - private val unsubscribeUserHandler: Handler = emptyHandler() - - override fun unsubscribeUser( - params: SubscriptionUnsubscribeUserParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "lists", - params._pathParam(0), - "subscriptions", - params._pathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { unsubscribeUserHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt deleted file mode 100644 index 407b8af0..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckService.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.notifications.checks.CheckDeleteParams -import com.courier.api.models.notifications.checks.CheckListParams -import com.courier.api.models.notifications.checks.CheckListResponse -import com.courier.api.models.notifications.checks.CheckUpdateParams -import com.courier.api.models.notifications.checks.CheckUpdateResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface CheckService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CheckService - - fun update(submissionId: String, params: CheckUpdateParams): CheckUpdateResponse = - update(submissionId, params, RequestOptions.none()) - - /** @see update */ - fun update( - submissionId: String, - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CheckUpdateResponse = - update(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see update */ - fun update(params: CheckUpdateParams): CheckUpdateResponse = - update(params, RequestOptions.none()) - - /** @see update */ - fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CheckUpdateResponse - - fun list(submissionId: String, params: CheckListParams): CheckListResponse = - list(submissionId, params, RequestOptions.none()) - - /** @see list */ - fun list( - submissionId: String, - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CheckListResponse = - list(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see list */ - fun list(params: CheckListParams): CheckListResponse = list(params, RequestOptions.none()) - - /** @see list */ - fun list( - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CheckListResponse - - fun delete(submissionId: String, params: CheckDeleteParams) = - delete(submissionId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - submissionId: String, - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see delete */ - fun delete(params: CheckDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: CheckDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** A view of [CheckService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CheckService.WithRawResponse - - /** - * Returns a raw HTTP response for `put /notifications/{id}/{submissionId}/checks`, but is - * otherwise the same as [CheckService.update]. - */ - @MustBeClosed - fun update( - submissionId: String, - params: CheckUpdateParams, - ): HttpResponseFor = - update(submissionId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - submissionId: String, - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - update(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: CheckUpdateParams): HttpResponseFor = - update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /notifications/{id}/{submissionId}/checks`, but is - * otherwise the same as [CheckService.list]. - */ - @MustBeClosed - fun list( - submissionId: String, - params: CheckListParams, - ): HttpResponseFor = list(submissionId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - submissionId: String, - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - list(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list(params: CheckListParams): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: CheckListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `delete /notifications/{id}/{submissionId}/checks`, but - * is otherwise the same as [CheckService.delete]. - */ - @MustBeClosed - fun delete(submissionId: String, params: CheckDeleteParams): HttpResponse = - delete(submissionId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - submissionId: String, - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = - delete(params.toBuilder().submissionId(submissionId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete(params: CheckDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: CheckDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt deleted file mode 100644 index 682835ba..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/CheckServiceImpl.kt +++ /dev/null @@ -1,169 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.notifications.checks.CheckDeleteParams -import com.courier.api.models.notifications.checks.CheckListParams -import com.courier.api.models.notifications.checks.CheckListResponse -import com.courier.api.models.notifications.checks.CheckUpdateParams -import com.courier.api.models.notifications.checks.CheckUpdateResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class CheckServiceImpl internal constructor(private val clientOptions: ClientOptions) : - CheckService { - - private val withRawResponse: CheckService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): CheckService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): CheckService = - CheckServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions, - ): CheckUpdateResponse = - // put /notifications/{id}/{submissionId}/checks - withRawResponse().update(params, requestOptions).parse() - - override fun list(params: CheckListParams, requestOptions: RequestOptions): CheckListResponse = - // get /notifications/{id}/{submissionId}/checks - withRawResponse().list(params, requestOptions).parse() - - override fun delete(params: CheckDeleteParams, requestOptions: RequestOptions) { - // delete /notifications/{id}/{submissionId}/checks - withRawResponse().delete(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - CheckService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): CheckService.WithRawResponse = - CheckServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val updateHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun update( - params: CheckUpdateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("submissionId", params.submissionId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "notifications", - params._pathParam(0), - params._pathParam(1), - "checks", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { updateHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: CheckListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("submissionId", params.submissionId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "notifications", - params._pathParam(0), - params._pathParam(1), - "checks", - ) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: CheckDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("submissionId", params.submissionId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "notifications", - params._pathParam(0), - params._pathParam(1), - "checks", - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt deleted file mode 100644 index ce4dc76f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftService.kt +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.draft.DraftRetrieveContentParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface DraftService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): DraftService - - fun retrieveContent(id: String): NotificationGetContent = - retrieveContent(id, DraftRetrieveContentParams.none()) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): NotificationGetContent = retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - ): NotificationGetContent = retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): NotificationGetContent - - /** @see retrieveContent */ - fun retrieveContent(params: DraftRetrieveContentParams): NotificationGetContent = - retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - fun retrieveContent(id: String, requestOptions: RequestOptions): NotificationGetContent = - retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) - - /** A view of [DraftService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): DraftService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /notifications/{id}/draft/content`, but is otherwise - * the same as [DraftService.retrieveContent]. - */ - @MustBeClosed - fun retrieveContent(id: String): HttpResponseFor = - retrieveContent(id, DraftRetrieveContentParams.none()) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveContent(params.toBuilder().id(id).build(), requestOptions) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - id: String, - params: DraftRetrieveContentParams = DraftRetrieveContentParams.none(), - ): HttpResponseFor = - retrieveContent(id, params, RequestOptions.none()) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - params: DraftRetrieveContentParams - ): HttpResponseFor = retrieveContent(params, RequestOptions.none()) - - /** @see retrieveContent */ - @MustBeClosed - fun retrieveContent( - id: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieveContent(id, DraftRetrieveContentParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt deleted file mode 100644 index 695d2c99..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/notifications/DraftServiceImpl.kt +++ /dev/null @@ -1,85 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.notifications - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.notifications.NotificationGetContent -import com.courier.api.models.notifications.draft.DraftRetrieveContentParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class DraftServiceImpl internal constructor(private val clientOptions: ClientOptions) : - DraftService { - - private val withRawResponse: DraftService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): DraftService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): DraftService = - DraftServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions, - ): NotificationGetContent = - // get /notifications/{id}/draft/content - withRawResponse().retrieveContent(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DraftService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): DraftService.WithRawResponse = - DraftServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveContentHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveContent( - params: DraftRetrieveContentParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("id", params.id().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("notifications", params._pathParam(0), "draft", "content") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveContentHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt deleted file mode 100644 index 1b552764..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListService.kt +++ /dev/null @@ -1,243 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.profiles - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.profiles.lists.ListDeleteParams -import com.courier.api.models.profiles.lists.ListDeleteResponse -import com.courier.api.models.profiles.lists.ListRetrieveParams -import com.courier.api.models.profiles.lists.ListRetrieveResponse -import com.courier.api.models.profiles.lists.ListSubscribeParams -import com.courier.api.models.profiles.lists.ListSubscribeResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface ListService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListService - - /** Returns the subscribed lists for a specified user. */ - fun retrieve(userId: String): ListRetrieveResponse = retrieve(userId, ListRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ListRetrieveResponse = retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): ListRetrieveResponse = retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ListRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: ListRetrieveParams): ListRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(userId: String, requestOptions: RequestOptions): ListRetrieveResponse = - retrieve(userId, ListRetrieveParams.none(), requestOptions) - - /** Removes all list subscriptions for given user. */ - fun delete(userId: String): ListDeleteResponse = delete(userId, ListDeleteParams.none()) - - /** @see delete */ - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): ListDeleteResponse = delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): ListDeleteResponse = delete(userId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ListDeleteResponse - - /** @see delete */ - fun delete(params: ListDeleteParams): ListDeleteResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(userId: String, requestOptions: RequestOptions): ListDeleteResponse = - delete(userId, ListDeleteParams.none(), requestOptions) - - /** - * Subscribes the given user to one or more lists. If the list does not exist, it will be - * created. - */ - fun subscribe(userId: String, params: ListSubscribeParams): ListSubscribeResponse = - subscribe(userId, params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - userId: String, - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ListSubscribeResponse = subscribe(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribe */ - fun subscribe(params: ListSubscribeParams): ListSubscribeResponse = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): ListSubscribeResponse - - /** A view of [ListService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ListService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /profiles/{user_id}/lists`, but is otherwise the - * same as [ListService.retrieve]. - */ - @MustBeClosed - fun retrieve(userId: String): HttpResponseFor = - retrieve(userId, ListRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - params: ListRetrieveParams = ListRetrieveParams.none(), - ): HttpResponseFor = retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: ListRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(userId, ListRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /profiles/{user_id}/lists`, but is otherwise the - * same as [ListService.delete]. - */ - @MustBeClosed - fun delete(userId: String): HttpResponseFor = - delete(userId, ListDeleteParams.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - delete(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete( - userId: String, - params: ListDeleteParams = ListDeleteParams.none(), - ): HttpResponseFor = delete(userId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see delete */ - @MustBeClosed - fun delete(params: ListDeleteParams): HttpResponseFor = - delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - userId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - delete(userId, ListDeleteParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /profiles/{user_id}/lists`, but is otherwise the - * same as [ListService.subscribe]. - */ - @MustBeClosed - fun subscribe( - userId: String, - params: ListSubscribeParams, - ): HttpResponseFor = subscribe(userId, params, RequestOptions.none()) - - /** @see subscribe */ - @MustBeClosed - fun subscribe( - userId: String, - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - subscribe(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see subscribe */ - @MustBeClosed - fun subscribe(params: ListSubscribeParams): HttpResponseFor = - subscribe(params, RequestOptions.none()) - - /** @see subscribe */ - @MustBeClosed - fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt deleted file mode 100644 index 3ba26fa7..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/profiles/ListServiceImpl.kt +++ /dev/null @@ -1,165 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.profiles - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.profiles.lists.ListDeleteParams -import com.courier.api.models.profiles.lists.ListDeleteResponse -import com.courier.api.models.profiles.lists.ListRetrieveParams -import com.courier.api.models.profiles.lists.ListRetrieveResponse -import com.courier.api.models.profiles.lists.ListSubscribeParams -import com.courier.api.models.profiles.lists.ListSubscribeResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ListServiceImpl internal constructor(private val clientOptions: ClientOptions) : ListService { - - private val withRawResponse: ListService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): ListService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ListService = - ListServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): ListRetrieveResponse = - // get /profiles/{user_id}/lists - withRawResponse().retrieve(params, requestOptions).parse() - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): ListDeleteResponse = - // delete /profiles/{user_id}/lists - withRawResponse().delete(params, requestOptions).parse() - - override fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions, - ): ListSubscribeResponse = - // post /profiles/{user_id}/lists - withRawResponse().subscribe(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ListService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): ListService.WithRawResponse = - ListServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: ListRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0), "lists") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val deleteHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun delete( - params: ListDeleteParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0), "lists") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { deleteHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val subscribeHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun subscribe( - params: ListSubscribeParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("profiles", params._pathParam(0), "lists") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { subscribeHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt deleted file mode 100644 index d441fba9..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceService.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.tenants.defaultpreferences.ItemService -import java.util.function.Consumer - -interface DefaultPreferenceService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): DefaultPreferenceService - - fun items(): ItemService - - /** - * A view of [DefaultPreferenceService] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): DefaultPreferenceService.WithRawResponse - - fun items(): ItemService.WithRawResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt deleted file mode 100644 index 9d7b8c15..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/DefaultPreferenceServiceImpl.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.services.blocking.tenants.defaultpreferences.ItemService -import com.courier.api.services.blocking.tenants.defaultpreferences.ItemServiceImpl -import java.util.function.Consumer - -class DefaultPreferenceServiceImpl internal constructor(private val clientOptions: ClientOptions) : - DefaultPreferenceService { - - private val withRawResponse: DefaultPreferenceService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val items: ItemService by lazy { ItemServiceImpl(clientOptions) } - - override fun withRawResponse(): DefaultPreferenceService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): DefaultPreferenceService = - DefaultPreferenceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun items(): ItemService = items - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - DefaultPreferenceService.WithRawResponse { - - private val items: ItemService.WithRawResponse by lazy { - ItemServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): DefaultPreferenceService.WithRawResponse = - DefaultPreferenceServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun items(): ItemService.WithRawResponse = items - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt deleted file mode 100644 index 95f8bc9b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateService.kt +++ /dev/null @@ -1,169 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation -import com.courier.api.models.tenants.templates.TemplateListParams -import com.courier.api.models.tenants.templates.TemplateListResponse -import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface TemplateService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TemplateService - - /** Get a Template in Tenant */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - ): BaseTemplateTenantAssociation = retrieve(templateId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BaseTemplateTenantAssociation = - retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: TemplateRetrieveParams): BaseTemplateTenantAssociation = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BaseTemplateTenantAssociation - - /** List Templates in Tenant */ - fun list(tenantId: String): TemplateListResponse = list(tenantId, TemplateListParams.none()) - - /** @see list */ - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): TemplateListResponse = list(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see list */ - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - ): TemplateListResponse = list(tenantId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TemplateListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TemplateListResponse - - /** @see list */ - fun list(params: TemplateListParams): TemplateListResponse = list(params, RequestOptions.none()) - - /** @see list */ - fun list(tenantId: String, requestOptions: RequestOptions): TemplateListResponse = - list(tenantId, TemplateListParams.none(), requestOptions) - - /** A view of [TemplateService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TemplateService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates/{template_id}`, but - * is otherwise the same as [TemplateService.retrieve]. - */ - @MustBeClosed - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - ): HttpResponseFor = - retrieve(templateId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - templateId: String, - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().templateId(templateId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: TemplateRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /tenants/{tenant_id}/templates`, but is otherwise - * the same as [TemplateService.list]. - */ - @MustBeClosed - fun list(tenantId: String): HttpResponseFor = - list(tenantId, TemplateListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - list(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list( - tenantId: String, - params: TemplateListParams = TemplateListParams.none(), - ): HttpResponseFor = list(tenantId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: TemplateListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: TemplateListParams): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - tenantId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - list(tenantId, TemplateListParams.none(), requestOptions) - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt deleted file mode 100644 index 71d74426..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceImpl.kt +++ /dev/null @@ -1,129 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.tenants.templates.BaseTemplateTenantAssociation -import com.courier.api.models.tenants.templates.TemplateListParams -import com.courier.api.models.tenants.templates.TemplateListResponse -import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TemplateServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TemplateService { - - private val withRawResponse: TemplateService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TemplateService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TemplateService = - TemplateServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions, - ): BaseTemplateTenantAssociation = - // get /tenants/{tenant_id}/templates/{template_id} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun list( - params: TemplateListParams, - requestOptions: RequestOptions, - ): TemplateListResponse = - // get /tenants/{tenant_id}/templates - withRawResponse().list(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TemplateService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TemplateService.WithRawResponse = - TemplateServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TemplateRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("templateId", params.templateId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "tenants", - params._pathParam(0), - "templates", - params._pathParam(1), - ) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: TemplateListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("tenants", params._pathParam(0), "templates") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt deleted file mode 100644 index 7eea5039..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemService.kt +++ /dev/null @@ -1,127 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants.defaultpreferences - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams -import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface ItemService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ItemService - - /** Create or Replace Default Preferences For Topic */ - fun update(topicId: String, params: ItemUpdateParams) = - update(topicId, params, RequestOptions.none()) - - /** @see update */ - fun update( - topicId: String, - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = update(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see update */ - fun update(params: ItemUpdateParams) = update(params, RequestOptions.none()) - - /** @see update */ - fun update(params: ItemUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Remove Default Preferences For Topic */ - fun delete(topicId: String, params: ItemDeleteParams) = - delete(topicId, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - topicId: String, - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see delete */ - fun delete(params: ItemDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: ItemDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** A view of [ItemService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): ItemService.WithRawResponse - - /** - * Returns a raw HTTP response for `put - * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as - * [ItemService.update]. - */ - @MustBeClosed - fun update(topicId: String, params: ItemUpdateParams): HttpResponse = - update(topicId, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - topicId: String, - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = update(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: ItemUpdateParams): HttpResponse = update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: ItemUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `delete - * /tenants/{tenant_id}/default_preferences/items/{topic_id}`, but is otherwise the same as - * [ItemService.delete]. - */ - @MustBeClosed - fun delete(topicId: String, params: ItemDeleteParams): HttpResponse = - delete(topicId, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - topicId: String, - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete(params: ItemDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: ItemDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt deleted file mode 100644 index 678ee62f..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceImpl.kt +++ /dev/null @@ -1,117 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants.defaultpreferences - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams -import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class ItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : ItemService { - - private val withRawResponse: ItemService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): ItemService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): ItemService = - ItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun update(params: ItemUpdateParams, requestOptions: RequestOptions) { - // put /tenants/{tenant_id}/default_preferences/items/{topic_id} - withRawResponse().update(params, requestOptions) - } - - override fun delete(params: ItemDeleteParams, requestOptions: RequestOptions) { - // delete /tenants/{tenant_id}/default_preferences/items/{topic_id} - withRawResponse().delete(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - ItemService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): ItemService.WithRawResponse = - ItemServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: ItemUpdateParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "tenants", - params._pathParam(0), - "default_preferences", - "items", - params._pathParam(1), - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: ItemDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "tenants", - params._pathParam(0), - "default_preferences", - "items", - params._pathParam(1), - ) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt deleted file mode 100644 index 6d69a10b..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceService.kt +++ /dev/null @@ -1,239 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.users.preferences.PreferenceRetrieveParams -import com.courier.api.models.users.preferences.PreferenceRetrieveResponse -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface PreferenceService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): PreferenceService - - /** Fetch all user preferences. */ - fun retrieve(userId: String): PreferenceRetrieveResponse = - retrieve(userId, PreferenceRetrieveParams.none()) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): PreferenceRetrieveResponse = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - ): PreferenceRetrieveResponse = retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PreferenceRetrieveResponse - - /** @see retrieve */ - fun retrieve(params: PreferenceRetrieveParams): PreferenceRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve(userId: String, requestOptions: RequestOptions): PreferenceRetrieveResponse = - retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) - - /** Fetch user preferences for a specific subscription topic. */ - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - ): PreferenceRetrieveTopicResponse = retrieveTopic(topicId, params, RequestOptions.none()) - - /** @see retrieveTopic */ - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PreferenceRetrieveTopicResponse = - retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see retrieveTopic */ - fun retrieveTopic(params: PreferenceRetrieveTopicParams): PreferenceRetrieveTopicResponse = - retrieveTopic(params, RequestOptions.none()) - - /** @see retrieveTopic */ - fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PreferenceRetrieveTopicResponse - - /** Update or Create user preferences for a specific subscription topic. */ - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - ): PreferenceUpdateOrCreateTopicResponse = - updateOrCreateTopic(topicId, params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PreferenceUpdateOrCreateTopicResponse = - updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams - ): PreferenceUpdateOrCreateTopicResponse = updateOrCreateTopic(params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): PreferenceUpdateOrCreateTopicResponse - - /** A view of [PreferenceService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): PreferenceService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/preferences`, but is otherwise the - * same as [PreferenceService.retrieve]. - */ - @MustBeClosed - fun retrieve(userId: String): HttpResponseFor = - retrieve(userId, PreferenceRetrieveParams.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - params: PreferenceRetrieveParams = PreferenceRetrieveParams.none(), - ): HttpResponseFor = - retrieve(userId, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: PreferenceRetrieveParams - ): HttpResponseFor = retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - userId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - retrieve(userId, PreferenceRetrieveParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /users/{user_id}/preferences/{topic_id}`, but is - * otherwise the same as [PreferenceService.retrieveTopic]. - */ - @MustBeClosed - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - ): HttpResponseFor = - retrieveTopic(topicId, params, RequestOptions.none()) - - /** @see retrieveTopic */ - @MustBeClosed - fun retrieveTopic( - topicId: String, - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieveTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see retrieveTopic */ - @MustBeClosed - fun retrieveTopic( - params: PreferenceRetrieveTopicParams - ): HttpResponseFor = - retrieveTopic(params, RequestOptions.none()) - - /** @see retrieveTopic */ - @MustBeClosed - fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `put /users/{user_id}/preferences/{topic_id}`, but is - * otherwise the same as [PreferenceService.updateOrCreateTopic]. - */ - @MustBeClosed - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - ): HttpResponseFor = - updateOrCreateTopic(topicId, params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - @MustBeClosed - fun updateOrCreateTopic( - topicId: String, - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - updateOrCreateTopic(params.toBuilder().topicId(topicId).build(), requestOptions) - - /** @see updateOrCreateTopic */ - @MustBeClosed - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams - ): HttpResponseFor = - updateOrCreateTopic(params, RequestOptions.none()) - - /** @see updateOrCreateTopic */ - @MustBeClosed - fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt deleted file mode 100644 index 6b5a4f0d..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/PreferenceServiceImpl.kt +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.users.preferences.PreferenceRetrieveParams -import com.courier.api.models.users.preferences.PreferenceRetrieveResponse -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicResponse -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicResponse -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class PreferenceServiceImpl internal constructor(private val clientOptions: ClientOptions) : - PreferenceService { - - private val withRawResponse: PreferenceService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): PreferenceService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): PreferenceService = - PreferenceServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions, - ): PreferenceRetrieveResponse = - // get /users/{user_id}/preferences - withRawResponse().retrieve(params, requestOptions).parse() - - override fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions, - ): PreferenceRetrieveTopicResponse = - // get /users/{user_id}/preferences/{topic_id} - withRawResponse().retrieveTopic(params, requestOptions).parse() - - override fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions, - ): PreferenceUpdateOrCreateTopicResponse = - // put /users/{user_id}/preferences/{topic_id} - withRawResponse().updateOrCreateTopic(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - PreferenceService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): PreferenceService.WithRawResponse = - PreferenceServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: PreferenceRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "preferences") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val retrieveTopicHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieveTopic( - params: PreferenceRetrieveTopicParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "users", - params._pathParam(0), - "preferences", - params._pathParam(1), - ) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveTopicHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateOrCreateTopicHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun updateOrCreateTopic( - params: PreferenceUpdateOrCreateTopicParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("topicId", params.topicId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "users", - params._pathParam(0), - "preferences", - params._pathParam(1), - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { updateOrCreateTopicHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt deleted file mode 100644 index 67401748..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantService.kt +++ /dev/null @@ -1,336 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.users.tenants.TenantAddMultipleParams -import com.courier.api.models.users.tenants.TenantAddSingleParams -import com.courier.api.models.users.tenants.TenantListParams -import com.courier.api.models.users.tenants.TenantListResponse -import com.courier.api.models.users.tenants.TenantRemoveAllParams -import com.courier.api.models.users.tenants.TenantRemoveSingleParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface TenantService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TenantService - - /** Returns a paginated list of user tenant associations. */ - fun list(userId: String): TenantListResponse = list(userId, TenantListParams.none()) - - /** @see list */ - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): TenantListResponse = list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - ): TenantListResponse = list(userId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TenantListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TenantListResponse - - /** @see list */ - fun list(params: TenantListParams): TenantListResponse = list(params, RequestOptions.none()) - - /** @see list */ - fun list(userId: String, requestOptions: RequestOptions): TenantListResponse = - list(userId, TenantListParams.none(), requestOptions) - - /** - * This endpoint is used to add a user to multiple tenants in one call. A custom profile can - * also be supplied for each tenant. This profile will be merged with the user's main profile - * when sending to the user with that tenant. - */ - fun addMultiple(userId: String, params: TenantAddMultipleParams) = - addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - fun addMultiple(params: TenantAddMultipleParams) = addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** - * This endpoint is used to add a single tenant. - * - * A custom profile can also be supplied with the tenant. This profile will be merged with the - * user's main profile when sending to the user with that tenant. - */ - fun addSingle(tenantId: String, params: TenantAddSingleParams) = - addSingle(tenantId, params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - tenantId: String, - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see addSingle */ - fun addSingle(params: TenantAddSingleParams) = addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** Removes a user from any tenants they may have been associated with. */ - fun removeAll(userId: String) = removeAll(userId, TenantRemoveAllParams.none()) - - /** @see removeAll */ - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = removeAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see removeAll */ - fun removeAll(userId: String, params: TenantRemoveAllParams = TenantRemoveAllParams.none()) = - removeAll(userId, params, RequestOptions.none()) - - /** @see removeAll */ - fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** @see removeAll */ - fun removeAll(params: TenantRemoveAllParams) = removeAll(params, RequestOptions.none()) - - /** @see removeAll */ - fun removeAll(userId: String, requestOptions: RequestOptions) = - removeAll(userId, TenantRemoveAllParams.none(), requestOptions) - - /** Removes a user from the supplied tenant. */ - fun removeSingle(tenantId: String, params: TenantRemoveSingleParams) = - removeSingle(tenantId, params, RequestOptions.none()) - - /** @see removeSingle */ - fun removeSingle( - tenantId: String, - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see removeSingle */ - fun removeSingle(params: TenantRemoveSingleParams) = removeSingle(params, RequestOptions.none()) - - /** @see removeSingle */ - fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** A view of [TenantService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TenantService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tenants`, but is otherwise the same - * as [TenantService.list]. - */ - @MustBeClosed - fun list(userId: String): HttpResponseFor = - list(userId, TenantListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list( - userId: String, - params: TenantListParams = TenantListParams.none(), - ): HttpResponseFor = list(userId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: TenantListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: TenantListParams): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - userId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - list(userId, TenantListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tenants`, but is otherwise the same - * as [TenantService.addMultiple]. - */ - @MustBeClosed - fun addMultiple(userId: String, params: TenantAddMultipleParams): HttpResponse = - addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple( - userId: String, - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple(params: TenantAddMultipleParams): HttpResponse = - addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tenants/{tenant_id}`, but is - * otherwise the same as [TenantService.addSingle]. - */ - @MustBeClosed - fun addSingle(tenantId: String, params: TenantAddSingleParams): HttpResponse = - addSingle(tenantId, params, RequestOptions.none()) - - /** @see addSingle */ - @MustBeClosed - fun addSingle( - tenantId: String, - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = addSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see addSingle */ - @MustBeClosed - fun addSingle(params: TenantAddSingleParams): HttpResponse = - addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - @MustBeClosed - fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `delete /users/{user_id}/tenants`, but is otherwise the - * same as [TenantService.removeAll]. - */ - @MustBeClosed - fun removeAll(userId: String): HttpResponse = - removeAll(userId, TenantRemoveAllParams.none()) - - /** @see removeAll */ - @MustBeClosed - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = removeAll(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see removeAll */ - @MustBeClosed - fun removeAll( - userId: String, - params: TenantRemoveAllParams = TenantRemoveAllParams.none(), - ): HttpResponse = removeAll(userId, params, RequestOptions.none()) - - /** @see removeAll */ - @MustBeClosed - fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see removeAll */ - @MustBeClosed - fun removeAll(params: TenantRemoveAllParams): HttpResponse = - removeAll(params, RequestOptions.none()) - - /** @see removeAll */ - @MustBeClosed - fun removeAll(userId: String, requestOptions: RequestOptions): HttpResponse = - removeAll(userId, TenantRemoveAllParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /users/{user_id}/tenants/{tenant_id}`, but is - * otherwise the same as [TenantService.removeSingle]. - */ - @MustBeClosed - fun removeSingle(tenantId: String, params: TenantRemoveSingleParams): HttpResponse = - removeSingle(tenantId, params, RequestOptions.none()) - - /** @see removeSingle */ - @MustBeClosed - fun removeSingle( - tenantId: String, - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = - removeSingle(params.toBuilder().tenantId(tenantId).build(), requestOptions) - - /** @see removeSingle */ - @MustBeClosed - fun removeSingle(params: TenantRemoveSingleParams): HttpResponse = - removeSingle(params, RequestOptions.none()) - - /** @see removeSingle */ - @MustBeClosed - fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt deleted file mode 100644 index ac374fcb..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TenantServiceImpl.kt +++ /dev/null @@ -1,207 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.users.tenants.TenantAddMultipleParams -import com.courier.api.models.users.tenants.TenantAddSingleParams -import com.courier.api.models.users.tenants.TenantListParams -import com.courier.api.models.users.tenants.TenantListResponse -import com.courier.api.models.users.tenants.TenantRemoveAllParams -import com.courier.api.models.users.tenants.TenantRemoveSingleParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TenantServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TenantService { - - private val withRawResponse: TenantService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TenantService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TenantService = - TenantServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): TenantListResponse = - // get /users/{user_id}/tenants - withRawResponse().list(params, requestOptions).parse() - - override fun addMultiple(params: TenantAddMultipleParams, requestOptions: RequestOptions) { - // put /users/{user_id}/tenants - withRawResponse().addMultiple(params, requestOptions) - } - - override fun addSingle(params: TenantAddSingleParams, requestOptions: RequestOptions) { - // put /users/{user_id}/tenants/{tenant_id} - withRawResponse().addSingle(params, requestOptions) - } - - override fun removeAll(params: TenantRemoveAllParams, requestOptions: RequestOptions) { - // delete /users/{user_id}/tenants - withRawResponse().removeAll(params, requestOptions) - } - - override fun removeSingle(params: TenantRemoveSingleParams, requestOptions: RequestOptions) { - // delete /users/{user_id}/tenants/{tenant_id} - withRawResponse().removeSingle(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TenantService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TenantService.WithRawResponse = - TenantServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: TenantListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val addMultipleHandler: Handler = emptyHandler() - - override fun addMultiple( - params: TenantAddMultipleParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { addMultipleHandler.handle(it) } - } - } - - private val addSingleHandler: Handler = emptyHandler() - - override fun addSingle( - params: TenantAddSingleParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { addSingleHandler.handle(it) } - } - } - - private val removeAllHandler: Handler = emptyHandler() - - override fun removeAll( - params: TenantRemoveAllParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { removeAllHandler.handle(it) } - } - } - - private val removeSingleHandler: Handler = emptyHandler() - - override fun removeSingle( - params: TenantRemoveSingleParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("tenantId", params.tenantId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tenants", params._pathParam(1)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { removeSingleHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt deleted file mode 100644 index ab684385..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenService.kt +++ /dev/null @@ -1,369 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.users.tokens.TokenAddMultipleParams -import com.courier.api.models.users.tokens.TokenAddSingleParams -import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveParams -import com.courier.api.models.users.tokens.TokenRetrieveResponse -import com.courier.api.models.users.tokens.TokenUpdateParams -import com.courier.api.models.users.tokens.UserToken -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface TokenService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TokenService - - /** Get single token available for a `:token` */ - fun retrieve(token: String, params: TokenRetrieveParams): TokenRetrieveResponse = - retrieve(token, params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - token: String, - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TokenRetrieveResponse = retrieve(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieve */ - fun retrieve(params: TokenRetrieveParams): TokenRetrieveResponse = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): TokenRetrieveResponse - - /** Apply a JSON Patch (RFC 6902) to the specified token. */ - fun update(token: String, params: TokenUpdateParams) = - update(token, params, RequestOptions.none()) - - /** @see update */ - fun update( - token: String, - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = update(params.toBuilder().token(token).build(), requestOptions) - - /** @see update */ - fun update(params: TokenUpdateParams) = update(params, RequestOptions.none()) - - /** @see update */ - fun update(params: TokenUpdateParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Gets all tokens available for a :user_id */ - fun list(userId: String): List = list(userId, TokenListParams.none()) - - /** @see list */ - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): List = list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - fun list(userId: String, params: TokenListParams = TokenListParams.none()): List = - list(userId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: TokenListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): List - - /** @see list */ - fun list(params: TokenListParams): List = list(params, RequestOptions.none()) - - /** @see list */ - fun list(userId: String, requestOptions: RequestOptions): List = - list(userId, TokenListParams.none(), requestOptions) - - /** Delete User Token */ - fun delete(token: String, params: TokenDeleteParams) = - delete(token, params, RequestOptions.none()) - - /** @see delete */ - fun delete( - token: String, - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = delete(params.toBuilder().token(token).build(), requestOptions) - - /** @see delete */ - fun delete(params: TokenDeleteParams) = delete(params, RequestOptions.none()) - - /** @see delete */ - fun delete(params: TokenDeleteParams, requestOptions: RequestOptions = RequestOptions.none()) - - /** Adds multiple tokens to a user and overwrites matching existing tokens. */ - fun addMultiple(userId: String) = addMultiple(userId, TokenAddMultipleParams.none()) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ) = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - ) = addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** @see addMultiple */ - fun addMultiple(params: TokenAddMultipleParams) = addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - fun addMultiple(userId: String, requestOptions: RequestOptions) = - addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) - - /** Adds a single token to a user and overwrites a matching existing token. */ - fun addSingle(pathToken: String, params: TokenAddSingleParams) = - addSingle(pathToken, params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - pathToken: String, - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) = addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) - - /** @see addSingle */ - fun addSingle(params: TokenAddSingleParams) = addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ) - - /** A view of [TokenService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): TokenService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenService.retrieve]. - */ - @MustBeClosed - fun retrieve( - token: String, - params: TokenRetrieveParams, - ): HttpResponseFor = retrieve(token, params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - token: String, - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - retrieve(params.toBuilder().token(token).build(), requestOptions) - - /** @see retrieve */ - @MustBeClosed - fun retrieve(params: TokenRetrieveParams): HttpResponseFor = - retrieve(params, RequestOptions.none()) - - /** @see retrieve */ - @MustBeClosed - fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `patch /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenService.update]. - */ - @MustBeClosed - fun update(token: String, params: TokenUpdateParams): HttpResponse = - update(token, params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - token: String, - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = update(params.toBuilder().token(token).build(), requestOptions) - - /** @see update */ - @MustBeClosed - fun update(params: TokenUpdateParams): HttpResponse = update(params, RequestOptions.none()) - - /** @see update */ - @MustBeClosed - fun update( - params: TokenUpdateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `get /users/{user_id}/tokens`, but is otherwise the same - * as [TokenService.list]. - */ - @MustBeClosed - fun list(userId: String): HttpResponseFor> = - list(userId, TokenListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> = - list(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list( - userId: String, - params: TokenListParams = TokenListParams.none(), - ): HttpResponseFor> = list(userId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: TokenListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor> - - /** @see list */ - @MustBeClosed - fun list(params: TokenListParams): HttpResponseFor> = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(userId: String, requestOptions: RequestOptions): HttpResponseFor> = - list(userId, TokenListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `delete /users/{user_id}/tokens/{token}`, but is - * otherwise the same as [TokenService.delete]. - */ - @MustBeClosed - fun delete(token: String, params: TokenDeleteParams): HttpResponse = - delete(token, params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - token: String, - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = delete(params.toBuilder().token(token).build(), requestOptions) - - /** @see delete */ - @MustBeClosed - fun delete(params: TokenDeleteParams): HttpResponse = delete(params, RequestOptions.none()) - - /** @see delete */ - @MustBeClosed - fun delete( - params: TokenDeleteParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tokens`, but is otherwise the same - * as [TokenService.addMultiple]. - */ - @MustBeClosed - fun addMultiple(userId: String): HttpResponse = - addMultiple(userId, TokenAddMultipleParams.none()) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = addMultiple(params.toBuilder().userId(userId).build(), requestOptions) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple( - userId: String, - params: TokenAddMultipleParams = TokenAddMultipleParams.none(), - ): HttpResponse = addMultiple(userId, params, RequestOptions.none()) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple(params: TokenAddMultipleParams): HttpResponse = - addMultiple(params, RequestOptions.none()) - - /** @see addMultiple */ - @MustBeClosed - fun addMultiple(userId: String, requestOptions: RequestOptions): HttpResponse = - addMultiple(userId, TokenAddMultipleParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `put /users/{user_id}/tokens/{token}`, but is otherwise - * the same as [TokenService.addSingle]. - */ - @MustBeClosed - fun addSingle(pathToken: String, params: TokenAddSingleParams): HttpResponse = - addSingle(pathToken, params, RequestOptions.none()) - - /** @see addSingle */ - @MustBeClosed - fun addSingle( - pathToken: String, - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse = addSingle(params.toBuilder().pathToken(pathToken).build(), requestOptions) - - /** @see addSingle */ - @MustBeClosed - fun addSingle(params: TokenAddSingleParams): HttpResponse = - addSingle(params, RequestOptions.none()) - - /** @see addSingle */ - @MustBeClosed - fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponse - } -} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt deleted file mode 100644 index d000a1fb..00000000 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/users/TokenServiceImpl.kt +++ /dev/null @@ -1,243 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.core.ClientOptions -import com.courier.api.core.RequestOptions -import com.courier.api.core.checkRequired -import com.courier.api.core.handlers.emptyHandler -import com.courier.api.core.handlers.errorBodyHandler -import com.courier.api.core.handlers.errorHandler -import com.courier.api.core.handlers.jsonHandler -import com.courier.api.core.http.HttpMethod -import com.courier.api.core.http.HttpRequest -import com.courier.api.core.http.HttpResponse -import com.courier.api.core.http.HttpResponse.Handler -import com.courier.api.core.http.HttpResponseFor -import com.courier.api.core.http.json -import com.courier.api.core.http.parseable -import com.courier.api.core.prepare -import com.courier.api.models.users.tokens.TokenAddMultipleParams -import com.courier.api.models.users.tokens.TokenAddSingleParams -import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenListParams -import com.courier.api.models.users.tokens.TokenRetrieveParams -import com.courier.api.models.users.tokens.TokenRetrieveResponse -import com.courier.api.models.users.tokens.TokenUpdateParams -import com.courier.api.models.users.tokens.UserToken -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class TokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : - TokenService { - - private val withRawResponse: TokenService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): TokenService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): TokenService = - TokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions, - ): TokenRetrieveResponse = - // get /users/{user_id}/tokens/{token} - withRawResponse().retrieve(params, requestOptions).parse() - - override fun update(params: TokenUpdateParams, requestOptions: RequestOptions) { - // patch /users/{user_id}/tokens/{token} - withRawResponse().update(params, requestOptions) - } - - override fun list(params: TokenListParams, requestOptions: RequestOptions): List = - // get /users/{user_id}/tokens - withRawResponse().list(params, requestOptions).parse() - - override fun delete(params: TokenDeleteParams, requestOptions: RequestOptions) { - // delete /users/{user_id}/tokens/{token} - withRawResponse().delete(params, requestOptions) - } - - override fun addMultiple(params: TokenAddMultipleParams, requestOptions: RequestOptions) { - // put /users/{user_id}/tokens - withRawResponse().addMultiple(params, requestOptions) - } - - override fun addSingle(params: TokenAddSingleParams, requestOptions: RequestOptions) { - // put /users/{user_id}/tokens/{token} - withRawResponse().addSingle(params, requestOptions) - } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - TokenService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): TokenService.WithRawResponse = - TokenServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val retrieveHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun retrieve( - params: TokenRetrieveParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { retrieveHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val updateHandler: Handler = emptyHandler() - - override fun update( - params: TokenUpdateParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PATCH) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { updateHandler.handle(it) } - } - } - - private val listHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) - - override fun list( - params: TokenListParams, - requestOptions: RequestOptions, - ): HttpResponseFor> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } - } - } - } - } - - private val deleteHandler: Handler = emptyHandler() - - override fun delete( - params: TokenDeleteParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("token", params.token().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.DELETE) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { deleteHandler.handle(it) } - } - } - - private val addMultipleHandler: Handler = emptyHandler() - - override fun addMultiple( - params: TokenAddMultipleParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("userId", params.userId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens") - .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { addMultipleHandler.handle(it) } - } - } - - private val addSingleHandler: Handler = emptyHandler() - - override fun addSingle( - params: TokenAddSingleParams, - requestOptions: RequestOptions, - ): HttpResponse { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("pathToken", params.pathToken().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.PUT) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("users", params._pathParam(0), "tokens", params._pathParam(1)) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response.use { addSingleHandler.handle(it) } - } - } - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt deleted file mode 100644 index 5c23daa0..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/ChannelPreferenceTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models - -import com.courier.api.core.jsonMapper -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ChannelPreferenceTest { - - @Test - fun create() { - val channelPreference = - ChannelPreference.builder().channel(ChannelClassification.DIRECT_MESSAGE).build() - - assertThat(channelPreference.channel()).isEqualTo(ChannelClassification.DIRECT_MESSAGE) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val channelPreference = - ChannelPreference.builder().channel(ChannelClassification.DIRECT_MESSAGE).build() - - val roundtrippedChannelPreference = - jsonMapper.readValue( - jsonMapper.writeValueAsString(channelPreference), - jacksonTypeRef(), - ) - - assertThat(roundtrippedChannelPreference).isEqualTo(channelPreference) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt deleted file mode 100644 index ddd2f81c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/RuleTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RuleTest { - - @Test - fun create() { - val rule = Rule.builder().until("until").start("start").build() - - assertThat(rule.until()).isEqualTo("until") - assertThat(rule.start()).contains("start") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val rule = Rule.builder().until("until").start("start").build() - - val roundtrippedRule = - jsonMapper.readValue(jsonMapper.writeValueAsString(rule), jacksonTypeRef()) - - assertThat(roundtrippedRule).isEqualTo(rule) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt deleted file mode 100644 index 3525755a..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceDeleteParamsTest { - - @Test - fun create() { - AudienceDeleteParams.builder().audienceId("audience_id").build() - } - - @Test - fun pathParams() { - val params = AudienceDeleteParams.builder().audienceId("audience_id").build() - - assertThat(params._pathParam(0)).isEqualTo("audience_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt deleted file mode 100644 index aa874b76..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersParamsTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceListMembersParamsTest { - - @Test - fun create() { - AudienceListMembersParams.builder().audienceId("audience_id").cursor("cursor").build() - } - - @Test - fun pathParams() { - val params = AudienceListMembersParams.builder().audienceId("audience_id").build() - - assertThat(params._pathParam(0)).isEqualTo("audience_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - AudienceListMembersParams.builder().audienceId("audience_id").cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = AudienceListMembersParams.builder().audienceId("audience_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt deleted file mode 100644 index 3ef062a7..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListMembersResponseTest.kt +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceListMembersResponseTest { - - @Test - fun create() { - val audienceListMembersResponse = - AudienceListMembersResponse.builder() - .addItem( - AudienceListMembersResponse.Item.builder() - .addedAt("added_at") - .audienceId("audience_id") - .audienceVersion(0L) - .memberId("member_id") - .reason("reason") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(audienceListMembersResponse.items()) - .containsExactly( - AudienceListMembersResponse.Item.builder() - .addedAt("added_at") - .audienceId("audience_id") - .audienceVersion(0L) - .memberId("member_id") - .reason("reason") - .build() - ) - assertThat(audienceListMembersResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val audienceListMembersResponse = - AudienceListMembersResponse.builder() - .addItem( - AudienceListMembersResponse.Item.builder() - .addedAt("added_at") - .audienceId("audience_id") - .audienceVersion(0L) - .memberId("member_id") - .reason("reason") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedAudienceListMembersResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(audienceListMembersResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAudienceListMembersResponse).isEqualTo(audienceListMembersResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt deleted file mode 100644 index c794dfbc..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListParamsTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceListParamsTest { - - @Test - fun create() { - AudienceListParams.builder().cursor("cursor").build() - } - - @Test - fun queryParams() { - val params = AudienceListParams.builder().cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = AudienceListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt deleted file mode 100644 index 5ba56e5c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceListResponseTest.kt +++ /dev/null @@ -1,88 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceListResponseTest { - - @Test - fun create() { - val audienceListResponse = - AudienceListResponse.builder() - .addItem( - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(audienceListResponse.items()) - .containsExactly( - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - ) - assertThat(audienceListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val audienceListResponse = - AudienceListResponse.builder() - .addItem( - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedAudienceListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(audienceListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAudienceListResponse).isEqualTo(audienceListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt deleted file mode 100644 index acf188f5..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceRetrieveParamsTest { - - @Test - fun create() { - AudienceRetrieveParams.builder().audienceId("audience_id").build() - } - - @Test - fun pathParams() { - val params = AudienceRetrieveParams.builder().audienceId("audience_id").build() - - assertThat(params._pathParam(0)).isEqualTo("audience_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt deleted file mode 100644 index 9573ecc6..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceTest { - - @Test - fun create() { - val audience = - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - - assertThat(audience.id()).isEqualTo("id") - assertThat(audience.createdAt()).isEqualTo("created_at") - assertThat(audience.description()).isEqualTo("description") - assertThat(audience.filter()) - .isEqualTo( - Filter.ofUnionMember0( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - ) - assertThat(audience.name()).isEqualTo("name") - assertThat(audience.updatedAt()).isEqualTo("updated_at") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val audience = - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - - val roundtrippedAudience = - jsonMapper.readValue( - jsonMapper.writeValueAsString(audience), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAudience).isEqualTo(audience) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt deleted file mode 100644 index e8ab4192..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateParamsTest.kt +++ /dev/null @@ -1,73 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceUpdateParamsTest { - - @Test - fun create() { - AudienceUpdateParams.builder() - .audienceId("audience_id") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .build() - } - - @Test - fun pathParams() { - val params = AudienceUpdateParams.builder().audienceId("audience_id").build() - - assertThat(params._pathParam(0)).isEqualTo("audience_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - AudienceUpdateParams.builder() - .audienceId("audience_id") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .build() - - val body = params._body() - - assertThat(body.description()).contains("description") - assertThat(body.filter()) - .contains( - Filter.ofUnionMember0( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - ) - assertThat(body.name()).contains("name") - } - - @Test - fun bodyWithoutOptionalFields() { - val params = AudienceUpdateParams.builder().audienceId("audience_id").build() - - val body = params._body() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt deleted file mode 100644 index ef8a8c15..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/AudienceUpdateResponseTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AudienceUpdateResponseTest { - - @Test - fun create() { - val audienceUpdateResponse = - AudienceUpdateResponse.builder() - .audience( - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - ) - .build() - - assertThat(audienceUpdateResponse.audience()) - .isEqualTo( - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val audienceUpdateResponse = - AudienceUpdateResponse.builder() - .audience( - Audience.builder() - .id("id") - .createdAt("created_at") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .updatedAt("updated_at") - .build() - ) - .build() - - val roundtrippedAudienceUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(audienceUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAudienceUpdateResponse).isEqualTo(audienceUpdateResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt deleted file mode 100644 index 8ad539d9..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterConfigTest.kt +++ /dev/null @@ -1,115 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class FilterConfigTest { - - @Test - fun ofUnionMember0() { - val unionMember0 = - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - - val filterConfig = FilterConfig.ofUnionMember0(unionMember0) - - assertThat(filterConfig.unionMember0()).contains(unionMember0) - assertThat(filterConfig.nested()).isEmpty - } - - @Test - fun ofUnionMember0Roundtrip() { - val jsonMapper = jsonMapper() - val filterConfig = - FilterConfig.ofUnionMember0( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - - val roundtrippedFilterConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(filterConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFilterConfig).isEqualTo(filterConfig) - } - - @Test - fun ofNested() { - val nested = - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - - val filterConfig = FilterConfig.ofNested(nested) - - assertThat(filterConfig.unionMember0()).isEmpty - assertThat(filterConfig.nested()).contains(nested) - } - - @Test - fun ofNestedRoundtrip() { - val jsonMapper = jsonMapper() - val filterConfig = - FilterConfig.ofNested( - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - ) - - val roundtrippedFilterConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(filterConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedFilterConfig).isEqualTo(filterConfig) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val filterConfig = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { filterConfig.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt deleted file mode 100644 index 3e565ad1..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/FilterTest.kt +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class FilterTest { - - @Test - fun ofUnionMember0() { - val unionMember0 = - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - - val filter = Filter.ofUnionMember0(unionMember0) - - assertThat(filter.unionMember0()).contains(unionMember0) - assertThat(filter.nestedFilterConfig()).isEmpty - } - - @Test - fun ofUnionMember0Roundtrip() { - val jsonMapper = jsonMapper() - val filter = - Filter.ofUnionMember0( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - - val roundtrippedFilter = - jsonMapper.readValue(jsonMapper.writeValueAsString(filter), jacksonTypeRef()) - - assertThat(roundtrippedFilter).isEqualTo(filter) - } - - @Test - fun ofNestedFilterConfig() { - val nestedFilterConfig = - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - - val filter = Filter.ofNestedFilterConfig(nestedFilterConfig) - - assertThat(filter.unionMember0()).isEmpty - assertThat(filter.nestedFilterConfig()).contains(nestedFilterConfig) - } - - @Test - fun ofNestedFilterConfigRoundtrip() { - val jsonMapper = jsonMapper() - val filter = - Filter.ofNestedFilterConfig( - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - ) - - val roundtrippedFilter = - jsonMapper.readValue(jsonMapper.writeValueAsString(filter), jacksonTypeRef()) - - assertThat(roundtrippedFilter).isEqualTo(filter) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val filter = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { filter.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt deleted file mode 100644 index e86f387d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/NestedFilterConfigTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NestedFilterConfigTest { - - @Test - fun create() { - val nestedFilterConfig = - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - - assertThat(nestedFilterConfig.operator()).isEqualTo(NestedFilterConfig.Operator.ENDS_WITH) - assertThat(nestedFilterConfig.rules()) - .containsExactly( - FilterConfig.ofUnionMember0( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val nestedFilterConfig = - NestedFilterConfig.builder() - .operator(NestedFilterConfig.Operator.ENDS_WITH) - .addRule( - FilterConfig.UnionMember0.builder() - .operator(FilterConfig.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .build() - - val roundtrippedNestedFilterConfig = - jsonMapper.readValue( - jsonMapper.writeValueAsString(nestedFilterConfig), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNestedFilterConfig).isEqualTo(nestedFilterConfig) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt deleted file mode 100644 index c456b0c0..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/audiences/PagingTest.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.audiences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PagingTest { - - @Test - fun create() { - val paging = Paging.builder().more(true).cursor("cursor").build() - - assertThat(paging.more()).isEqualTo(true) - assertThat(paging.cursor()).contains("cursor") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val paging = Paging.builder().more(true).cursor("cursor").build() - - val roundtrippedPaging = - jsonMapper.readValue(jsonMapper.writeValueAsString(paging), jacksonTypeRef()) - - assertThat(roundtrippedPaging).isEqualTo(paging) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt deleted file mode 100644 index c571ee3e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListParamsTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AuditEventListParamsTest { - - @Test - fun create() { - AuditEventListParams.builder().cursor("cursor").build() - } - - @Test - fun queryParams() { - val params = AuditEventListParams.builder().cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = AuditEventListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt deleted file mode 100644 index 1c113ff7..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventListResponseTest.kt +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AuditEventListResponseTest { - - @Test - fun create() { - val auditEventListResponse = - AuditEventListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - AuditEvent.builder() - .auditEventId("auditEventId") - .source("source") - .timestamp("timestamp") - .type("type") - .actor(AuditEvent.Actor.builder().id("id").email("email").build()) - .target(AuditEvent.Target.builder().id("id").email("email").build()) - .build() - ) - .build() - - assertThat(auditEventListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - assertThat(auditEventListResponse.results()) - .containsExactly( - AuditEvent.builder() - .auditEventId("auditEventId") - .source("source") - .timestamp("timestamp") - .type("type") - .actor(AuditEvent.Actor.builder().id("id").email("email").build()) - .target(AuditEvent.Target.builder().id("id").email("email").build()) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val auditEventListResponse = - AuditEventListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - AuditEvent.builder() - .auditEventId("auditEventId") - .source("source") - .timestamp("timestamp") - .type("type") - .actor(AuditEvent.Actor.builder().id("id").email("email").build()) - .target(AuditEvent.Target.builder().id("id").email("email").build()) - .build() - ) - .build() - - val roundtrippedAuditEventListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(auditEventListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAuditEventListResponse).isEqualTo(auditEventListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt deleted file mode 100644 index 7b671c8b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AuditEventRetrieveParamsTest { - - @Test - fun create() { - AuditEventRetrieveParams.builder().auditEventId("audit-event-id").build() - } - - @Test - fun pathParams() { - val params = AuditEventRetrieveParams.builder().auditEventId("audit-event-id").build() - - assertThat(params._pathParam(0)).isEqualTo("audit-event-id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt deleted file mode 100644 index 49f9f690..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auditevents/AuditEventTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auditevents - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AuditEventTest { - - @Test - fun create() { - val auditEvent = - AuditEvent.builder() - .auditEventId("auditEventId") - .source("source") - .timestamp("timestamp") - .type("type") - .actor(AuditEvent.Actor.builder().id("id").email("email").build()) - .target(AuditEvent.Target.builder().id("id").email("email").build()) - .build() - - assertThat(auditEvent.auditEventId()).isEqualTo("auditEventId") - assertThat(auditEvent.source()).isEqualTo("source") - assertThat(auditEvent.timestamp()).isEqualTo("timestamp") - assertThat(auditEvent.type()).isEqualTo("type") - assertThat(auditEvent.actor()) - .contains(AuditEvent.Actor.builder().id("id").email("email").build()) - assertThat(auditEvent.target()) - .contains(AuditEvent.Target.builder().id("id").email("email").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val auditEvent = - AuditEvent.builder() - .auditEventId("auditEventId") - .source("source") - .timestamp("timestamp") - .type("type") - .actor(AuditEvent.Actor.builder().id("id").email("email").build()) - .target(AuditEvent.Target.builder().id("id").email("email").build()) - .build() - - val roundtrippedAuditEvent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(auditEvent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAuditEvent).isEqualTo(auditEvent) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt deleted file mode 100644 index a972133b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auth - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AuthIssueTokenParamsTest { - - @Test - fun create() { - AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() - } - - @Test - fun body() { - val params = AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() - - val body = params._body() - - assertThat(body.expiresIn()).isEqualTo("expires_in") - assertThat(body.scope()).isEqualTo("scope") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt deleted file mode 100644 index 80690828..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/auth/AuthIssueTokenResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.auth - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AuthIssueTokenResponseTest { - - @Test - fun create() { - val authIssueTokenResponse = AuthIssueTokenResponse.builder().token("token").build() - - assertThat(authIssueTokenResponse.token()).contains("token") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val authIssueTokenResponse = AuthIssueTokenResponse.builder().token("token").build() - - val roundtrippedAuthIssueTokenResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(authIssueTokenResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAuthIssueTokenResponse).isEqualTo(authIssueTokenResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt deleted file mode 100644 index 376c761d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeParamsTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AutomationInvokeParamsTest { - - @Test - fun create() { - val automationInvokeParams = - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - - assertThat(automationInvokeParams.brand()).contains("brand") - assertThat(automationInvokeParams.data()) - .contains( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(automationInvokeParams._profile()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(automationInvokeParams.recipient()).contains("recipient") - assertThat(automationInvokeParams.template()).contains("template") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val automationInvokeParams = - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - - val roundtrippedAutomationInvokeParams = - jsonMapper.readValue( - jsonMapper.writeValueAsString(automationInvokeParams), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAutomationInvokeParams).isEqualTo(automationInvokeParams) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt deleted file mode 100644 index 1b164e6f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationInvokeResponseTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AutomationInvokeResponseTest { - - @Test - fun create() { - val automationInvokeResponse = - AutomationInvokeResponse.builder().runId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() - - assertThat(automationInvokeResponse.runId()) - .isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val automationInvokeResponse = - AutomationInvokeResponse.builder().runId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() - - val roundtrippedAutomationInvokeResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(automationInvokeResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAutomationInvokeResponse).isEqualTo(automationInvokeResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt deleted file mode 100644 index 37c8b8b8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/AutomationStepTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class AutomationStepTest { - - @Test - fun create() { - val automationStep = AutomationStep.builder().if_("if").ref("ref").build() - - assertThat(automationStep.if_()).contains("if") - assertThat(automationStep.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val automationStep = AutomationStep.builder().if_("if").ref("ref").build() - - val roundtrippedAutomationStep = - jsonMapper.readValue( - jsonMapper.writeValueAsString(automationStep), - jacksonTypeRef(), - ) - - assertThat(roundtrippedAutomationStep).isEqualTo(automationStep) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt deleted file mode 100644 index d3ed655f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeAdHocParamsTest.kt +++ /dev/null @@ -1,149 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InvokeInvokeAdHocParamsTest { - - @Test - fun create() { - InvokeInvokeAdHocParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .automation( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep.builder() - .if_("if") - .ref("ref") - .action( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .cancelationToken("cancelation_token") - .build() - ) - .build() - } - - @Test - fun body() { - val params = - InvokeInvokeAdHocParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .automation( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() - .if_("if") - .ref("ref") - .action( - InvokeInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .cancelationToken("cancelation_token") - .build() - ) - .build() - - val body = params._body() - - assertThat(body.brand()).contains("brand") - assertThat(body.data()) - .contains( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body._profile()).isEqualTo(JsonValue.from(mapOf())) - assertThat(body.recipient()).contains("recipient") - assertThat(body.template()).contains("template") - assertThat(body.automation()) - .isEqualTo( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep.builder() - .if_("if") - .ref("ref") - .action( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .cancelationToken("cancelation_token") - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - InvokeInvokeAdHocParams.builder() - .automation( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() - .action( - InvokeInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.automation()) - .isEqualTo( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep.builder() - .action( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt deleted file mode 100644 index c661938b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/automations/invoke/InvokeInvokeByTemplateParamsTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.automations.invoke - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InvokeInvokeByTemplateParamsTest { - - @Test - fun create() { - InvokeInvokeByTemplateParams.builder() - .templateId("templateId") - .automationInvokeParams( - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - InvokeInvokeByTemplateParams.builder() - .templateId("templateId") - .automationInvokeParams(AutomationInvokeParams.builder().build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("templateId") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - InvokeInvokeByTemplateParams.builder() - .templateId("templateId") - .automationInvokeParams( - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - ) - .build() - - val body = params._body() - - assertThat(body) - .isEqualTo( - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - InvokeInvokeByTemplateParams.builder() - .templateId("templateId") - .automationInvokeParams(AutomationInvokeParams.builder().build()) - .build() - - val body = params._body() - - assertThat(body).isEqualTo(AutomationInvokeParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt deleted file mode 100644 index b5febdd0..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandColorsTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandColorsTest { - - @Test - fun create() { - val brandColors = - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - - assertThat(brandColors.primary()).contains("primary") - assertThat(brandColors.secondary()).contains("secondary") - assertThat(brandColors.tertiary()).contains("tertiary") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brandColors = - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - - val roundtrippedBrandColors = - jsonMapper.readValue( - jsonMapper.writeValueAsString(brandColors), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBrandColors).isEqualTo(brandColors) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt deleted file mode 100644 index 71b4671f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandCreateParamsTest.kt +++ /dev/null @@ -1,135 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandCreateParamsTest { - - @Test - fun create() { - BrandCreateParams.builder() - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - } - - @Test - fun body() { - val params = - BrandCreateParams.builder() - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - assertThat(body.settings()) - .isEqualTo( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - assertThat(body.id()).contains("id") - assertThat(body.snippets()) - .contains( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BrandCreateParams.builder() - .name("name") - .settings(BrandSettings.builder().build()) - .build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - assertThat(body.settings()).isEqualTo(BrandSettings.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt deleted file mode 100644 index 631fcf67..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandDeleteParamsTest { - - @Test - fun create() { - BrandDeleteParams.builder().brandId("brand_id").build() - } - - @Test - fun pathParams() { - val params = BrandDeleteParams.builder().brandId("brand_id").build() - - assertThat(params._pathParam(0)).isEqualTo("brand_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt deleted file mode 100644 index bd89858a..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListParamsTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandListParamsTest { - - @Test - fun create() { - BrandListParams.builder().cursor("cursor").build() - } - - @Test - fun queryParams() { - val params = BrandListParams.builder().cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BrandListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt deleted file mode 100644 index b117317d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandListResponseTest.kt +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandListResponseTest { - - @Test - fun create() { - val brandListResponse = - BrandListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - Brand.builder() - .created(0L) - .name("name") - .published(0L) - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .updated(0L) - .version("version") - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - .build() - - assertThat(brandListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - assertThat(brandListResponse.results()) - .containsExactly( - Brand.builder() - .created(0L) - .name("name") - .published(0L) - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .updated(0L) - .version("version") - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brandListResponse = - BrandListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - Brand.builder() - .created(0L) - .name("name") - .published(0L) - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .updated(0L) - .version("version") - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - .build() - - val roundtrippedBrandListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(brandListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBrandListResponse).isEqualTo(brandListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt deleted file mode 100644 index 52f1ce9b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandRetrieveParamsTest { - - @Test - fun create() { - BrandRetrieveParams.builder().brandId("brand_id").build() - } - - @Test - fun pathParams() { - val params = BrandRetrieveParams.builder().brandId("brand_id").build() - - assertThat(params._pathParam(0)).isEqualTo("brand_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt deleted file mode 100644 index ca07a8d4..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSettingsTest.kt +++ /dev/null @@ -1,80 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandSettingsTest { - - @Test - fun create() { - val brandSettings = - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - - assertThat(brandSettings.colors()) - .contains( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - assertThat(brandSettings.email()) - .contains( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - assertThat(brandSettings._inapp()).isEqualTo(JsonValue.from(mapOf())) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brandSettings = - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - - val roundtrippedBrandSettings = - jsonMapper.readValue( - jsonMapper.writeValueAsString(brandSettings), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBrandSettings).isEqualTo(brandSettings) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt deleted file mode 100644 index c90e1882..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandSnippetTest { - - @Test - fun create() { - val brandSnippet = - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - - assertThat(brandSnippet.format()).isEqualTo(BrandSnippet.Format.HANDLEBARS) - assertThat(brandSnippet.name()).isEqualTo("name") - assertThat(brandSnippet.value()).isEqualTo("value") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brandSnippet = - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - - val roundtrippedBrandSnippet = - jsonMapper.readValue( - jsonMapper.writeValueAsString(brandSnippet), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBrandSnippet).isEqualTo(brandSnippet) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt deleted file mode 100644 index d5974d04..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandSnippetsTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandSnippetsTest { - - @Test - fun create() { - val brandSnippets = - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - - assertThat(brandSnippets.items()) - .containsExactly( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brandSnippets = - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - - val roundtrippedBrandSnippets = - jsonMapper.readValue( - jsonMapper.writeValueAsString(brandSnippets), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBrandSnippets).isEqualTo(brandSnippets) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt deleted file mode 100644 index c1e82887..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandTest.kt +++ /dev/null @@ -1,140 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandTest { - - @Test - fun create() { - val brand = - Brand.builder() - .created(0L) - .name("name") - .published(0L) - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .updated(0L) - .version("version") - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - - assertThat(brand.created()).isEqualTo(0L) - assertThat(brand.name()).isEqualTo("name") - assertThat(brand.published()).isEqualTo(0L) - assertThat(brand.settings()) - .isEqualTo( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - assertThat(brand.updated()).isEqualTo(0L) - assertThat(brand.version()).isEqualTo("version") - assertThat(brand.id()).contains("id") - assertThat(brand.snippets()) - .contains( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val brand = - Brand.builder() - .created(0L) - .name("name") - .published(0L) - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .updated(0L) - .version("version") - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - - val roundtrippedBrand = - jsonMapper.readValue(jsonMapper.writeValueAsString(brand), jacksonTypeRef()) - - assertThat(roundtrippedBrand).isEqualTo(brand) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt deleted file mode 100644 index 74019c70..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/BrandUpdateParamsTest.kt +++ /dev/null @@ -1,138 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BrandUpdateParamsTest { - - @Test - fun create() { - BrandUpdateParams.builder() - .brandId("brand_id") - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = BrandUpdateParams.builder().brandId("brand_id").name("name").build() - - assertThat(params._pathParam(0)).isEqualTo("brand_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - BrandUpdateParams.builder() - .brandId("brand_id") - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - assertThat(body.settings()) - .contains( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - assertThat(body.snippets()) - .contains( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = BrandUpdateParams.builder().brandId("brand_id").name("name").build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt deleted file mode 100644 index 5caab9aa..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/brands/EmailTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.brands - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class EmailTest { - - @Test - fun create() { - val email = - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - - assertThat(email._footer()).isEqualTo(JsonValue.from(mapOf())) - assertThat(email._header()).isEqualTo(JsonValue.from(mapOf())) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val email = - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - - val roundtrippedEmail = - jsonMapper.readValue(jsonMapper.writeValueAsString(email), jacksonTypeRef()) - - assertThat(roundtrippedEmail).isEqualTo(email) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt deleted file mode 100644 index 5a012951..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkAddUsersParamsTest.kt +++ /dev/null @@ -1,433 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.send.MessageContext -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkAddUsersParamsTest { - - @Test - fun create() { - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser(InboundBulkMessageUser.builder().build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.users()) - .containsExactly( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser(InboundBulkMessageUser.builder().build()) - .build() - - val body = params._body() - - assertThat(body.users()).containsExactly(InboundBulkMessageUser.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt deleted file mode 100644 index 0726af46..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobParamsTest.kt +++ /dev/null @@ -1,442 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.Utm -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkCreateJobParamsTest { - - @Test - fun create() { - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .build() - } - - @Test - fun body() { - val params = - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to - mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() - ) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.message()) - .isEqualTo( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BulkCreateJobParams.builder().message(InboundBulkMessage.builder().build()).build() - - val body = params._body() - - assertThat(body.message()).isEqualTo(InboundBulkMessage.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt deleted file mode 100644 index 07dc583e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkCreateJobResponseTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkCreateJobResponseTest { - - @Test - fun create() { - val bulkCreateJobResponse = BulkCreateJobResponse.builder().jobId("jobId").build() - - assertThat(bulkCreateJobResponse.jobId()).isEqualTo("jobId") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkCreateJobResponse = BulkCreateJobResponse.builder().jobId("jobId").build() - - val roundtrippedBulkCreateJobResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkCreateJobResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkCreateJobResponse).isEqualTo(bulkCreateJobResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt deleted file mode 100644 index fd0af7b0..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkListUsersParamsTest { - - @Test - fun create() { - BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - } - - @Test - fun pathParams() { - val params = BulkListUsersParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BulkListUsersParams.builder().jobId("job_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt deleted file mode 100644 index e3eeea91..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkListUsersResponseTest.kt +++ /dev/null @@ -1,436 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.send.MessageContext -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkListUsersResponseTest { - - @Test - fun create() { - val bulkListUsersResponse = - BulkListUsersResponse.builder() - .addItem( - BulkListUsersResponse.Item.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .status(BulkListUsersResponse.Item.Status.PENDING) - .messageId("messageId") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(bulkListUsersResponse.items()) - .containsExactly( - BulkListUsersResponse.Item.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .status(BulkListUsersResponse.Item.Status.PENDING) - .messageId("messageId") - .build() - ) - assertThat(bulkListUsersResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkListUsersResponse = - BulkListUsersResponse.builder() - .addItem( - BulkListUsersResponse.Item.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .status(BulkListUsersResponse.Item.Status.PENDING) - .messageId("messageId") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedBulkListUsersResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkListUsersResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkListUsersResponse).isEqualTo(bulkListUsersResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt deleted file mode 100644 index ace2bcbe..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkRetrieveJobParamsTest { - - @Test - fun create() { - BulkRetrieveJobParams.builder().jobId("job_id").build() - } - - @Test - fun pathParams() { - val params = BulkRetrieveJobParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt deleted file mode 100644 index ca80b199..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRetrieveJobResponseTest.kt +++ /dev/null @@ -1,511 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.Utm -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkRetrieveJobResponseTest { - - @Test - fun create() { - val bulkRetrieveJobResponse = - BulkRetrieveJobResponse.builder() - .job( - BulkRetrieveJobResponse.Job.builder() - .definition( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to - mapOf( - "channel" to 0, - "provider" to 0, - ), - ) - ), - ) - .build() - ) - .context( - MessageContext.builder().tenantId("tenant_id").build() - ) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay( - BaseMessage.Delay.builder() - .duration(0L) - .until("until") - .build() - ) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(0), - ) - .build() - ) - .criteria( - BaseMessage.Timeout.Criteria.NO_ESCALATION - ) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(0), - ) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .enqueued(0L) - .failures(0L) - .received(0L) - .status(BulkRetrieveJobResponse.Job.Status.CREATED) - .build() - ) - .build() - - assertThat(bulkRetrieveJobResponse.job()) - .isEqualTo( - BulkRetrieveJobResponse.Job.builder() - .definition( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to - mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay( - BaseMessage.Delay.builder() - .duration(0L) - .until("until") - .build() - ) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .enqueued(0L) - .failures(0L) - .received(0L) - .status(BulkRetrieveJobResponse.Job.Status.CREATED) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val bulkRetrieveJobResponse = - BulkRetrieveJobResponse.builder() - .job( - BulkRetrieveJobResponse.Job.builder() - .definition( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to - mapOf( - "channel" to 0, - "provider" to 0, - ), - ) - ), - ) - .build() - ) - .context( - MessageContext.builder().tenantId("tenant_id").build() - ) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay( - BaseMessage.Delay.builder() - .duration(0L) - .until("until") - .build() - ) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to - "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(0), - ) - .build() - ) - .criteria( - BaseMessage.Timeout.Criteria.NO_ESCALATION - ) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(0), - ) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .enqueued(0L) - .failures(0L) - .received(0L) - .status(BulkRetrieveJobResponse.Job.Status.CREATED) - .build() - ) - .build() - - val roundtrippedBulkRetrieveJobResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(bulkRetrieveJobResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBulkRetrieveJobResponse).isEqualTo(bulkRetrieveJobResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt deleted file mode 100644 index 9feb5964..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/BulkRunJobParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BulkRunJobParamsTest { - - @Test - fun create() { - BulkRunJobParams.builder().jobId("job_id").build() - } - - @Test - fun pathParams() { - val params = BulkRunJobParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt deleted file mode 100644 index 83892784..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageTest.kt +++ /dev/null @@ -1,431 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.Utm -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InboundBulkMessageTest { - - @Test - fun create() { - val inboundBulkMessage = - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - - assertThat(inboundBulkMessage.brand()).contains("brand") - assertThat(inboundBulkMessage.data()) - .contains( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(inboundBulkMessage.event()).contains("event") - assertThat(inboundBulkMessage.locale()) - .contains( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(inboundBulkMessage.message()) - .contains( - InboundBulkMessage.Message.ofInboundBulkTemplate( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - ) - assertThat(inboundBulkMessage._override()).isEqualTo(JsonValue.from(mapOf())) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val inboundBulkMessage = - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - - val roundtrippedInboundBulkMessage = - jsonMapper.readValue( - jsonMapper.writeValueAsString(inboundBulkMessage), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInboundBulkMessage).isEqualTo(inboundBulkMessage) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt deleted file mode 100644 index fa0c9c8a..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/InboundBulkMessageUserTest.kt +++ /dev/null @@ -1,369 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.send.MessageContext -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InboundBulkMessageUserTest { - - @Test - fun create() { - val inboundBulkMessageUser = - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - - assertThat(inboundBulkMessageUser._data()).isEqualTo(JsonValue.from(mapOf())) - assertThat(inboundBulkMessageUser.preferences()) - .contains( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - assertThat(inboundBulkMessageUser._profile()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(inboundBulkMessageUser.recipient()).contains("recipient") - assertThat(inboundBulkMessageUser.to()) - .contains( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val inboundBulkMessageUser = - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - - val roundtrippedInboundBulkMessageUser = - jsonMapper.readValue( - jsonMapper.writeValueAsString(inboundBulkMessageUser), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInboundBulkMessageUser).isEqualTo(inboundBulkMessageUser) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt deleted file mode 100644 index 85d5306b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/bulk/UserRecipientTest.kt +++ /dev/null @@ -1,201 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.bulk - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.send.MessageContext -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UserRecipientTest { - - @Test - fun create() { - val userRecipient = - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - - assertThat(userRecipient.accountId()).contains("account_id") - assertThat(userRecipient.context()) - .contains(MessageContext.builder().tenantId("tenant_id").build()) - assertThat(userRecipient.data()) - .contains( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(userRecipient.email()).contains("email") - assertThat(userRecipient.locale()).contains("locale") - assertThat(userRecipient.phoneNumber()).contains("phone_number") - assertThat(userRecipient.preferences()) - .contains( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - assertThat(userRecipient.tenantId()).contains("tenant_id") - assertThat(userRecipient.userId()).contains("user_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val userRecipient = - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - - val roundtrippedUserRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(userRecipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUserRecipient).isEqualTo(userRecipient) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt deleted file mode 100644 index 5015b259..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventParamsTest.kt +++ /dev/null @@ -1,91 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.inbound - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InboundTrackEventParamsTest { - - @Test - fun create() { - InboundTrackEventParams.builder() - .event("New Order Placed") - .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") - .properties( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - .type(InboundTrackEventParams.Type.TRACK) - .userId("1234") - .build() - } - - @Test - fun body() { - val params = - InboundTrackEventParams.builder() - .event("New Order Placed") - .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") - .properties( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - .type(InboundTrackEventParams.Type.TRACK) - .userId("1234") - .build() - - val body = params._body() - - assertThat(body.event()).isEqualTo("New Order Placed") - assertThat(body.messageId()).isEqualTo("4c62c457-b329-4bea-9bfc-17bba86c393f") - assertThat(body.properties()) - .isEqualTo( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - assertThat(body.type()).isEqualTo(InboundTrackEventParams.Type.TRACK) - assertThat(body.userId()).contains("1234") - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - InboundTrackEventParams.builder() - .event("New Order Placed") - .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") - .properties( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - .type(InboundTrackEventParams.Type.TRACK) - .build() - - val body = params._body() - - assertThat(body.event()).isEqualTo("New Order Placed") - assertThat(body.messageId()).isEqualTo("4c62c457-b329-4bea-9bfc-17bba86c393f") - assertThat(body.properties()) - .isEqualTo( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - assertThat(body.type()).isEqualTo(InboundTrackEventParams.Type.TRACK) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt deleted file mode 100644 index dfe1fd97..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/inbound/InboundTrackEventResponseTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.inbound - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class InboundTrackEventResponseTest { - - @Test - fun create() { - val inboundTrackEventResponse = - InboundTrackEventResponse.builder() - .messageId("1-65f240a0-47a6a120c8374de9bcf9f22c") - .build() - - assertThat(inboundTrackEventResponse.messageId()) - .isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val inboundTrackEventResponse = - InboundTrackEventResponse.builder() - .messageId("1-65f240a0-47a6a120c8374de9bcf9f22c") - .build() - - val roundtrippedInboundTrackEventResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(inboundTrackEventResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedInboundTrackEventResponse).isEqualTo(inboundTrackEventResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt deleted file mode 100644 index 09d23fe3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListDeleteParamsTest { - - @Test - fun create() { - ListDeleteParams.builder().listId("list_id").build() - } - - @Test - fun pathParams() { - val params = ListDeleteParams.builder().listId("list_id").build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt deleted file mode 100644 index 01e1f7ab..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListParamsTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListListParamsTest { - - @Test - fun create() { - ListListParams.builder().cursor("cursor").pattern("pattern").build() - } - - @Test - fun queryParams() { - val params = ListListParams.builder().cursor("cursor").pattern("pattern").build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder().put("cursor", "cursor").put("pattern", "pattern").build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = ListListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt deleted file mode 100644 index 2f61684a..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListListResponseTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListListResponseTest { - - @Test - fun create() { - val listListResponse = - ListListResponse.builder() - .addItem( - List.builder() - .id("id") - .name("name") - .created("created") - .updated("updated") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(listListResponse.items()) - .containsExactly( - List.builder().id("id").name("name").created("created").updated("updated").build() - ) - assertThat(listListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val listListResponse = - ListListResponse.builder() - .addItem( - List.builder() - .id("id") - .name("name") - .created("created") - .updated("updated") - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedListListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(listListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedListListResponse).isEqualTo(listListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt deleted file mode 100644 index 934eb5db..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRestoreParamsTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListRestoreParamsTest { - - @Test - fun create() { - ListRestoreParams.builder() - .listId("list_id") - .body(JsonValue.from(mapOf())) - .build() - } - - @Test - fun pathParams() { - val params = - ListRestoreParams.builder() - .listId("list_id") - .body(JsonValue.from(mapOf())) - .build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - ListRestoreParams.builder() - .listId("list_id") - .body(JsonValue.from(mapOf())) - .build() - - val body = params._body() - - assertThat(body).isEqualTo(JsonValue.from(mapOf())) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt deleted file mode 100644 index 907f8b4e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListRetrieveParamsTest { - - @Test - fun create() { - ListRetrieveParams.builder().listId("list_id").build() - } - - @Test - fun pathParams() { - val params = ListRetrieveParams.builder().listId("list_id").build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt deleted file mode 100644 index b7b348ac..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListTest { - - @Test - fun create() { - val list = - List.builder().id("id").name("name").created("created").updated("updated").build() - - assertThat(list.id()).isEqualTo("id") - assertThat(list.name()).isEqualTo("name") - assertThat(list.created()).contains("created") - assertThat(list.updated()).contains("updated") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val list = - List.builder().id("id").name("name").created("created").updated("updated").build() - - val roundtrippedList = - jsonMapper.readValue(jsonMapper.writeValueAsString(list), jacksonTypeRef()) - - assertThat(roundtrippedList).isEqualTo(list) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt deleted file mode 100644 index 64553174..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/ListUpdateParamsTest.kt +++ /dev/null @@ -1,163 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists - -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListUpdateParamsTest { - - @Test - fun create() { - ListUpdateParams.builder() - .listId("list_id") - .name("name") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = ListUpdateParams.builder().listId("list_id").name("name").build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - ListUpdateParams.builder() - .listId("list_id") - .name("name") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - assertThat(body.preferences()) - .contains( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = ListUpdateParams.builder().listId("list_id").name("name").build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt deleted file mode 100644 index e404844f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/NotificationPreferenceDetailsTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.jsonMapper -import com.courier.api.models.ChannelPreference -import com.courier.api.models.Rule -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.users.preferences.PreferenceStatus -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NotificationPreferenceDetailsTest { - - @Test - fun create() { - val notificationPreferenceDetails = - NotificationPreferenceDetails.builder() - .status(PreferenceStatus.OPTED_IN) - .addChannelPreference( - ChannelPreference.builder() - .channel(ChannelClassification.DIRECT_MESSAGE) - .build() - ) - .addRule(Rule.builder().until("until").start("start").build()) - .build() - - assertThat(notificationPreferenceDetails.status()).isEqualTo(PreferenceStatus.OPTED_IN) - assertThat(notificationPreferenceDetails.channelPreferences().getOrNull()) - .containsExactly( - ChannelPreference.builder().channel(ChannelClassification.DIRECT_MESSAGE).build() - ) - assertThat(notificationPreferenceDetails.rules().getOrNull()) - .containsExactly(Rule.builder().until("until").start("start").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val notificationPreferenceDetails = - NotificationPreferenceDetails.builder() - .status(PreferenceStatus.OPTED_IN) - .addChannelPreference( - ChannelPreference.builder() - .channel(ChannelClassification.DIRECT_MESSAGE) - .build() - ) - .addRule(Rule.builder().until("until").start("start").build()) - .build() - - val roundtrippedNotificationPreferenceDetails = - jsonMapper.readValue( - jsonMapper.writeValueAsString(notificationPreferenceDetails), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNotificationPreferenceDetails) - .isEqualTo(notificationPreferenceDetails) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt deleted file mode 100644 index 1287a144..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/PutSubscriptionsRecipientTest.kt +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PutSubscriptionsRecipientTest { - - @Test - fun create() { - val putSubscriptionsRecipient = - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - - assertThat(putSubscriptionsRecipient.recipientId()).isEqualTo("recipientId") - assertThat(putSubscriptionsRecipient.preferences()) - .contains( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val putSubscriptionsRecipient = - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - - val roundtrippedPutSubscriptionsRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(putSubscriptionsRecipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPutSubscriptionsRecipient).isEqualTo(putSubscriptionsRecipient) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt deleted file mode 100644 index 5bf58f9d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/RecipientPreferencesTest.kt +++ /dev/null @@ -1,128 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RecipientPreferencesTest { - - @Test - fun create() { - val recipientPreferences = - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - - assertThat(recipientPreferences.categories()) - .contains( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - assertThat(recipientPreferences.notifications()) - .contains( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val recipientPreferences = - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - - val roundtrippedRecipientPreferences = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipientPreferences), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipientPreferences).isEqualTo(recipientPreferences) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt deleted file mode 100644 index 32193c77..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionAddParamsTest.kt +++ /dev/null @@ -1,217 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionAddParamsTest { - - @Test - fun create() { - SubscriptionAddParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - SubscriptionAddParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder().recipientId("recipientId").build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - SubscriptionAddParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.recipients()) - .containsExactly( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - SubscriptionAddParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder().recipientId("recipientId").build() - ) - .build() - - val body = params._body() - - assertThat(body.recipients()) - .containsExactly(PutSubscriptionsRecipient.builder().recipientId("recipientId").build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt deleted file mode 100644 index ade25b2f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionListParamsTest { - - @Test - fun create() { - SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() - } - - @Test - fun pathParams() { - val params = SubscriptionListParams.builder().listId("list_id").build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = SubscriptionListParams.builder().listId("list_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt deleted file mode 100644 index 5943c470..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionListResponseTest.kt +++ /dev/null @@ -1,206 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionListResponseTest { - - @Test - fun create() { - val subscriptionListResponse = - SubscriptionListResponse.builder() - .addItem( - SubscriptionListResponse.Item.builder() - .recipientId("recipientId") - .created("created") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(subscriptionListResponse.items()) - .containsExactly( - SubscriptionListResponse.Item.builder() - .recipientId("recipientId") - .created("created") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - assertThat(subscriptionListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionListResponse = - SubscriptionListResponse.builder() - .addItem( - SubscriptionListResponse.Item.builder() - .recipientId("recipientId") - .created("created") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedSubscriptionListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(subscriptionListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedSubscriptionListResponse).isEqualTo(subscriptionListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt deleted file mode 100644 index ff37366e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeParamsTest.kt +++ /dev/null @@ -1,217 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionSubscribeParamsTest { - - @Test - fun create() { - SubscriptionSubscribeParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - SubscriptionSubscribeParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder().recipientId("recipientId").build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - SubscriptionSubscribeParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.recipients()) - .containsExactly( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - SubscriptionSubscribeParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder().recipientId("recipientId").build() - ) - .build() - - val body = params._body() - - assertThat(body.recipients()) - .containsExactly(PutSubscriptionsRecipient.builder().recipientId("recipientId").build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt deleted file mode 100644 index a60befae..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionSubscribeUserParamsTest.kt +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionSubscribeUserParamsTest { - - @Test - fun create() { - SubscriptionSubscribeUserParams.builder() - .listId("list_id") - .userId("user_id") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - SubscriptionSubscribeUserParams.builder().listId("list_id").userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - assertThat(params._pathParam(1)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - SubscriptionSubscribeUserParams.builder() - .listId("list_id") - .userId("user_id") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.preferences()) - .contains( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - SubscriptionSubscribeUserParams.builder().listId("list_id").userId("user_id").build() - - val body = params._body() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt deleted file mode 100644 index 054cbb3c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/lists/subscriptions/SubscriptionUnsubscribeUserParamsTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.lists.subscriptions - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionUnsubscribeUserParamsTest { - - @Test - fun create() { - SubscriptionUnsubscribeUserParams.builder().listId("list_id").userId("user_id").build() - } - - @Test - fun pathParams() { - val params = - SubscriptionUnsubscribeUserParams.builder().listId("list_id").userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("list_id") - assertThat(params._pathParam(1)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt deleted file mode 100644 index 2d76ba16..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageCancelParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageCancelParamsTest { - - @Test - fun create() { - MessageCancelParams.builder().messageId("message_id").build() - } - - @Test - fun pathParams() { - val params = MessageCancelParams.builder().messageId("message_id").build() - - assertThat(params._pathParam(0)).isEqualTo("message_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt deleted file mode 100644 index 359fe01d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageContentParamsTest { - - @Test - fun create() { - MessageContentParams.builder().messageId("message_id").build() - } - - @Test - fun pathParams() { - val params = MessageContentParams.builder().messageId("message_id").build() - - assertThat(params._pathParam(0)).isEqualTo("message_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt deleted file mode 100644 index cb5a08b5..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageContentResponseTest.kt +++ /dev/null @@ -1,99 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageContentResponseTest { - - @Test - fun create() { - val messageContentResponse = - MessageContentResponse.builder() - .addResult( - MessageContentResponse.Result.builder() - .channel("channel") - .channelId("channel_id") - .content( - MessageContentResponse.Result.Content.builder() - .addBlock( - MessageContentResponse.Result.Content.Block.builder() - .text("text") - .type("type") - .build() - ) - .body("body") - .html("html") - .subject("subject") - .text("text") - .title("title") - .build() - ) - .build() - ) - .build() - - assertThat(messageContentResponse.results()) - .containsExactly( - MessageContentResponse.Result.builder() - .channel("channel") - .channelId("channel_id") - .content( - MessageContentResponse.Result.Content.builder() - .addBlock( - MessageContentResponse.Result.Content.Block.builder() - .text("text") - .type("type") - .build() - ) - .body("body") - .html("html") - .subject("subject") - .text("text") - .title("title") - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val messageContentResponse = - MessageContentResponse.builder() - .addResult( - MessageContentResponse.Result.builder() - .channel("channel") - .channelId("channel_id") - .content( - MessageContentResponse.Result.Content.builder() - .addBlock( - MessageContentResponse.Result.Content.Block.builder() - .text("text") - .type("type") - .build() - ) - .body("body") - .html("html") - .subject("subject") - .text("text") - .title("title") - .build() - ) - .build() - ) - .build() - - val roundtrippedMessageContentResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(messageContentResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMessageContentResponse).isEqualTo(messageContentResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt deleted file mode 100644 index de505845..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageDetailsTest.kt +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageDetailsTest { - - @Test - fun create() { - val messageDetails = - MessageDetails.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .build() - - assertThat(messageDetails.id()).isEqualTo("id") - assertThat(messageDetails.clicked()).isEqualTo(0L) - assertThat(messageDetails.delivered()).isEqualTo(0L) - assertThat(messageDetails.enqueued()).isEqualTo(0L) - assertThat(messageDetails.event()).isEqualTo("event") - assertThat(messageDetails.notification()).isEqualTo("notification") - assertThat(messageDetails.opened()).isEqualTo(0L) - assertThat(messageDetails.recipient()).isEqualTo("recipient") - assertThat(messageDetails.sent()).isEqualTo(0L) - assertThat(messageDetails.status()).isEqualTo(MessageDetails.Status.CANCELED) - assertThat(messageDetails.error()).contains("error") - assertThat(messageDetails.reason()).contains(MessageDetails.Reason.BOUNCED) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val messageDetails = - MessageDetails.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .build() - - val roundtrippedMessageDetails = - jsonMapper.readValue( - jsonMapper.writeValueAsString(messageDetails), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMessageDetails).isEqualTo(messageDetails) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt deleted file mode 100644 index c1c71c4c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageHistoryParamsTest { - - @Test - fun create() { - MessageHistoryParams.builder().messageId("message_id").type("type").build() - } - - @Test - fun pathParams() { - val params = MessageHistoryParams.builder().messageId("message_id").build() - - assertThat(params._pathParam(0)).isEqualTo("message_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = MessageHistoryParams.builder().messageId("message_id").type("type").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("type", "type").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = MessageHistoryParams.builder().messageId("message_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt deleted file mode 100644 index 3840c4e3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageHistoryResponseTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageHistoryResponseTest { - - @Test - fun create() { - val messageHistoryResponse = - MessageHistoryResponse.builder() - .addResult( - MessageHistoryResponse.Result.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - assertThat(messageHistoryResponse.results()) - .containsExactly( - MessageHistoryResponse.Result.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val messageHistoryResponse = - MessageHistoryResponse.builder() - .addResult( - MessageHistoryResponse.Result.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val roundtrippedMessageHistoryResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(messageHistoryResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMessageHistoryResponse).isEqualTo(messageHistoryResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt deleted file mode 100644 index 06844658..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListParamsTest.kt +++ /dev/null @@ -1,82 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageListParamsTest { - - @Test - fun create() { - MessageListParams.builder() - .archived(true) - .cursor("cursor") - .enqueuedAfter("enqueued_after") - .event("event") - .list("list") - .messageId("messageId") - .notification("notification") - .addProvider("string") - .recipient("recipient") - .addStatus("string") - .addTag("string") - .tags("tags") - .tenantId("tenant_id") - .traceId("traceId") - .build() - } - - @Test - fun queryParams() { - val params = - MessageListParams.builder() - .archived(true) - .cursor("cursor") - .enqueuedAfter("enqueued_after") - .event("event") - .list("list") - .messageId("messageId") - .notification("notification") - .addProvider("string") - .recipient("recipient") - .addStatus("string") - .addTag("string") - .tags("tags") - .tenantId("tenant_id") - .traceId("traceId") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("archived", "true") - .put("cursor", "cursor") - .put("enqueued_after", "enqueued_after") - .put("event", "event") - .put("list", "list") - .put("messageId", "messageId") - .put("notification", "notification") - .put("provider", listOf("string").joinToString(",")) - .put("recipient", "recipient") - .put("status", listOf("string").joinToString(",")) - .put("tag", listOf("string").joinToString(",")) - .put("tags", "tags") - .put("tenant_id", "tenant_id") - .put("traceId", "traceId") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = MessageListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt deleted file mode 100644 index b6a3e256..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageListResponseTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageListResponseTest { - - @Test - fun create() { - val messageListResponse = - MessageListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - MessageDetails.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .build() - ) - .build() - - assertThat(messageListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - assertThat(messageListResponse.results()) - .containsExactly( - MessageDetails.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val messageListResponse = - MessageListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - MessageDetails.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .build() - ) - .build() - - val roundtrippedMessageListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(messageListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMessageListResponse).isEqualTo(messageListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt deleted file mode 100644 index 111a3262..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageRetrieveParamsTest { - - @Test - fun create() { - MessageRetrieveParams.builder().messageId("message_id").build() - } - - @Test - fun pathParams() { - val params = MessageRetrieveParams.builder().messageId("message_id").build() - - assertThat(params._pathParam(0)).isEqualTo("message_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt deleted file mode 100644 index 0ed0c62d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/messages/MessageRetrieveResponseTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.messages - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MessageRetrieveResponseTest { - - @Test - fun create() { - val messageRetrieveResponse = - MessageRetrieveResponse.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .addProvider( - MessageRetrieveResponse.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - assertThat(messageRetrieveResponse.id()).isEqualTo("id") - assertThat(messageRetrieveResponse.clicked()).isEqualTo(0L) - assertThat(messageRetrieveResponse.delivered()).isEqualTo(0L) - assertThat(messageRetrieveResponse.enqueued()).isEqualTo(0L) - assertThat(messageRetrieveResponse.event()).isEqualTo("event") - assertThat(messageRetrieveResponse.notification()).isEqualTo("notification") - assertThat(messageRetrieveResponse.opened()).isEqualTo(0L) - assertThat(messageRetrieveResponse.recipient()).isEqualTo("recipient") - assertThat(messageRetrieveResponse.sent()).isEqualTo(0L) - assertThat(messageRetrieveResponse.status()).isEqualTo(MessageDetails.Status.CANCELED) - assertThat(messageRetrieveResponse.error()).contains("error") - assertThat(messageRetrieveResponse.reason()).contains(MessageDetails.Reason.BOUNCED) - assertThat(messageRetrieveResponse.providers().getOrNull()) - .containsExactly( - MessageRetrieveResponse.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val messageRetrieveResponse = - MessageRetrieveResponse.builder() - .id("id") - .clicked(0L) - .delivered(0L) - .enqueued(0L) - .event("event") - .notification("notification") - .opened(0L) - .recipient("recipient") - .sent(0L) - .status(MessageDetails.Status.CANCELED) - .error("error") - .reason(MessageDetails.Reason.BOUNCED) - .addProvider( - MessageRetrieveResponse.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val roundtrippedMessageRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(messageRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMessageRetrieveResponse).isEqualTo(messageRetrieveResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt deleted file mode 100644 index c53dd38f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationGetContentTest.kt +++ /dev/null @@ -1,154 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NotificationGetContentTest { - - @Test - fun create() { - val notificationGetContent = - NotificationGetContent.builder() - .addBlock( - NotificationGetContent.Block.builder() - .id("id") - .type(NotificationGetContent.Block.Type.ACTION) - .alias("alias") - .checksum("checksum") - .content("string") - .context("context") - .locales( - NotificationGetContent.Block.Locales.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - ) - .addChannel( - NotificationGetContent.Channel.builder() - .id("id") - .checksum("checksum") - .content( - NotificationGetContent.Channel.Content.builder() - .subject("subject") - .title("title") - .build() - ) - .locales( - NotificationGetContent.Channel.Locales.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf("subject" to "subject", "title" to "title") - ), - ) - .build() - ) - .type("type") - .build() - ) - .checksum("checksum") - .build() - - assertThat(notificationGetContent.blocks().getOrNull()) - .containsExactly( - NotificationGetContent.Block.builder() - .id("id") - .type(NotificationGetContent.Block.Type.ACTION) - .alias("alias") - .checksum("checksum") - .content("string") - .context("context") - .locales( - NotificationGetContent.Block.Locales.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - ) - assertThat(notificationGetContent.channels().getOrNull()) - .containsExactly( - NotificationGetContent.Channel.builder() - .id("id") - .checksum("checksum") - .content( - NotificationGetContent.Channel.Content.builder() - .subject("subject") - .title("title") - .build() - ) - .locales( - NotificationGetContent.Channel.Locales.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf("subject" to "subject", "title" to "title")), - ) - .build() - ) - .type("type") - .build() - ) - assertThat(notificationGetContent.checksum()).contains("checksum") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val notificationGetContent = - NotificationGetContent.builder() - .addBlock( - NotificationGetContent.Block.builder() - .id("id") - .type(NotificationGetContent.Block.Type.ACTION) - .alias("alias") - .checksum("checksum") - .content("string") - .context("context") - .locales( - NotificationGetContent.Block.Locales.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .build() - ) - .addChannel( - NotificationGetContent.Channel.builder() - .id("id") - .checksum("checksum") - .content( - NotificationGetContent.Channel.Content.builder() - .subject("subject") - .title("title") - .build() - ) - .locales( - NotificationGetContent.Channel.Locales.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf("subject" to "subject", "title" to "title") - ), - ) - .build() - ) - .type("type") - .build() - ) - .checksum("checksum") - .build() - - val roundtrippedNotificationGetContent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(notificationGetContent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNotificationGetContent).isEqualTo(notificationGetContent) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt deleted file mode 100644 index 0fb4a5ea..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListParamsTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NotificationListParamsTest { - - @Test - fun create() { - NotificationListParams.builder().cursor("cursor").notes(true).build() - } - - @Test - fun queryParams() { - val params = NotificationListParams.builder().cursor("cursor").notes(true).build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("notes", "true").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = NotificationListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt deleted file mode 100644 index 8346a157..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationListResponseTest.kt +++ /dev/null @@ -1,119 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NotificationListResponseTest { - - @Test - fun create() { - val notificationListResponse = - NotificationListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - NotificationListResponse.Result.builder() - .id("id") - .createdAt(0L) - .note("note") - .routing( - MessageRouting.builder() - .addChannel("string") - .method(MessageRouting.Method.ALL) - .build() - ) - .topicId("topic_id") - .updatedAt(0L) - .tags( - NotificationListResponse.Result.Tags.builder() - .addData( - NotificationListResponse.Result.Tags.Data.builder() - .id("id") - .name("name") - .build() - ) - .build() - ) - .title("title") - .build() - ) - .build() - - assertThat(notificationListResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - assertThat(notificationListResponse.results()) - .containsExactly( - NotificationListResponse.Result.builder() - .id("id") - .createdAt(0L) - .note("note") - .routing( - MessageRouting.builder() - .addChannel("string") - .method(MessageRouting.Method.ALL) - .build() - ) - .topicId("topic_id") - .updatedAt(0L) - .tags( - NotificationListResponse.Result.Tags.builder() - .addData( - NotificationListResponse.Result.Tags.Data.builder() - .id("id") - .name("name") - .build() - ) - .build() - ) - .title("title") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val notificationListResponse = - NotificationListResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - NotificationListResponse.Result.builder() - .id("id") - .createdAt(0L) - .note("note") - .routing( - MessageRouting.builder() - .addChannel("string") - .method(MessageRouting.Method.ALL) - .build() - ) - .topicId("topic_id") - .updatedAt(0L) - .tags( - NotificationListResponse.Result.Tags.builder() - .addData( - NotificationListResponse.Result.Tags.Data.builder() - .id("id") - .name("name") - .build() - ) - .build() - ) - .title("title") - .build() - ) - .build() - - val roundtrippedNotificationListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(notificationListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedNotificationListResponse).isEqualTo(notificationListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt deleted file mode 100644 index e402cd97..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/NotificationRetrieveContentParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class NotificationRetrieveContentParamsTest { - - @Test - fun create() { - NotificationRetrieveContentParams.builder().id("id").build() - } - - @Test - fun pathParams() { - val params = NotificationRetrieveContentParams.builder().id("id").build() - - assertThat(params._pathParam(0)).isEqualTo("id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt deleted file mode 100644 index 6c71dfd8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/BaseCheckTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BaseCheckTest { - - @Test - fun create() { - val baseCheck = - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - - assertThat(baseCheck.id()).isEqualTo("id") - assertThat(baseCheck.status()).isEqualTo(BaseCheck.Status.RESOLVED) - assertThat(baseCheck.type()).isEqualTo(BaseCheck.Type.CUSTOM) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val baseCheck = - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - - val roundtrippedBaseCheck = - jsonMapper.readValue( - jsonMapper.writeValueAsString(baseCheck), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBaseCheck).isEqualTo(baseCheck) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt deleted file mode 100644 index b6052a50..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckDeleteParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CheckDeleteParamsTest { - - @Test - fun create() { - CheckDeleteParams.builder().id("id").submissionId("submissionId").build() - } - - @Test - fun pathParams() { - val params = CheckDeleteParams.builder().id("id").submissionId("submissionId").build() - - assertThat(params._pathParam(0)).isEqualTo("id") - assertThat(params._pathParam(1)).isEqualTo("submissionId") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt deleted file mode 100644 index 08bf67b8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CheckListParamsTest { - - @Test - fun create() { - CheckListParams.builder().id("id").submissionId("submissionId").build() - } - - @Test - fun pathParams() { - val params = CheckListParams.builder().id("id").submissionId("submissionId").build() - - assertThat(params._pathParam(0)).isEqualTo("id") - assertThat(params._pathParam(1)).isEqualTo("submissionId") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt deleted file mode 100644 index 8a962db5..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckListResponseTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CheckListResponseTest { - - @Test - fun create() { - val checkListResponse = - CheckListResponse.builder() - .addCheck( - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - ) - .build() - - assertThat(checkListResponse.checks()) - .containsExactly( - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val checkListResponse = - CheckListResponse.builder() - .addCheck( - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - ) - .build() - - val roundtrippedCheckListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(checkListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedCheckListResponse).isEqualTo(checkListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt deleted file mode 100644 index 541aa366..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CheckTest { - - @Test - fun create() { - val check = - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - - assertThat(check.id()).isEqualTo("id") - assertThat(check.status()).isEqualTo(BaseCheck.Status.RESOLVED) - assertThat(check.type()).isEqualTo(BaseCheck.Type.CUSTOM) - assertThat(check.updated()).isEqualTo(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val check = - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - - val roundtrippedCheck = - jsonMapper.readValue(jsonMapper.writeValueAsString(check), jacksonTypeRef()) - - assertThat(roundtrippedCheck).isEqualTo(check) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt deleted file mode 100644 index e16d02bd..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateParamsTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CheckUpdateParamsTest { - - @Test - fun create() { - CheckUpdateParams.builder() - .id("id") - .submissionId("submissionId") - .addCheck( - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - CheckUpdateParams.builder() - .id("id") - .submissionId("submissionId") - .addCheck( - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("id") - assertThat(params._pathParam(1)).isEqualTo("submissionId") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - CheckUpdateParams.builder() - .id("id") - .submissionId("submissionId") - .addCheck( - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.checks()) - .containsExactly( - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt deleted file mode 100644 index d9023651..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/checks/CheckUpdateResponseTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.checks - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class CheckUpdateResponseTest { - - @Test - fun create() { - val checkUpdateResponse = - CheckUpdateResponse.builder() - .addCheck( - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - ) - .build() - - assertThat(checkUpdateResponse.checks()) - .containsExactly( - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val checkUpdateResponse = - CheckUpdateResponse.builder() - .addCheck( - Check.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .updated(0L) - .build() - ) - .build() - - val roundtrippedCheckUpdateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(checkUpdateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedCheckUpdateResponse).isEqualTo(checkUpdateResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt deleted file mode 100644 index 04f83d08..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/draft/DraftRetrieveContentParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.notifications.draft - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class DraftRetrieveContentParamsTest { - - @Test - fun create() { - DraftRetrieveContentParams.builder().id("id").build() - } - - @Test - fun pathParams() { - val params = DraftRetrieveContentParams.builder().id("id").build() - - assertThat(params._pathParam(0)).isEqualTo("id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt deleted file mode 100644 index d5fcdf04..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateParamsTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileCreateParamsTest { - - @Test - fun create() { - ProfileCreateParams.builder() - .userId("user_id") - .profile( - ProfileCreateParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - ProfileCreateParams.builder() - .userId("user_id") - .profile( - ProfileCreateParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - ProfileCreateParams.builder() - .userId("user_id") - .profile( - ProfileCreateParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.profile()) - .isEqualTo( - ProfileCreateParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt deleted file mode 100644 index f116cca8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileCreateResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileCreateResponseTest { - - @Test - fun create() { - val profileCreateResponse = - ProfileCreateResponse.builder().status(ProfileCreateResponse.Status.SUCCESS).build() - - assertThat(profileCreateResponse.status()).isEqualTo(ProfileCreateResponse.Status.SUCCESS) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val profileCreateResponse = - ProfileCreateResponse.builder().status(ProfileCreateResponse.Status.SUCCESS).build() - - val roundtrippedProfileCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(profileCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedProfileCreateResponse).isEqualTo(profileCreateResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt deleted file mode 100644 index 25329c9f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileDeleteParamsTest { - - @Test - fun create() { - ProfileDeleteParams.builder().userId("user_id").build() - } - - @Test - fun pathParams() { - val params = ProfileDeleteParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt deleted file mode 100644 index c526eba3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceParamsTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileReplaceParamsTest { - - @Test - fun create() { - ProfileReplaceParams.builder() - .userId("user_id") - .profile( - ProfileReplaceParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - ProfileReplaceParams.builder() - .userId("user_id") - .profile( - ProfileReplaceParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - ProfileReplaceParams.builder() - .userId("user_id") - .profile( - ProfileReplaceParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.profile()) - .isEqualTo( - ProfileReplaceParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt deleted file mode 100644 index b7c84d1a..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileReplaceResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileReplaceResponseTest { - - @Test - fun create() { - val profileReplaceResponse = - ProfileReplaceResponse.builder().status(ProfileReplaceResponse.Status.SUCCESS).build() - - assertThat(profileReplaceResponse.status()).isEqualTo(ProfileReplaceResponse.Status.SUCCESS) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val profileReplaceResponse = - ProfileReplaceResponse.builder().status(ProfileReplaceResponse.Status.SUCCESS).build() - - val roundtrippedProfileReplaceResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(profileReplaceResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedProfileReplaceResponse).isEqualTo(profileReplaceResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt deleted file mode 100644 index 27296002..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileRetrieveParamsTest { - - @Test - fun create() { - ProfileRetrieveParams.builder().userId("user_id").build() - } - - @Test - fun pathParams() { - val params = ProfileRetrieveParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt deleted file mode 100644 index b33a0038..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileRetrieveResponseTest.kt +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileRetrieveResponseTest { - - @Test - fun create() { - val profileRetrieveResponse = - ProfileRetrieveResponse.builder() - .profile( - ProfileRetrieveResponse.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - - assertThat(profileRetrieveResponse.profile()) - .isEqualTo( - ProfileRetrieveResponse.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(profileRetrieveResponse.preferences()) - .contains( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf(mapOf("until" to "until", "start" to "start")), - ) - ), - ) - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val profileRetrieveResponse = - ProfileRetrieveResponse.builder() - .profile( - ProfileRetrieveResponse.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - - val roundtrippedProfileRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(profileRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedProfileRetrieveResponse).isEqualTo(profileRetrieveResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt deleted file mode 100644 index 6ff75916..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/ProfileUpdateParamsTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ProfileUpdateParamsTest { - - @Test - fun create() { - ProfileUpdateParams.builder() - .userId("user_id") - .addPatch( - ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - ProfileUpdateParams.builder() - .userId("user_id") - .addPatch( - ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - ProfileUpdateParams.builder() - .userId("user_id") - .addPatch( - ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - - val body = params._body() - - assertThat(body.patch()) - .containsExactly( - ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt deleted file mode 100644 index 7bc7cad6..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListDeleteParamsTest { - - @Test - fun create() { - ListDeleteParams.builder().userId("user_id").build() - } - - @Test - fun pathParams() { - val params = ListDeleteParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt deleted file mode 100644 index 5263496f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListDeleteResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListDeleteResponseTest { - - @Test - fun create() { - val listDeleteResponse = - ListDeleteResponse.builder().status(ListDeleteResponse.Status.SUCCESS).build() - - assertThat(listDeleteResponse.status()).isEqualTo(ListDeleteResponse.Status.SUCCESS) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val listDeleteResponse = - ListDeleteResponse.builder().status(ListDeleteResponse.Status.SUCCESS).build() - - val roundtrippedListDeleteResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(listDeleteResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedListDeleteResponse).isEqualTo(listDeleteResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt deleted file mode 100644 index 9cda2937..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveParamsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListRetrieveParamsTest { - - @Test - fun create() { - ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() - } - - @Test - fun pathParams() { - val params = ListRetrieveParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().put("cursor", "cursor").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = ListRetrieveParams.builder().userId("user_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt deleted file mode 100644 index a4cf478f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListRetrieveResponseTest.kt +++ /dev/null @@ -1,213 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListRetrieveResponseTest { - - @Test - fun create() { - val listRetrieveResponse = - ListRetrieveResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - ListRetrieveResponse.Result.builder() - .id("id") - .created("created") - .name("name") - .updated("updated") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - - assertThat(listRetrieveResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - assertThat(listRetrieveResponse.results()) - .containsExactly( - ListRetrieveResponse.Result.builder() - .id("id") - .created("created") - .name("name") - .updated("updated") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val listRetrieveResponse = - ListRetrieveResponse.builder() - .paging(Paging.builder().more(true).cursor("cursor").build()) - .addResult( - ListRetrieveResponse.Result.builder() - .id("id") - .created("created") - .name("name") - .updated("updated") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - - val roundtrippedListRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(listRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedListRetrieveResponse).isEqualTo(listRetrieveResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt deleted file mode 100644 index f4f5f703..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeParamsTest.kt +++ /dev/null @@ -1,214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListSubscribeParamsTest { - - @Test - fun create() { - ListSubscribeParams.builder() - .userId("user_id") - .addList( - ListSubscribeParams.List.builder() - .listId("listId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - ListSubscribeParams.builder() - .userId("user_id") - .addList(ListSubscribeParams.List.builder().listId("listId").build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - ListSubscribeParams.builder() - .userId("user_id") - .addList( - ListSubscribeParams.List.builder() - .listId("listId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.lists()) - .containsExactly( - ListSubscribeParams.List.builder() - .listId("listId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - ListSubscribeParams.builder() - .userId("user_id") - .addList(ListSubscribeParams.List.builder().listId("listId").build()) - .build() - - val body = params._body() - - assertThat(body.lists()) - .containsExactly(ListSubscribeParams.List.builder().listId("listId").build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt deleted file mode 100644 index 952fea61..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/profiles/lists/ListSubscribeResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.profiles.lists - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ListSubscribeResponseTest { - - @Test - fun create() { - val listSubscribeResponse = - ListSubscribeResponse.builder().status(ListSubscribeResponse.Status.SUCCESS).build() - - assertThat(listSubscribeResponse.status()).isEqualTo(ListSubscribeResponse.Status.SUCCESS) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val listSubscribeResponse = - ListSubscribeResponse.builder().status(ListSubscribeResponse.Status.SUCCESS).build() - - val roundtrippedListSubscribeResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(listSubscribeResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedListSubscribeResponse).isEqualTo(listSubscribeResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt deleted file mode 100644 index b450b2c0..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/requests/RequestArchiveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.requests - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class RequestArchiveParamsTest { - - @Test - fun create() { - RequestArchiveParams.builder().requestId("request_id").build() - } - - @Test - fun pathParams() { - val params = RequestArchiveParams.builder().requestId("request_id").build() - - assertThat(params._pathParam(0)).isEqualTo("request_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt deleted file mode 100644 index 1e206ee4..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageSendToTest.kt +++ /dev/null @@ -1,96 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BaseMessageSendToTest { - - @Test - fun create() { - val baseMessageSendTo = - BaseMessageSendTo.builder() - .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF - ) - .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - ) - .build() - - assertThat(baseMessageSendTo.to()) - .contains( - BaseMessageSendTo.To.ofAudienceRecipient( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF - ) - .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - ) - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val baseMessageSendTo = - BaseMessageSendTo.builder() - .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF - ) - .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - ) - .build() - - val roundtrippedBaseMessageSendTo = - jsonMapper.readValue( - jsonMapper.writeValueAsString(baseMessageSendTo), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBaseMessageSendTo).isEqualTo(baseMessageSendTo) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt deleted file mode 100644 index 02a48bd3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/BaseMessageTest.kt +++ /dev/null @@ -1,370 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BaseMessageTest { - - @Test - fun create() { - val baseMessage = - BaseMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .build() - - assertThat(baseMessage.brandId()).contains("brand_id") - assertThat(baseMessage.channels()) - .contains( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - assertThat(baseMessage.context()) - .contains(MessageContext.builder().tenantId("tenant_id").build()) - assertThat(baseMessage.data()) - .contains( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(baseMessage.delay()) - .contains(BaseMessage.Delay.builder().duration(0L).until("until").build()) - assertThat(baseMessage.expiry()) - .contains( - BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() - ) - assertThat(baseMessage.metadata()) - .contains( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - assertThat(baseMessage.preferences()) - .contains( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - assertThat(baseMessage.providers()) - .contains( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - assertThat(baseMessage.routing()) - .contains( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - assertThat(baseMessage.timeout()) - .contains( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val baseMessage = - BaseMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .build() - - val roundtrippedBaseMessage = - jsonMapper.readValue( - jsonMapper.writeValueAsString(baseMessage), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBaseMessage).isEqualTo(baseMessage) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt deleted file mode 100644 index 04338e09..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/ContentTest.kt +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.templates.ElementalContent -import com.courier.api.models.tenants.templates.ElementalNode -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class ContentTest { - - @Test - fun ofElemental() { - val elemental = - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - - val content = Content.ofElemental(elemental) - - assertThat(content.elemental()).contains(elemental) - assertThat(content.elementalContentSugar()).isEmpty - } - - @Test - fun ofElementalRoundtrip() { - val jsonMapper = jsonMapper() - val content = - Content.ofElemental( - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - ) - - val roundtrippedContent = - jsonMapper.readValue(jsonMapper.writeValueAsString(content), jacksonTypeRef()) - - assertThat(roundtrippedContent).isEqualTo(content) - } - - @Test - fun ofElementalContentSugar() { - val elementalContentSugar = - Content.ElementalContentSugar.builder().body("body").title("title").build() - - val content = Content.ofElementalContentSugar(elementalContentSugar) - - assertThat(content.elemental()).isEmpty - assertThat(content.elementalContentSugar()).contains(elementalContentSugar) - } - - @Test - fun ofElementalContentSugarRoundtrip() { - val jsonMapper = jsonMapper() - val content = - Content.ofElementalContentSugar( - Content.ElementalContentSugar.builder().body("body").title("title").build() - ) - - val roundtrippedContent = - jsonMapper.readValue(jsonMapper.writeValueAsString(content), jacksonTypeRef()) - - assertThat(roundtrippedContent).isEqualTo(content) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val content = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { content.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageRoutingChannelTest.kt similarity index 98% rename from courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageRoutingChannelTest.kt index bf77a1d7..543414c1 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingChannelTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageRoutingChannelTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.notifications +package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageRoutingTest.kt similarity index 96% rename from courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageRoutingTest.kt index 3b26b7ec..86a26983 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/notifications/MessageRoutingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageRoutingTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.courier.api.models.notifications +package com.courier.api.models.send import com.courier.api.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt deleted file mode 100644 index 55ed144b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MessageTest.kt +++ /dev/null @@ -1,643 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.tenants.templates.ElementalContent -import com.courier.api.models.tenants.templates.ElementalNode -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class MessageTest { - - @Test - fun ofContent() { - val content = - Message.ContentMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF - ) - .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - ) - .content( - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - ) - .build() - - val message = Message.ofContent(content) - - assertThat(message.content()).contains(content) - assertThat(message.template()).isEmpty - } - - @Test - fun ofContentRoundtrip() { - val jsonMapper = jsonMapper() - val message = - Message.ofContent( - Message.ContentMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator - .MEMBER_OF - ) - .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path - .ACCOUNT_ID - ) - .value("value") - .build() - ) - .build() - ) - .content( - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - - val roundtrippedMessage = - jsonMapper.readValue(jsonMapper.writeValueAsString(message), jacksonTypeRef()) - - assertThat(roundtrippedMessage).isEqualTo(message) - } - - @Test - fun ofTemplate() { - val template = - Message.TemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator.MEMBER_OF - ) - .path(BaseMessageSendTo.To.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - ) - .template("template") - .build() - - val message = Message.ofTemplate(template) - - assertThat(message.content()).isEmpty - assertThat(message.template()).contains(template) - } - - @Test - fun ofTemplateRoundtrip() { - val jsonMapper = jsonMapper() - val message = - Message.ofTemplate( - Message.TemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - BaseMessageSendTo.To.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.AudienceRecipient.Filter.builder() - .operator( - BaseMessageSendTo.To.AudienceRecipient.Filter.Operator - .MEMBER_OF - ) - .path( - BaseMessageSendTo.To.AudienceRecipient.Filter.Path - .ACCOUNT_ID - ) - .value("value") - .build() - ) - .build() - ) - .template("template") - .build() - ) - - val roundtrippedMessage = - jsonMapper.readValue(jsonMapper.writeValueAsString(message), jacksonTypeRef()) - - assertThat(roundtrippedMessage).isEqualTo(message) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val message = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { message.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt deleted file mode 100644 index c544d37e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/MsTeamsBasePropertiesTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class MsTeamsBasePropertiesTest { - - @Test - fun create() { - val msTeamsBaseProperties = - MsTeamsBaseProperties.builder().serviceUrl("service_url").tenantId("tenant_id").build() - - assertThat(msTeamsBaseProperties.serviceUrl()).isEqualTo("service_url") - assertThat(msTeamsBaseProperties.tenantId()).isEqualTo("tenant_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val msTeamsBaseProperties = - MsTeamsBaseProperties.builder().serviceUrl("service_url").tenantId("tenant_id").build() - - val roundtrippedMsTeamsBaseProperties = - jsonMapper.readValue( - jsonMapper.writeValueAsString(msTeamsBaseProperties), - jacksonTypeRef(), - ) - - assertThat(roundtrippedMsTeamsBaseProperties).isEqualTo(msTeamsBaseProperties) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt index 15f3ccf2..5591ac5e 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/RecipientTest.kt @@ -4,200 +4,20 @@ package com.courier.api.models.send import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.courier.api.models.bulk.UserRecipient import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource internal class RecipientTest { @Test - fun ofAudience() { - val audience = - Recipient.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - Recipient.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - Recipient.AudienceRecipient.Filter.builder() - .operator(Recipient.AudienceRecipient.Filter.Operator.MEMBER_OF) - .path(Recipient.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - - val recipient = Recipient.ofAudience(audience) - - assertThat(recipient.audience()).contains(audience) - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofAudienceRoundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofAudience( - Recipient.AudienceRecipient.builder() - .audienceId("audience_id") - .data( - Recipient.AudienceRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - Recipient.AudienceRecipient.Filter.builder() - .operator(Recipient.AudienceRecipient.Filter.Operator.MEMBER_OF) - .path(Recipient.AudienceRecipient.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofUnionMember1() { - val unionMember1 = - Recipient.UnionMember1.builder() - .data( - Recipient.UnionMember1.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - Recipient.UnionMember1.Filter.builder() - .operator(Recipient.UnionMember1.Filter.Operator.MEMBER_OF) - .path(Recipient.UnionMember1.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .listId("list_id") - .build() - - val recipient = Recipient.ofUnionMember1(unionMember1) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).contains(unionMember1) - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofUnionMember1Roundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofUnionMember1( - Recipient.UnionMember1.builder() - .data( - Recipient.UnionMember1.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - Recipient.UnionMember1.Filter.builder() - .operator(Recipient.UnionMember1.Filter.Operator.MEMBER_OF) - .path(Recipient.UnionMember1.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .listId("list_id") - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofUnionMember2() { - val unionMember2 = - Recipient.UnionMember2.builder() - .data( - Recipient.UnionMember2.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .listPattern("list_pattern") - .build() - - val recipient = Recipient.ofUnionMember2(unionMember2) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).contains(unionMember2) - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofUnionMember2Roundtrip() { - val jsonMapper = jsonMapper() + fun create() { val recipient = - Recipient.ofUnionMember2( - Recipient.UnionMember2.builder() - .data( - Recipient.UnionMember2.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .listPattern("list_pattern") - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofUser() { - val user = - UserRecipient.builder() + Recipient.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - UserRecipient.Data.builder() + Recipient.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -205,9 +25,9 @@ internal class RecipientTest { .locale("locale") .phoneNumber("phone_number") .preferences( - UserRecipient.Preferences.builder() + Recipient.Preferences.builder() .notifications( - UserRecipient.Preferences.Notifications.builder() + Recipient.Preferences.Notifications.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -226,7 +46,7 @@ internal class RecipientTest { .build() ) .categories( - UserRecipient.Preferences.Categories.builder() + Recipient.Preferences.Categories.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -251,360 +71,122 @@ internal class RecipientTest { .userId("user_id") .build() - val recipient = Recipient.ofUser(user) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).contains(user) - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofUserRoundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofUser( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), + assertThat(recipient.accountId()).contains("account_id") + assertThat(recipient.context()) + .contains(MessageContext.builder().tenantId("tenant_id").build()) + assertThat(recipient.data()) + .contains( + Recipient.Data.builder().putAdditionalProperty("foo", JsonValue.from("bar")).build() + ) + assertThat(recipient.email()).contains("email") + assertThat(recipient.locale()).contains("locale") + assertThat(recipient.phoneNumber()).contains("phone_number") + assertThat(recipient.preferences()) + .contains( + Recipient.Preferences.builder() + .notifications( + Recipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + "source" to "subscription", ) - .build() + ), ) - .templateId("templateId") .build() ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofSlack() { - val slack = - Recipient.SlackRecipient.builder() - .slack( - Recipient.SlackRecipient.Slack.SendToSlackChannel.builder() - .accessToken("access_token") - .channel("channel") - .build() - ) - .build() - - val recipient = Recipient.ofSlack(slack) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).contains(slack) - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofSlackRoundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofSlack( - Recipient.SlackRecipient.builder() - .slack( - Recipient.SlackRecipient.Slack.SendToSlackChannel.builder() - .accessToken("access_token") - .channel("channel") - .build() - ) - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofMsTeams() { - val msTeams = - Recipient.MsTeamsRecipient.builder() - .msTeams( - Recipient.MsTeamsRecipient.MsTeams.SendToMsTeamsUserId.builder() - .serviceUrl("service_url") - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - - val recipient = Recipient.ofMsTeams(msTeams) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).contains(msTeams) - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofMsTeamsRoundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofMsTeams( - Recipient.MsTeamsRecipient.builder() - .msTeams( - Recipient.MsTeamsRecipient.MsTeams.SendToMsTeamsUserId.builder() - .serviceUrl("service_url") - .tenantId("tenant_id") - .userId("user_id") + .categories( + Recipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf(mapOf("until" to "until", "start" to "start")), + "source" to "subscription", + ) + ), + ) .build() ) + .templateId("templateId") .build() ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofData() { - val data = - Recipient.RecipientData.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - - val recipient = Recipient.ofData(data) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).contains(data) - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).isEmpty + assertThat(recipient.tenantId()).contains("tenant_id") + assertThat(recipient.userId()).contains("user_id") } @Test - fun ofDataRoundtrip() { + fun roundtrip() { val jsonMapper = jsonMapper() val recipient = - Recipient.ofData( - Recipient.RecipientData.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofPagerduty() { - val pagerduty = - Recipient.PagerdutyRecipient.builder() - .pagerduty( - Recipient.PagerdutyRecipient.Pagerduty.builder() - .eventAction("event_action") - .routingKey("routing_key") - .severity("severity") - .source("source") + Recipient.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + Recipient.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .build() - - val recipient = Recipient.ofPagerduty(pagerduty) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).contains(pagerduty) - assertThat(recipient.webhook()).isEmpty - } - - @Test - fun ofPagerdutyRoundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofPagerduty( - Recipient.PagerdutyRecipient.builder() - .pagerduty( - Recipient.PagerdutyRecipient.Pagerduty.builder() - .eventAction("event_action") - .routingKey("routing_key") - .severity("severity") - .source("source") - .build() - ) - .build() - ) - - val roundtrippedRecipient = - jsonMapper.readValue( - jsonMapper.writeValueAsString(recipient), - jacksonTypeRef(), - ) - - assertThat(roundtrippedRecipient).isEqualTo(recipient) - } - - @Test - fun ofWebhook() { - val webhook = - Recipient.WebhookRecipient.builder() - .webhook( - Recipient.WebhookRecipient.Webhook.builder() - .url("url") - .authentication( - Recipient.WebhookRecipient.Webhook.Authentication.builder() - .mode(Recipient.WebhookRecipient.Webhook.Authentication.Mode.NONE) - .token("token") - .password("password") - .username("username") + .email("email") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + Recipient.Preferences.builder() + .notifications( + Recipient.Preferences.Notifications.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) .build() ) - .headers( - Recipient.WebhookRecipient.Webhook.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) + .categories( + Recipient.Preferences.Categories.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf(mapOf("channel" to "direct_message")), + "rules" to + listOf( + mapOf("until" to "until", "start" to "start") + ), + "source" to "subscription", + ) + ), + ) .build() ) - .method(Recipient.WebhookRecipient.Webhook.Method.POST) - .profile(Recipient.WebhookRecipient.Webhook.Profile.LIMITED) + .templateId("templateId") .build() ) + .tenantId("tenant_id") + .userId("user_id") .build() - val recipient = Recipient.ofWebhook(webhook) - - assertThat(recipient.audience()).isEmpty - assertThat(recipient.unionMember1()).isEmpty - assertThat(recipient.unionMember2()).isEmpty - assertThat(recipient.user()).isEmpty - assertThat(recipient.slack()).isEmpty - assertThat(recipient.msTeams()).isEmpty - assertThat(recipient.data()).isEmpty - assertThat(recipient.pagerduty()).isEmpty - assertThat(recipient.webhook()).contains(webhook) - } - - @Test - fun ofWebhookRoundtrip() { - val jsonMapper = jsonMapper() - val recipient = - Recipient.ofWebhook( - Recipient.WebhookRecipient.builder() - .webhook( - Recipient.WebhookRecipient.Webhook.builder() - .url("url") - .authentication( - Recipient.WebhookRecipient.Webhook.Authentication.builder() - .mode( - Recipient.WebhookRecipient.Webhook.Authentication.Mode.NONE - ) - .token("token") - .password("password") - .username("username") - .build() - ) - .headers( - Recipient.WebhookRecipient.Webhook.Headers.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .method(Recipient.WebhookRecipient.Webhook.Method.POST) - .profile(Recipient.WebhookRecipient.Webhook.Profile.LIMITED) - .build() - ) - .build() - ) - val roundtrippedRecipient = jsonMapper.readValue( jsonMapper.writeValueAsString(recipient), @@ -613,21 +195,4 @@ internal class RecipientTest { assertThat(roundtrippedRecipient).isEqualTo(recipient) } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val recipient = jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { recipient.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } } diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt deleted file mode 100644 index 3889f463..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt +++ /dev/null @@ -1,488 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SendMessageParamsTest { - - @Test - fun create() { - SendMessageParams.builder() - .message( - Message.ContentMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("name", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.UnionMember1.builder() - .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter.Operator.MEMBER_OF - ) - .path(BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID) - .value("value") - .build() - ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") - .build() - ) - .build() - ) - .build() - } - - @Test - fun body() { - val params = - SendMessageParams.builder() - .message( - Message.ContentMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("name", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.UnionMember1.builder() - .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter.Operator - .MEMBER_OF - ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID - ) - .value("value") - .build() - ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.message()) - .isEqualTo( - Message.ofContent( - Message.ContentMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("name", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .to( - BaseMessageSendTo.To.UnionMember1.builder() - .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter.Operator - .MEMBER_OF - ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID - ) - .value("value") - .build() - ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") - .build() - ) - .build() - ) - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - SendMessageParams.builder() - .message( - Message.ContentMessage.builder() - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.message()) - .isEqualTo( - Message.ofContent( - Message.ContentMessage.builder() - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") - .build() - ) - .build() - ) - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt deleted file mode 100644 index 990f0b0b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SendMessageResponseTest { - - @Test - fun create() { - val sendMessageResponse = - SendMessageResponse.builder().requestId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() - - assertThat(sendMessageResponse.requestId()).isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val sendMessageResponse = - SendMessageResponse.builder().requestId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() - - val roundtrippedSendMessageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(sendMessageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedSendMessageResponse).isEqualTo(sendMessageResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt new file mode 100644 index 00000000..77114069 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt @@ -0,0 +1,666 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.JsonValue +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SendSendMessageParamsTest { + + @Test + fun create() { + SendSendMessageParams.builder() + .message( + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) + .brandId("brand_id") + .channels( + SendSendMessageParams.Message.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + SendSendMessageParams.Message.Data.builder() + .putAdditionalProperty("name", JsonValue.from("bar")) + .build() + ) + .delay( + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + SendSendMessageParams.Message.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + SendSendMessageParams.Message.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + SendSendMessageParams.Message.Metadata.Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + SendSendMessageParams.Message.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + SendSendMessageParams.Message.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + SendSendMessageParams.Message.Routing.builder() + .addChannel("email") + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .build() + ) + .timeout( + SendSendMessageParams.Message.Timeout.builder() + .channel( + SendSendMessageParams.Message.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + SendSendMessageParams.Message.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + SendSendMessageParams.Message.To.UnionMember0.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0.Preferences.builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + .build() + } + + @Test + fun body() { + val params = + SendSendMessageParams.builder() + .message( + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) + .brandId("brand_id") + .channels( + SendSendMessageParams.Message.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + SendSendMessageParams.Message.Data.builder() + .putAdditionalProperty("name", JsonValue.from("bar")) + .build() + ) + .delay( + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + SendSendMessageParams.Message.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + SendSendMessageParams.Message.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + SendSendMessageParams.Message.Metadata.Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + SendSendMessageParams.Message.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + SendSendMessageParams.Message.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + SendSendMessageParams.Message.Routing.builder() + .addChannel("email") + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .build() + ) + .timeout( + SendSendMessageParams.Message.Timeout.builder() + .channel( + SendSendMessageParams.Message.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION + ) + .escalation(0L) + .message(0L) + .provider( + SendSendMessageParams.Message.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + SendSendMessageParams.Message.To.UnionMember0.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.message()) + .isEqualTo( + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) + .brandId("brand_id") + .channels( + SendSendMessageParams.Message.Channels.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "brand_id" to "brand_id", + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "providers" to listOf("string"), + "routing_method" to "all", + "timeouts" to mapOf("channel" to 0, "provider" to 0), + ) + ), + ) + .build() + ) + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + SendSendMessageParams.Message.Data.builder() + .putAdditionalProperty("name", JsonValue.from("bar")) + .build() + ) + .delay( + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() + ) + .expiry( + SendSendMessageParams.Message.Expiry.builder() + .expiresIn("string") + .expiresAt("expires_at") + .build() + ) + .metadata( + SendSendMessageParams.Message.Metadata.builder() + .event("event") + .addTag("string") + .traceId("trace_id") + .utm( + SendSendMessageParams.Message.Metadata.Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + ) + .build() + ) + .preferences( + SendSendMessageParams.Message.Preferences.builder() + .subscriptionTopicId("subscription_topic_id") + .build() + ) + .providers( + SendSendMessageParams.Message.Providers.builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "if" to "if", + "metadata" to + mapOf( + "utm" to + mapOf( + "campaign" to "campaign", + "content" to "content", + "medium" to "medium", + "source" to "source", + "term" to "term", + ) + ), + "override" to mapOf("foo" to "bar"), + "timeouts" to 0, + ) + ), + ) + .build() + ) + .routing( + SendSendMessageParams.Message.Routing.builder() + .addChannel("email") + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .build() + ) + .timeout( + SendSendMessageParams.Message.Timeout.builder() + .channel( + SendSendMessageParams.Message.Timeout.Channel.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .criteria(SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) + .escalation(0L) + .message(0L) + .provider( + SendSendMessageParams.Message.Timeout.Provider.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .build() + ) + .to( + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) + .data( + SendSendMessageParams.Message.To.UnionMember0.Data.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0.Preferences.builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .categories( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf("channel" to "direct_message") + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() + ) + .templateId("templateId") + .build() + ) + .tenantId("tenant_id") + .userId("user_id") + .build() + ) + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SendSendMessageParams.builder() + .message( + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) + .build() + ) + .build() + + val body = params._body() + + assertThat(body.message()) + .isEqualTo( + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) + .build() + ) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt new file mode 100644 index 00000000..61cd26f9 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SendSendMessageResponseTest { + + @Test + fun create() { + val sendSendMessageResponse = + SendSendMessageResponse.builder() + .requestId("1-65f240a0-47a6a120c8374de9bcf9f22c") + .build() + + assertThat(sendSendMessageResponse.requestId()) + .isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sendSendMessageResponse = + SendSendMessageResponse.builder() + .requestId("1-65f240a0-47a6a120c8374de9bcf9f22c") + .build() + + val roundtrippedSendSendMessageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sendSendMessageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSendSendMessageResponse).isEqualTo(sendSendMessageResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt deleted file mode 100644 index 557ada7d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SlackBasePropertiesTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SlackBasePropertiesTest { - - @Test - fun create() { - val slackBaseProperties = SlackBaseProperties.builder().accessToken("access_token").build() - - assertThat(slackBaseProperties.accessToken()).isEqualTo("access_token") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val slackBaseProperties = SlackBaseProperties.builder().accessToken("access_token").build() - - val roundtrippedSlackBaseProperties = - jsonMapper.readValue( - jsonMapper.writeValueAsString(slackBaseProperties), - jacksonTypeRef(), - ) - - assertThat(roundtrippedSlackBaseProperties).isEqualTo(slackBaseProperties) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt deleted file mode 100644 index 889e13b8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UtmTest { - - @Test - fun create() { - val utm = - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - - assertThat(utm.campaign()).contains("campaign") - assertThat(utm.content()).contains("content") - assertThat(utm.medium()).contains("medium") - assertThat(utm.source()).contains("source") - assertThat(utm.term()).contains("term") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val utm = - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - - val roundtrippedUtm = - jsonMapper.readValue(jsonMapper.writeValueAsString(utm), jacksonTypeRef()) - - assertThat(roundtrippedUtm).isEqualTo(utm) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt deleted file mode 100644 index 4e7b4acb..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/DefaultPreferencesTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.jsonMapper -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class DefaultPreferencesTest { - - @Test - fun create() { - val defaultPreferences = - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - - assertThat(defaultPreferences.items().getOrNull()) - .containsExactly( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val defaultPreferences = - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - - val roundtrippedDefaultPreferences = - jsonMapper.readValue( - jsonMapper.writeValueAsString(defaultPreferences), - jacksonTypeRef(), - ) - - assertThat(roundtrippedDefaultPreferences).isEqualTo(defaultPreferences) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt deleted file mode 100644 index 73af19c6..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantDeleteParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantDeleteParamsTest { - - @Test - fun create() { - TenantDeleteParams.builder().tenantId("tenant_id").build() - } - - @Test - fun pathParams() { - val params = TenantDeleteParams.builder().tenantId("tenant_id").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt deleted file mode 100644 index 4ccb72f5..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListParamsTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantListParamsTest { - - @Test - fun create() { - TenantListParams.builder() - .cursor("cursor") - .limit(0L) - .parentTenantId("parent_tenant_id") - .build() - } - - @Test - fun queryParams() { - val params = - TenantListParams.builder() - .cursor("cursor") - .limit(0L) - .parentTenantId("parent_tenant_id") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("cursor", "cursor") - .put("limit", "0") - .put("parent_tenant_id", "parent_tenant_id") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = TenantListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt deleted file mode 100644 index 2cdaf64f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListResponseTest.kt +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantListResponseTest { - - @Test - fun create() { - val tenantListResponse = - TenantListResponse.builder() - .hasMore(true) - .addItem( - Tenant.builder() - .id("id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - Tenant.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - Tenant.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - .type(TenantListResponse.Type.LIST) - .url("url") - .cursor("cursor") - .nextUrl("next_url") - .build() - - assertThat(tenantListResponse.hasMore()).isEqualTo(true) - assertThat(tenantListResponse.items()) - .containsExactly( - Tenant.builder() - .id("id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - Tenant.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - Tenant.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - assertThat(tenantListResponse.type()).isEqualTo(TenantListResponse.Type.LIST) - assertThat(tenantListResponse.url()).isEqualTo("url") - assertThat(tenantListResponse.cursor()).contains("cursor") - assertThat(tenantListResponse.nextUrl()).contains("next_url") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tenantListResponse = - TenantListResponse.builder() - .hasMore(true) - .addItem( - Tenant.builder() - .id("id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - Tenant.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - Tenant.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - .type(TenantListResponse.Type.LIST) - .url("url") - .cursor("cursor") - .nextUrl("next_url") - .build() - - val roundtrippedTenantListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tenantListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTenantListResponse).isEqualTo(tenantListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt deleted file mode 100644 index 633d142b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersParamsTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantListUsersParamsTest { - - @Test - fun create() { - TenantListUsersParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() - } - - @Test - fun pathParams() { - val params = TenantListUsersParams.builder().tenantId("tenant_id").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - TenantListUsersParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "0").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = TenantListUsersParams.builder().tenantId("tenant_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt deleted file mode 100644 index d6445bd4..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantListUsersResponseTest.kt +++ /dev/null @@ -1,90 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.users.tenants.TenantAssociation -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantListUsersResponseTest { - - @Test - fun create() { - val tenantListUsersResponse = - TenantListUsersResponse.builder() - .hasMore(true) - .type(TenantListUsersResponse.Type.LIST) - .url("url") - .cursor("cursor") - .addItem( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .nextUrl("next_url") - .build() - - assertThat(tenantListUsersResponse.hasMore()).isEqualTo(true) - assertThat(tenantListUsersResponse.type()).isEqualTo(TenantListUsersResponse.Type.LIST) - assertThat(tenantListUsersResponse.url()).isEqualTo("url") - assertThat(tenantListUsersResponse.cursor()).contains("cursor") - assertThat(tenantListUsersResponse.items().getOrNull()) - .containsExactly( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - assertThat(tenantListUsersResponse.nextUrl()).contains("next_url") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tenantListUsersResponse = - TenantListUsersResponse.builder() - .hasMore(true) - .type(TenantListUsersResponse.Type.LIST) - .url("url") - .cursor("cursor") - .addItem( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .nextUrl("next_url") - .build() - - val roundtrippedTenantListUsersResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tenantListUsersResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTenantListUsersResponse).isEqualTo(tenantListUsersResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt deleted file mode 100644 index 81b74128..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantRetrieveParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantRetrieveParamsTest { - - @Test - fun create() { - TenantRetrieveParams.builder().tenantId("tenant_id").build() - } - - @Test - fun pathParams() { - val params = TenantRetrieveParams.builder().tenantId("tenant_id").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt deleted file mode 100644 index b4e30b15..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantTest.kt +++ /dev/null @@ -1,116 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantTest { - - @Test - fun create() { - val tenant = - Tenant.builder() - .id("id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - Tenant.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - Tenant.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - assertThat(tenant.id()).isEqualTo("id") - assertThat(tenant.name()).isEqualTo("name") - assertThat(tenant.brandId()).contains("brand_id") - assertThat(tenant.defaultPreferences()) - .contains( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - assertThat(tenant.parentTenantId()).contains("parent_tenant_id") - assertThat(tenant.properties()) - .contains( - Tenant.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(tenant.userProfile()) - .contains( - Tenant.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tenant = - Tenant.builder() - .id("id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - Tenant.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - Tenant.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val roundtrippedTenant = - jsonMapper.readValue(jsonMapper.writeValueAsString(tenant), jacksonTypeRef()) - - assertThat(roundtrippedTenant).isEqualTo(tenant) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt deleted file mode 100644 index f56d4f3c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/TenantUpdateParamsTest.kt +++ /dev/null @@ -1,126 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantUpdateParamsTest { - - @Test - fun create() { - TenantUpdateParams.builder() - .tenantId("tenant_id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - TenantUpdateParams.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - TenantUpdateParams.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = TenantUpdateParams.builder().tenantId("tenant_id").name("name").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - TenantUpdateParams.builder() - .tenantId("tenant_id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - TenantUpdateParams.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - TenantUpdateParams.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - assertThat(body.brandId()).contains("brand_id") - assertThat(body.defaultPreferences()) - .contains( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - assertThat(body.parentTenantId()).contains("parent_tenant_id") - assertThat(body.properties()) - .contains( - TenantUpdateParams.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(body.userProfile()) - .contains( - TenantUpdateParams.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = TenantUpdateParams.builder().tenantId("tenant_id").name("name").build() - - val body = params._body() - - assertThat(body.name()).isEqualTo("name") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt deleted file mode 100644 index b24fe6a7..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemDeleteParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ItemDeleteParamsTest { - - @Test - fun create() { - ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() - } - - @Test - fun pathParams() { - val params = ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - assertThat(params._pathParam(1)).isEqualTo("topic_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt deleted file mode 100644 index 7e048ddd..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/ItemUpdateParamsTest.kt +++ /dev/null @@ -1,91 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ItemUpdateParamsTest { - - @Test - fun create() { - ItemUpdateParams.builder() - .tenantId("tenant_id") - .topicId("topic_id") - .subscriptionTopicNew( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .hasCustomRouting(true) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - ItemUpdateParams.builder() - .tenantId("tenant_id") - .topicId("topic_id") - .subscriptionTopicNew( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - assertThat(params._pathParam(1)).isEqualTo("topic_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - ItemUpdateParams.builder() - .tenantId("tenant_id") - .topicId("topic_id") - .subscriptionTopicNew( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .hasCustomRouting(true) - .build() - ) - .build() - - val body = params._body() - - assertThat(body) - .isEqualTo( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .hasCustomRouting(true) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - ItemUpdateParams.builder() - .tenantId("tenant_id") - .topicId("topic_id") - .subscriptionTopicNew( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .build() - ) - .build() - - val body = params._body() - - assertThat(body) - .isEqualTo( - SubscriptionTopicNew.builder().status(SubscriptionTopicNew.Status.OPTED_IN).build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt deleted file mode 100644 index bc9799a9..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/defaultpreferences/items/SubscriptionTopicNewTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.defaultpreferences.items - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SubscriptionTopicNewTest { - - @Test - fun create() { - val subscriptionTopicNew = - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - - assertThat(subscriptionTopicNew.status()).isEqualTo(SubscriptionTopicNew.Status.OPTED_OUT) - assertThat(subscriptionTopicNew.customRouting().getOrNull()) - .containsExactly(ChannelClassification.DIRECT_MESSAGE) - assertThat(subscriptionTopicNew.hasCustomRouting()).contains(true) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val subscriptionTopicNew = - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - - val roundtrippedSubscriptionTopicNew = - jsonMapper.readValue( - jsonMapper.writeValueAsString(subscriptionTopicNew), - jacksonTypeRef(), - ) - - assertThat(roundtrippedSubscriptionTopicNew).isEqualTo(subscriptionTopicNew) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt deleted file mode 100644 index dda241ef..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/BaseTemplateTenantAssociationTest.kt +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BaseTemplateTenantAssociationTest { - - @Test - fun create() { - val baseTemplateTenantAssociation = - BaseTemplateTenantAssociation.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .build() - - assertThat(baseTemplateTenantAssociation.id()).isEqualTo("id") - assertThat(baseTemplateTenantAssociation.createdAt()).isEqualTo("created_at") - assertThat(baseTemplateTenantAssociation.publishedAt()).isEqualTo("published_at") - assertThat(baseTemplateTenantAssociation.updatedAt()).isEqualTo("updated_at") - assertThat(baseTemplateTenantAssociation.version()).isEqualTo("version") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val baseTemplateTenantAssociation = - BaseTemplateTenantAssociation.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .build() - - val roundtrippedBaseTemplateTenantAssociation = - jsonMapper.readValue( - jsonMapper.writeValueAsString(baseTemplateTenantAssociation), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBaseTemplateTenantAssociation) - .isEqualTo(baseTemplateTenantAssociation) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt deleted file mode 100644 index 40d76a91..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalChannelNodeTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalChannelNodeTest { - - @Test - fun create() { - val elementalChannelNode = - ElementalChannelNode.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .build() - - assertThat(elementalChannelNode.channel()).isEqualTo("channel") - assertThat(elementalChannelNode.channels().getOrNull()).containsExactly("string") - assertThat(elementalChannelNode.elements().getOrNull()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalChannelNode.if_()).contains("if") - assertThat(elementalChannelNode.loop()).contains("loop") - assertThat(elementalChannelNode.raw()) - .contains( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(elementalChannelNode.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalChannelNode = - ElementalChannelNode.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .build() - - val roundtrippedElementalChannelNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalChannelNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalChannelNode).isEqualTo(elementalChannelNode) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt deleted file mode 100644 index 1a816605..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalContentTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalContentTest { - - @Test - fun create() { - val elementalContent = - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - - assertThat(elementalContent.elements()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalContent.version()).isEqualTo("version") - assertThat(elementalContent._brand()).isEqualTo(JsonValue.from(mapOf())) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalContent = - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() - - val roundtrippedElementalContent = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalContent), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalContent).isEqualTo(elementalContent) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt deleted file mode 100644 index 57ed362b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalGroupNodeTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class ElementalGroupNodeTest { - - @Test - fun create() { - val elementalGroupNode = - ElementalGroupNode.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .build() - - assertThat(elementalGroupNode.elements()) - .containsExactly( - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - ) - assertThat(elementalGroupNode.channels().getOrNull()).containsExactly("string") - assertThat(elementalGroupNode.if_()).contains("if") - assertThat(elementalGroupNode.loop()).contains("loop") - assertThat(elementalGroupNode.ref()).contains("ref") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val elementalGroupNode = - ElementalGroupNode.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .build() - - val roundtrippedElementalGroupNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalGroupNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalGroupNode).isEqualTo(elementalGroupNode) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt deleted file mode 100644 index a6fe92cb..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/ElementalNodeTest.kt +++ /dev/null @@ -1,450 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.courier.api.errors.CourierInvalidDataException -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource - -internal class ElementalNodeTest { - - @Test - fun ofUnionMember0() { - val unionMember0 = - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - - val elementalNode = ElementalNode.ofUnionMember0(unionMember0) - - assertThat(elementalNode.unionMember0()).contains(unionMember0) - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember0Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember0( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember1() { - val unionMember1 = - ElementalNode.UnionMember1.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember1.Type.META) - .build() - - val elementalNode = ElementalNode.ofUnionMember1(unionMember1) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).contains(unionMember1) - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember1Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember1( - ElementalNode.UnionMember1.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember1.Type.META) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember2() { - val unionMember2 = - ElementalNode.UnionMember2.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .type(ElementalNode.UnionMember2.Type.CHANNEL) - .build() - - val elementalNode = ElementalNode.ofUnionMember2(unionMember2) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).contains(unionMember2) - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember2Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember2( - ElementalNode.UnionMember2.builder() - .channel("channel") - .addChannel("string") - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .if_("if") - .loop("loop") - .raw( - ElementalChannelNode.Raw.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .ref("ref") - .type(ElementalNode.UnionMember2.Type.CHANNEL) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember3() { - val unionMember3 = - ElementalNode.UnionMember3.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember3.Type.IMAGE) - .build() - - val elementalNode = ElementalNode.ofUnionMember3(unionMember3) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).contains(unionMember3) - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember3Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember3( - ElementalNode.UnionMember3.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember3.Type.IMAGE) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember4() { - val unionMember4 = - ElementalNode.UnionMember4.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember4.Type.ACTION) - .build() - - val elementalNode = ElementalNode.ofUnionMember4(unionMember4) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).contains(unionMember4) - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember4Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember4( - ElementalNode.UnionMember4.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember4.Type.ACTION) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember5() { - val unionMember5 = - ElementalNode.UnionMember5.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember5.Type.DIVIDER) - .build() - - val elementalNode = ElementalNode.ofUnionMember5(unionMember5) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).contains(unionMember5) - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember5Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember5( - ElementalNode.UnionMember5.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember5.Type.DIVIDER) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember6() { - val unionMember6 = - ElementalNode.UnionMember6.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember6.Type.GROUP) - .build() - - val elementalNode = ElementalNode.ofUnionMember6(unionMember6) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).contains(unionMember6) - assertThat(elementalNode.unionMember7()).isEmpty - } - - @Test - fun ofUnionMember6Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember6( - ElementalNode.UnionMember6.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember6.Type.GROUP) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - @Test - fun ofUnionMember7() { - val unionMember7 = - ElementalNode.UnionMember7.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember7.Type.QUOTE) - .build() - - val elementalNode = ElementalNode.ofUnionMember7(unionMember7) - - assertThat(elementalNode.unionMember0()).isEmpty - assertThat(elementalNode.unionMember1()).isEmpty - assertThat(elementalNode.unionMember2()).isEmpty - assertThat(elementalNode.unionMember3()).isEmpty - assertThat(elementalNode.unionMember4()).isEmpty - assertThat(elementalNode.unionMember5()).isEmpty - assertThat(elementalNode.unionMember6()).isEmpty - assertThat(elementalNode.unionMember7()).contains(unionMember7) - } - - @Test - fun ofUnionMember7Roundtrip() { - val jsonMapper = jsonMapper() - val elementalNode = - ElementalNode.ofUnionMember7( - ElementalNode.UnionMember7.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember7.Type.QUOTE) - .build() - ) - - val roundtrippedElementalNode = - jsonMapper.readValue( - jsonMapper.writeValueAsString(elementalNode), - jacksonTypeRef(), - ) - - assertThat(roundtrippedElementalNode).isEqualTo(elementalNode) - } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val elementalNode = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { elementalNode.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt deleted file mode 100644 index fa16fc52..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListParamsTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TemplateListParamsTest { - - @Test - fun create() { - TemplateListParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() - } - - @Test - fun pathParams() { - val params = TemplateListParams.builder().tenantId("tenant_id").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - TemplateListParams.builder().tenantId("tenant_id").cursor("cursor").limit(0L).build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "0").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = TemplateListParams.builder().tenantId("tenant_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt deleted file mode 100644 index 427e61d3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateListResponseTest.kt +++ /dev/null @@ -1,110 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import com.courier.api.core.jsonMapper -import com.courier.api.models.notifications.MessageRouting -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TemplateListResponseTest { - - @Test - fun create() { - val templateListResponse = - TemplateListResponse.builder() - .hasMore(true) - .type(TemplateListResponse.Type.LIST) - .url("url") - .cursor("cursor") - .addItem( - TemplateListResponse.Item.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .data( - TemplateListResponse.Item.Data.builder() - .routing( - MessageRouting.builder() - .addChannel("string") - .method(MessageRouting.Method.ALL) - .build() - ) - .build() - ) - .build() - ) - .nextUrl("next_url") - .build() - - assertThat(templateListResponse.hasMore()).isEqualTo(true) - assertThat(templateListResponse.type()).isEqualTo(TemplateListResponse.Type.LIST) - assertThat(templateListResponse.url()).isEqualTo("url") - assertThat(templateListResponse.cursor()).contains("cursor") - assertThat(templateListResponse.items().getOrNull()) - .containsExactly( - TemplateListResponse.Item.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .data( - TemplateListResponse.Item.Data.builder() - .routing( - MessageRouting.builder() - .addChannel("string") - .method(MessageRouting.Method.ALL) - .build() - ) - .build() - ) - .build() - ) - assertThat(templateListResponse.nextUrl()).contains("next_url") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val templateListResponse = - TemplateListResponse.builder() - .hasMore(true) - .type(TemplateListResponse.Type.LIST) - .url("url") - .cursor("cursor") - .addItem( - TemplateListResponse.Item.builder() - .id("id") - .createdAt("created_at") - .publishedAt("published_at") - .updatedAt("updated_at") - .version("version") - .data( - TemplateListResponse.Item.Data.builder() - .routing( - MessageRouting.builder() - .addChannel("string") - .method(MessageRouting.Method.ALL) - .build() - ) - .build() - ) - .build() - ) - .nextUrl("next_url") - .build() - - val roundtrippedTemplateListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(templateListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTemplateListResponse).isEqualTo(templateListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt deleted file mode 100644 index 527cfe5b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/tenants/templates/TemplateRetrieveParamsTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.tenants.templates - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TemplateRetrieveParamsTest { - - @Test - fun create() { - TemplateRetrieveParams.builder().tenantId("tenant_id").templateId("template_id").build() - } - - @Test - fun pathParams() { - val params = - TemplateRetrieveParams.builder().tenantId("tenant_id").templateId("template_id").build() - - assertThat(params._pathParam(0)).isEqualTo("tenant_id") - assertThat(params._pathParam(1)).isEqualTo("template_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt deleted file mode 100644 index 51f2c042..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationRetrieveParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.translations - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TranslationRetrieveParamsTest { - - @Test - fun create() { - TranslationRetrieveParams.builder().domain("domain").locale("locale").build() - } - - @Test - fun pathParams() { - val params = TranslationRetrieveParams.builder().domain("domain").locale("locale").build() - - assertThat(params._pathParam(0)).isEqualTo("domain") - assertThat(params._pathParam(1)).isEqualTo("locale") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt deleted file mode 100644 index 8c1a69a5..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/translations/TranslationUpdateParamsTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.translations - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TranslationUpdateParamsTest { - - @Test - fun create() { - TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() - } - - @Test - fun pathParams() { - val params = - TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() - - assertThat(params._pathParam(0)).isEqualTo("domain") - assertThat(params._pathParam(1)).isEqualTo("locale") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() - - val body = params._body() - - assertThat(body).isEqualTo("body") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt deleted file mode 100644 index a647f715..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveParamsTest.kt +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PreferenceRetrieveParamsTest { - - @Test - fun create() { - PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() - } - - @Test - fun pathParams() { - val params = PreferenceRetrieveParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("tenant_id", "tenant_id").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = PreferenceRetrieveParams.builder().userId("user_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt deleted file mode 100644 index b0ccb74f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveResponseTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.jsonMapper -import com.courier.api.models.audiences.Paging -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PreferenceRetrieveResponseTest { - - @Test - fun create() { - val preferenceRetrieveResponse = - PreferenceRetrieveResponse.builder() - .addItem( - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - assertThat(preferenceRetrieveResponse.items()) - .containsExactly( - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - ) - assertThat(preferenceRetrieveResponse.paging()) - .isEqualTo(Paging.builder().more(true).cursor("cursor").build()) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val preferenceRetrieveResponse = - PreferenceRetrieveResponse.builder() - .addItem( - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - ) - .paging(Paging.builder().more(true).cursor("cursor").build()) - .build() - - val roundtrippedPreferenceRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(preferenceRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPreferenceRetrieveResponse).isEqualTo(preferenceRetrieveResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt deleted file mode 100644 index 3b991def..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicParamsTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PreferenceRetrieveTopicParamsTest { - - @Test - fun create() { - PreferenceRetrieveTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .build() - } - - @Test - fun pathParams() { - val params = - PreferenceRetrieveTopicParams.builder().userId("user_id").topicId("topic_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("topic_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - PreferenceRetrieveTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("tenant_id", "tenant_id").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = - PreferenceRetrieveTopicParams.builder().userId("user_id").topicId("topic_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt deleted file mode 100644 index 436043f4..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceRetrieveTopicResponseTest.kt +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.jsonMapper -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PreferenceRetrieveTopicResponseTest { - - @Test - fun create() { - val preferenceRetrieveTopicResponse = - PreferenceRetrieveTopicResponse.builder() - .topic( - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - ) - .build() - - assertThat(preferenceRetrieveTopicResponse.topic()) - .isEqualTo( - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val preferenceRetrieveTopicResponse = - PreferenceRetrieveTopicResponse.builder() - .topic( - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - ) - .build() - - val roundtrippedPreferenceRetrieveTopicResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(preferenceRetrieveTopicResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPreferenceRetrieveTopicResponse) - .isEqualTo(preferenceRetrieveTopicResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt deleted file mode 100644 index a7152c75..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicParamsTest.kt +++ /dev/null @@ -1,141 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.http.QueryParams -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PreferenceUpdateOrCreateTopicParamsTest { - - @Test - fun create() { - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .addCustomRouting(ChannelClassification.EMAIL) - .hasCustomRouting(true) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("topic_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .addCustomRouting(ChannelClassification.EMAIL) - .hasCustomRouting(true) - .build() - ) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("tenant_id", "tenant_id").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .build() - ) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } - - @Test - fun body() { - val params = - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .addCustomRouting(ChannelClassification.EMAIL) - .hasCustomRouting(true) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.topic()) - .isEqualTo( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .addCustomRouting(ChannelClassification.EMAIL) - .hasCustomRouting(true) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.topic()) - .isEqualTo( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt deleted file mode 100644 index 179b2d82..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/PreferenceUpdateOrCreateTopicResponseTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PreferenceUpdateOrCreateTopicResponseTest { - - @Test - fun create() { - val preferenceUpdateOrCreateTopicResponse = - PreferenceUpdateOrCreateTopicResponse.builder().message("success").build() - - assertThat(preferenceUpdateOrCreateTopicResponse.message()).isEqualTo("success") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val preferenceUpdateOrCreateTopicResponse = - PreferenceUpdateOrCreateTopicResponse.builder().message("success").build() - - val roundtrippedPreferenceUpdateOrCreateTopicResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(preferenceUpdateOrCreateTopicResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPreferenceUpdateOrCreateTopicResponse) - .isEqualTo(preferenceUpdateOrCreateTopicResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt deleted file mode 100644 index af9338f2..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/preferences/TopicPreferenceTest.kt +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.preferences - -import com.courier.api.core.jsonMapper -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TopicPreferenceTest { - - @Test - fun create() { - val topicPreference = - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - - assertThat(topicPreference.defaultStatus()).isEqualTo(PreferenceStatus.OPTED_IN) - assertThat(topicPreference.status()).isEqualTo(PreferenceStatus.OPTED_IN) - assertThat(topicPreference.topicId()).isEqualTo("topic_id") - assertThat(topicPreference.topicName()).isEqualTo("topic_name") - assertThat(topicPreference.customRouting().getOrNull()) - .containsExactly(ChannelClassification.DIRECT_MESSAGE) - assertThat(topicPreference.hasCustomRouting()).contains(true) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val topicPreference = - TopicPreference.builder() - .defaultStatus(PreferenceStatus.OPTED_IN) - .status(PreferenceStatus.OPTED_IN) - .topicId("topic_id") - .topicName("topic_name") - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .build() - - val roundtrippedTopicPreference = - jsonMapper.readValue( - jsonMapper.writeValueAsString(topicPreference), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTopicPreference).isEqualTo(topicPreference) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt deleted file mode 100644 index 9f403606..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddMultipleParamsTest.kt +++ /dev/null @@ -1,92 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantAddMultipleParamsTest { - - @Test - fun create() { - TenantAddMultipleParams.builder() - .userId("user_id") - .addTenant( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - TenantAddMultipleParams.builder() - .userId("user_id") - .addTenant(TenantAssociation.builder().tenantId("tenant_id").build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun body() { - val params = - TenantAddMultipleParams.builder() - .userId("user_id") - .addTenant( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .build() - - val body = params._body() - - assertThat(body.tenants()) - .containsExactly( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - TenantAddMultipleParams.builder() - .userId("user_id") - .addTenant(TenantAssociation.builder().tenantId("tenant_id").build()) - .build() - - val body = params._body() - - assertThat(body.tenants()) - .containsExactly(TenantAssociation.builder().tenantId("tenant_id").build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt deleted file mode 100644 index 9352423e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAddSingleParamsTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantAddSingleParamsTest { - - @Test - fun create() { - TenantAddSingleParams.builder() - .userId("user_id") - .tenantId("tenant_id") - .profile( - TenantAddSingleParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = TenantAddSingleParams.builder().userId("user_id").tenantId("tenant_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - TenantAddSingleParams.builder() - .userId("user_id") - .tenantId("tenant_id") - .profile( - TenantAddSingleParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - - val body = params._body() - - assertThat(body.profile()) - .contains( - TenantAddSingleParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = TenantAddSingleParams.builder().userId("user_id").tenantId("tenant_id").build() - - val body = params._body() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt deleted file mode 100644 index 57ac45b2..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantAssociationTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantAssociationTest { - - @Test - fun create() { - val tenantAssociation = - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - - assertThat(tenantAssociation.tenantId()).isEqualTo("tenant_id") - assertThat(tenantAssociation.profile()) - .contains( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - assertThat(tenantAssociation.type()).contains(TenantAssociation.Type.USER) - assertThat(tenantAssociation.userId()).contains("user_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tenantAssociation = - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - - val roundtrippedTenantAssociation = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tenantAssociation), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTenantAssociation).isEqualTo(tenantAssociation) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt deleted file mode 100644 index 1a86f423..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListParamsTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantListParamsTest { - - @Test - fun create() { - TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() - } - - @Test - fun pathParams() { - val params = TenantListParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("cursor", "cursor").put("limit", "0").build()) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = TenantListParams.builder().userId("user_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt deleted file mode 100644 index 695e75ed..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantListResponseTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantListResponseTest { - - @Test - fun create() { - val tenantListResponse = - TenantListResponse.builder() - .hasMore(true) - .type(TenantListResponse.Type.LIST) - .url("url") - .cursor("cursor") - .addItem( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .nextUrl("next_url") - .build() - - assertThat(tenantListResponse.hasMore()).isEqualTo(true) - assertThat(tenantListResponse.type()).isEqualTo(TenantListResponse.Type.LIST) - assertThat(tenantListResponse.url()).isEqualTo("url") - assertThat(tenantListResponse.cursor()).contains("cursor") - assertThat(tenantListResponse.items().getOrNull()) - .containsExactly( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - assertThat(tenantListResponse.nextUrl()).contains("next_url") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tenantListResponse = - TenantListResponse.builder() - .hasMore(true) - .type(TenantListResponse.Type.LIST) - .url("url") - .cursor("cursor") - .addItem( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .nextUrl("next_url") - .build() - - val roundtrippedTenantListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tenantListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTenantListResponse).isEqualTo(tenantListResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt deleted file mode 100644 index 5affcc16..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveAllParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantRemoveAllParamsTest { - - @Test - fun create() { - TenantRemoveAllParams.builder().userId("user_id").build() - } - - @Test - fun pathParams() { - val params = TenantRemoveAllParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt deleted file mode 100644 index fb0f705e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tenants/TenantRemoveSingleParamsTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tenants - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TenantRemoveSingleParamsTest { - - @Test - fun create() { - TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() - } - - @Test - fun pathParams() { - val params = - TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("tenant_id") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt deleted file mode 100644 index 67cdc296..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddMultipleParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenAddMultipleParamsTest { - - @Test - fun create() { - TokenAddMultipleParams.builder().userId("user_id").build() - } - - @Test - fun pathParams() { - val params = TokenAddMultipleParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt deleted file mode 100644 index f469be79..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenAddSingleParamsTest.kt +++ /dev/null @@ -1,143 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.JsonValue -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenAddSingleParamsTest { - - @Test - fun create() { - TokenAddSingleParams.builder() - .userId("user_id") - .pathToken("token") - .userToken( - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - TokenAddSingleParams.builder() - .userId("user_id") - .pathToken("token") - .userToken( - UserToken.builder().providerKey(UserToken.ProviderKey.FIREBASE_FCM).build() - ) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("token") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - TokenAddSingleParams.builder() - .userId("user_id") - .pathToken("token") - .userToken( - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - ) - .build() - - val body = params._body() - - assertThat(body) - .isEqualTo( - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - TokenAddSingleParams.builder() - .userId("user_id") - .pathToken("token") - .userToken( - UserToken.builder().providerKey(UserToken.ProviderKey.FIREBASE_FCM).build() - ) - .build() - - val body = params._body() - - assertThat(body) - .isEqualTo(UserToken.builder().providerKey(UserToken.ProviderKey.FIREBASE_FCM).build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt deleted file mode 100644 index 83ea313e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenDeleteParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenDeleteParamsTest { - - @Test - fun create() { - TokenDeleteParams.builder().userId("user_id").token("token").build() - } - - @Test - fun pathParams() { - val params = TokenDeleteParams.builder().userId("user_id").token("token").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("token") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt deleted file mode 100644 index 6bd6f11f..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenListParamsTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenListParamsTest { - - @Test - fun create() { - TokenListParams.builder().userId("user_id").build() - } - - @Test - fun pathParams() { - val params = TokenListParams.builder().userId("user_id").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt deleted file mode 100644 index ff21e7c3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveParamsTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenRetrieveParamsTest { - - @Test - fun create() { - TokenRetrieveParams.builder().userId("user_id").token("token").build() - } - - @Test - fun pathParams() { - val params = TokenRetrieveParams.builder().userId("user_id").token("token").build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("token") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt deleted file mode 100644 index 0f275e09..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenRetrieveResponseTest.kt +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenRetrieveResponseTest { - - @Test - fun create() { - val tokenRetrieveResponse = - TokenRetrieveResponse.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .status(TokenRetrieveResponse.Status.ACTIVE) - .statusReason("status_reason") - .build() - - assertThat(tokenRetrieveResponse.providerKey()) - .isEqualTo(UserToken.ProviderKey.FIREBASE_FCM) - assertThat(tokenRetrieveResponse.token()).contains("token") - assertThat(tokenRetrieveResponse.device()) - .contains( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - assertThat(tokenRetrieveResponse.expiryDate()) - .contains(UserToken.ExpiryDate.ofString("string")) - assertThat(tokenRetrieveResponse._properties()) - .isEqualTo(JsonValue.from(mapOf())) - assertThat(tokenRetrieveResponse.tracking()) - .contains( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - assertThat(tokenRetrieveResponse.status()).contains(TokenRetrieveResponse.Status.ACTIVE) - assertThat(tokenRetrieveResponse.statusReason()).contains("status_reason") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val tokenRetrieveResponse = - TokenRetrieveResponse.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .status(TokenRetrieveResponse.Status.ACTIVE) - .statusReason("status_reason") - .build() - - val roundtrippedTokenRetrieveResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(tokenRetrieveResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedTokenRetrieveResponse).isEqualTo(tokenRetrieveResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt deleted file mode 100644 index 53deb2f8..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/TokenUpdateParamsTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class TokenUpdateParamsTest { - - @Test - fun create() { - TokenUpdateParams.builder() - .userId("user_id") - .token("token") - .addPatch( - TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - } - - @Test - fun pathParams() { - val params = - TokenUpdateParams.builder() - .userId("user_id") - .token("token") - .addPatch(TokenUpdateParams.Patch.builder().op("op").path("path").build()) - .build() - - assertThat(params._pathParam(0)).isEqualTo("user_id") - assertThat(params._pathParam(1)).isEqualTo("token") - // out-of-bound path param - assertThat(params._pathParam(2)).isEqualTo("") - } - - @Test - fun body() { - val params = - TokenUpdateParams.builder() - .userId("user_id") - .token("token") - .addPatch( - TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - - val body = params._body() - - assertThat(body.patch()) - .containsExactly( - TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - TokenUpdateParams.builder() - .userId("user_id") - .token("token") - .addPatch(TokenUpdateParams.Patch.builder().op("op").path("path").build()) - .build() - - val body = params._body() - - assertThat(body.patch()) - .containsExactly(TokenUpdateParams.Patch.builder().op("op").path("path").build()) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt deleted file mode 100644 index 299f2391..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/users/tokens/UserTokenTest.kt +++ /dev/null @@ -1,104 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.users.tokens - -import com.courier.api.core.JsonValue -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UserTokenTest { - - @Test - fun create() { - val userToken = - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - - assertThat(userToken.providerKey()).isEqualTo(UserToken.ProviderKey.FIREBASE_FCM) - assertThat(userToken.token()).contains("token") - assertThat(userToken.device()) - .contains( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - assertThat(userToken.expiryDate()).contains(UserToken.ExpiryDate.ofString("string")) - assertThat(userToken._properties()).isEqualTo(JsonValue.from(mapOf())) - assertThat(userToken.tracking()) - .contains( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val userToken = - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - - val roundtrippedUserToken = - jsonMapper.readValue( - jsonMapper.writeValueAsString(userToken), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUserToken).isEqualTo(userToken) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index 74cb21e0..ea50fe34 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -16,13 +16,8 @@ import com.courier.api.errors.RateLimitException import com.courier.api.errors.UnauthorizedException import com.courier.api.errors.UnexpectedStatusCodeException import com.courier.api.errors.UnprocessableEntityException -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.BaseMessageSendTo -import com.courier.api.models.send.Content -import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm +import com.courier.api.models.send.SendSendMessageParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -65,7 +60,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage400() { + fun sendSendMessage400() { val sendService = client.send() stubFor( post(anyUrl()) @@ -76,13 +71,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -112,26 +113,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -142,12 +146,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -172,56 +176,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -236,7 +299,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage400WithRawResponse() { + fun sendSendMessage400WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -247,13 +310,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -283,26 +352,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -313,12 +385,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -343,56 +415,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -407,7 +538,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage401() { + fun sendSendMessage401() { val sendService = client.send() stubFor( post(anyUrl()) @@ -418,13 +549,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -454,26 +591,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -484,12 +624,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -514,56 +654,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -578,7 +777,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage401WithRawResponse() { + fun sendSendMessage401WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -589,13 +788,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -625,26 +830,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -655,12 +863,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -685,56 +893,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -749,7 +1016,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage403() { + fun sendSendMessage403() { val sendService = client.send() stubFor( post(anyUrl()) @@ -760,13 +1027,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -796,26 +1069,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -826,12 +1102,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -856,56 +1132,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -920,7 +1255,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage403WithRawResponse() { + fun sendSendMessage403WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -931,13 +1266,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -967,26 +1308,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -997,12 +1341,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1027,56 +1371,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -1091,7 +1494,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage404() { + fun sendSendMessage404() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1102,13 +1505,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1138,26 +1547,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1168,12 +1580,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1198,56 +1610,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -1262,7 +1733,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage404WithRawResponse() { + fun sendSendMessage404WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1273,13 +1744,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1309,26 +1786,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1339,12 +1819,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1369,56 +1849,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -1433,7 +1972,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage422() { + fun sendSendMessage422() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1444,13 +1983,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1480,26 +2025,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1510,12 +2058,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1540,56 +2088,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -1604,7 +2211,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage422WithRawResponse() { + fun sendSendMessage422WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1615,13 +2222,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1651,26 +2264,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1681,12 +2297,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1711,56 +2327,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -1775,7 +2450,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage429() { + fun sendSendMessage429() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1786,13 +2461,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1822,26 +2503,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1852,12 +2536,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1882,56 +2566,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -1946,7 +2689,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage429WithRawResponse() { + fun sendSendMessage429WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1957,13 +2700,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1993,26 +2742,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2023,12 +2775,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2053,56 +2805,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -2117,7 +2928,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage500() { + fun sendSendMessage500() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2128,13 +2939,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2164,26 +2981,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2194,12 +3014,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2224,56 +3044,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -2288,7 +3167,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage500WithRawResponse() { + fun sendSendMessage500WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -2299,13 +3178,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2335,26 +3220,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2365,12 +3253,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2395,56 +3283,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -2459,7 +3406,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage999() { + fun sendSendMessage999() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2470,13 +3417,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2506,26 +3459,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2536,12 +3492,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2566,56 +3522,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -2630,7 +3645,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessage999WithRawResponse() { + fun sendSendMessage999WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -2641,13 +3656,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2677,26 +3698,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2707,12 +3731,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2737,56 +3761,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() @@ -2801,7 +3884,7 @@ internal class ErrorHandlingTest { } @Test - fun sendMessageInvalidJsonBody() { + fun sendSendMessageInvalidJsonBody() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2810,13 +3893,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2846,26 +3935,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - BaseMessage.Delay.builder().duration(0L).until("until").build() + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2876,12 +3968,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2906,56 +3998,115 @@ internal class ErrorHandlingTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria + .NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context( + MessageContext.builder().tenantId("tenant_id").build() + ) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data + .builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter - .Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index ef3450ef..8a6dde81 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -5,13 +5,8 @@ package com.courier.api.services import com.courier.api.client.CourierClient import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.BaseMessageSendTo -import com.courier.api.models.send.Content -import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm +import com.courier.api.models.send.SendSendMessageParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -44,17 +39,23 @@ internal class ServiceParamsTest { @Disabled("Prism tests are disabled") @Test - fun message() { + fun sendMessage() { val sendService = client.send() stubFor(post(anyUrl()).willReturn(ok("{}"))) - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -83,24 +84,29 @@ internal class ServiceParamsTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .delay( + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() + ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -111,12 +117,12 @@ internal class ServiceParamsTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -141,54 +147,110 @@ internal class ServiceParamsTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter.Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path.ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt deleted file mode 100644 index ed40e354..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AudienceServiceAsyncTest.kt +++ /dev/null @@ -1,117 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.audiences.AudienceListMembersParams -import com.courier.api.models.audiences.AudienceListParams -import com.courier.api.models.audiences.AudienceUpdateParams -import com.courier.api.models.audiences.Filter -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class AudienceServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceServiceAsync = client.audiences() - - val audienceFuture = audienceServiceAsync.retrieve("audience_id") - - val audience = audienceFuture.get() - audience.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceServiceAsync = client.audiences() - - val audienceFuture = - audienceServiceAsync.update( - AudienceUpdateParams.builder() - .audienceId("audience_id") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .build() - ) - - val audience = audienceFuture.get() - audience.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceServiceAsync = client.audiences() - - val audiencesFuture = - audienceServiceAsync.list(AudienceListParams.builder().cursor("cursor").build()) - - val audiences = audiencesFuture.get() - audiences.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceServiceAsync = client.audiences() - - val future = audienceServiceAsync.delete("audience_id") - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun listMembers() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceServiceAsync = client.audiences() - - val responseFuture = - audienceServiceAsync.listMembers( - AudienceListMembersParams.builder() - .audienceId("audience_id") - .cursor("cursor") - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt deleted file mode 100644 index 0a290b6b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuditEventServiceAsyncTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.auditevents.AuditEventListParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class AuditEventServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val auditEventServiceAsync = client.auditEvents() - - val auditEventFuture = auditEventServiceAsync.retrieve("audit-event-id") - - val auditEvent = auditEventFuture.get() - auditEvent.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val auditEventServiceAsync = client.auditEvents() - - val auditEventsFuture = - auditEventServiceAsync.list(AuditEventListParams.builder().cursor("cursor").build()) - - val auditEvents = auditEventsFuture.get() - auditEvents.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt deleted file mode 100644 index 6bc5a348..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/AuthServiceAsyncTest.kt +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.auth.AuthIssueTokenParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class AuthServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun issueToken() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val authServiceAsync = client.auth() - - val responseFuture = - authServiceAsync.issueToken( - AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt deleted file mode 100644 index e5c3cfbb..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BrandServiceAsyncTest.kt +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.brands.BrandColors -import com.courier.api.models.brands.BrandCreateParams -import com.courier.api.models.brands.BrandListParams -import com.courier.api.models.brands.BrandSettings -import com.courier.api.models.brands.BrandSnippet -import com.courier.api.models.brands.BrandSnippets -import com.courier.api.models.brands.BrandUpdateParams -import com.courier.api.models.brands.Email -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class BrandServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun create() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandServiceAsync = client.brands() - - val brandFuture = - brandServiceAsync.create( - BrandCreateParams.builder() - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - - val brand = brandFuture.get() - brand.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandServiceAsync = client.brands() - - val brandFuture = brandServiceAsync.retrieve("brand_id") - - val brand = brandFuture.get() - brand.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandServiceAsync = client.brands() - - val brandFuture = - brandServiceAsync.update( - BrandUpdateParams.builder() - .brandId("brand_id") - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - - val brand = brandFuture.get() - brand.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandServiceAsync = client.brands() - - val brandsFuture = - brandServiceAsync.list(BrandListParams.builder().cursor("cursor").build()) - - val brands = brandsFuture.get() - brands.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandServiceAsync = client.brands() - - val future = brandServiceAsync.delete("brand_id") - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt deleted file mode 100644 index e976a17d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/BulkServiceAsyncTest.kt +++ /dev/null @@ -1,385 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.bulk.BulkAddUsersParams -import com.courier.api.models.bulk.BulkCreateJobParams -import com.courier.api.models.bulk.BulkListUsersParams -import com.courier.api.models.bulk.InboundBulkMessage -import com.courier.api.models.bulk.InboundBulkMessageUser -import com.courier.api.models.bulk.UserRecipient -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.Utm -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class BulkServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun addUsers() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkServiceAsync = client.bulk() - - val future = - bulkServiceAsync.addUsers( - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun createJob() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkServiceAsync = client.bulk() - - val responseFuture = - bulkServiceAsync.createJob( - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to - mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay( - BaseMessage.Delay.builder() - .duration(0L) - .until("until") - .build() - ) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun listUsers() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkServiceAsync = client.bulk() - - val responseFuture = - bulkServiceAsync.listUsers( - BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveJob() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkServiceAsync = client.bulk() - - val responseFuture = bulkServiceAsync.retrieveJob("job_id") - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun runJob() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkServiceAsync = client.bulk() - - val future = bulkServiceAsync.runJob("job_id") - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt deleted file mode 100644 index ce7e1ac1..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/InboundServiceAsyncTest.kt +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.inbound.InboundTrackEventParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class InboundServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun trackEvent() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val inboundServiceAsync = client.inbound() - - val responseFuture = - inboundServiceAsync.trackEvent( - InboundTrackEventParams.builder() - .event("New Order Placed") - .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") - .properties( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - .type(InboundTrackEventParams.Type.TRACK) - .userId("1234") - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt deleted file mode 100644 index 0db1025b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ListServiceAsyncTest.kt +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.ListListParams -import com.courier.api.models.lists.ListRestoreParams -import com.courier.api.models.lists.ListUpdateParams -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ListServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.lists() - - val listFuture = listServiceAsync.retrieve("list_id") - - val list = listFuture.get() - list.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.lists() - - val future = - listServiceAsync.update( - ListUpdateParams.builder() - .listId("list_id") - .name("name") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.lists() - - val listsFuture = - listServiceAsync.list( - ListListParams.builder().cursor("cursor").pattern("pattern").build() - ) - - val lists = listsFuture.get() - lists.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.lists() - - val future = listServiceAsync.delete("list_id") - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun restore() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.lists() - - val future = - listServiceAsync.restore( - ListRestoreParams.builder() - .listId("list_id") - .body(JsonValue.from(mapOf())) - .build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt deleted file mode 100644 index 3b81e849..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/MessageServiceAsyncTest.kt +++ /dev/null @@ -1,116 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.messages.MessageHistoryParams -import com.courier.api.models.messages.MessageListParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class MessageServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageServiceAsync = client.messages() - - val messageFuture = messageServiceAsync.retrieve("message_id") - - val message = messageFuture.get() - message.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageServiceAsync = client.messages() - - val messagesFuture = - messageServiceAsync.list( - MessageListParams.builder() - .archived(true) - .cursor("cursor") - .enqueuedAfter("enqueued_after") - .event("event") - .list("list") - .messageId("messageId") - .notification("notification") - .addProvider("string") - .recipient("recipient") - .addStatus("string") - .addTag("string") - .tags("tags") - .tenantId("tenant_id") - .traceId("traceId") - .build() - ) - - val messages = messagesFuture.get() - messages.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun cancel() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageServiceAsync = client.messages() - - val messageDetailsFuture = messageServiceAsync.cancel("message_id") - - val messageDetails = messageDetailsFuture.get() - messageDetails.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun content() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageServiceAsync = client.messages() - - val responseFuture = messageServiceAsync.content("message_id") - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun history() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageServiceAsync = client.messages() - - val responseFuture = - messageServiceAsync.history( - MessageHistoryParams.builder().messageId("message_id").type("type").build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt deleted file mode 100644 index e01bd772..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/NotificationServiceAsyncTest.kt +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.notifications.NotificationListParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class NotificationServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val notificationServiceAsync = client.notifications() - - val notificationsFuture = - notificationServiceAsync.list( - NotificationListParams.builder().cursor("cursor").notes(true).build() - ) - - val notifications = notificationsFuture.get() - notifications.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveContent() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val notificationServiceAsync = client.notifications() - - val notificationGetContentFuture = notificationServiceAsync.retrieveContent("id") - - val notificationGetContent = notificationGetContentFuture.get() - notificationGetContent.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt deleted file mode 100644 index 4a25544b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/ProfileServiceAsyncTest.kt +++ /dev/null @@ -1,127 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.profiles.ProfileCreateParams -import com.courier.api.models.profiles.ProfileReplaceParams -import com.courier.api.models.profiles.ProfileUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ProfileServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun create() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileServiceAsync = client.profiles() - - val profileFuture = - profileServiceAsync.create( - ProfileCreateParams.builder() - .userId("user_id") - .profile( - ProfileCreateParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - val profile = profileFuture.get() - profile.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileServiceAsync = client.profiles() - - val profileFuture = profileServiceAsync.retrieve("user_id") - - val profile = profileFuture.get() - profile.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileServiceAsync = client.profiles() - - val future = - profileServiceAsync.update( - ProfileUpdateParams.builder() - .userId("user_id") - .addPatch( - ProfileUpdateParams.Patch.builder() - .op("op") - .path("path") - .value("value") - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileServiceAsync = client.profiles() - - val future = profileServiceAsync.delete("user_id") - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun replace() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileServiceAsync = client.profiles() - - val responseFuture = - profileServiceAsync.replace( - ProfileReplaceParams.builder() - .userId("user_id") - .profile( - ProfileReplaceParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt deleted file mode 100644 index 98b519d3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/RequestServiceAsyncTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class RequestServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun archive() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val requestServiceAsync = client.requests() - - val future = requestServiceAsync.archive("request_id") - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 4a4c7bbb..53b4c1bd 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -5,13 +5,8 @@ package com.courier.api.services.async import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.BaseMessageSendTo -import com.courier.api.models.send.Content -import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm +import com.courier.api.models.send.SendSendMessageParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -21,7 +16,7 @@ internal class SendServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun message() { + fun sendMessage() { val client = CourierOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -30,13 +25,19 @@ internal class SendServiceAsyncTest { val sendServiceAsync = client.send() val responseFuture = - sendServiceAsync.message( - SendMessageParams.builder() + sendServiceAsync.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -65,24 +66,29 @@ internal class SendServiceAsyncTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .delay( + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() + ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -93,12 +99,12 @@ internal class SendServiceAsyncTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -123,55 +129,110 @@ internal class SendServiceAsyncTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter.Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt deleted file mode 100644 index 4bbb28f9..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/TenantServiceAsyncTest.kt +++ /dev/null @@ -1,143 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.tenants.DefaultPreferences -import com.courier.api.models.tenants.TenantListParams -import com.courier.api.models.tenants.TenantListUsersParams -import com.courier.api.models.tenants.TenantUpdateParams -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TenantServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.tenants() - - val tenantFuture = tenantServiceAsync.retrieve("tenant_id") - - val tenant = tenantFuture.get() - tenant.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.tenants() - - val tenantFuture = - tenantServiceAsync.update( - TenantUpdateParams.builder() - .tenantId("tenant_id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - TenantUpdateParams.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - TenantUpdateParams.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - val tenant = tenantFuture.get() - tenant.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.tenants() - - val tenantsFuture = - tenantServiceAsync.list( - TenantListParams.builder() - .cursor("cursor") - .limit(0L) - .parentTenantId("parent_tenant_id") - .build() - ) - - val tenants = tenantsFuture.get() - tenants.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.tenants() - - val future = tenantServiceAsync.delete("tenant_id") - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun listUsers() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.tenants() - - val responseFuture = - tenantServiceAsync.listUsers( - TenantListUsersParams.builder() - .tenantId("tenant_id") - .cursor("cursor") - .limit(0L) - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt deleted file mode 100644 index 2f131cfa..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/TranslationServiceAsyncTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.translations.TranslationRetrieveParams -import com.courier.api.models.translations.TranslationUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TranslationServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val translationServiceAsync = client.translations() - - val translationFuture = - translationServiceAsync.retrieve( - TranslationRetrieveParams.builder().domain("domain").locale("locale").build() - ) - - val translation = translationFuture.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val translationServiceAsync = client.translations() - - val future = - translationServiceAsync.update( - TranslationUpdateParams.builder() - .domain("domain") - .locale("locale") - .body("body") - .build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt deleted file mode 100644 index 3162bf76..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/automations/InvokeServiceAsyncTest.kt +++ /dev/null @@ -1,99 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.automations - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.automations.invoke.AutomationInvokeParams -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams -import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class InvokeServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun invokeAdHoc() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val invokeServiceAsync = client.automations().invoke() - - val automationInvokeResponseFuture = - invokeServiceAsync.invokeAdHoc( - InvokeInvokeAdHocParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .automation( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() - .if_("if") - .ref("ref") - .action( - InvokeInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .cancelationToken("cancelation_token") - .build() - ) - .build() - ) - - val automationInvokeResponse = automationInvokeResponseFuture.get() - automationInvokeResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun invokeByTemplate() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val invokeServiceAsync = client.automations().invoke() - - val automationInvokeResponseFuture = - invokeServiceAsync.invokeByTemplate( - InvokeInvokeByTemplateParams.builder() - .templateId("templateId") - .automationInvokeParams( - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - ) - .build() - ) - - val automationInvokeResponse = automationInvokeResponseFuture.get() - automationInvokeResponse.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt deleted file mode 100644 index ac98bbfd..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/lists/SubscriptionServiceAsyncTest.kt +++ /dev/null @@ -1,278 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.lists - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.PutSubscriptionsRecipient -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.lists.subscriptions.SubscriptionAddParams -import com.courier.api.models.lists.subscriptions.SubscriptionListParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams -import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class SubscriptionServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionServiceAsync = client.lists().subscriptions() - - val subscriptionsFuture = - subscriptionServiceAsync.list( - SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() - ) - - val subscriptions = subscriptionsFuture.get() - subscriptions.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun add() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionServiceAsync = client.lists().subscriptions() - - val future = - subscriptionServiceAsync.add( - SubscriptionAddParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun subscribe() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionServiceAsync = client.lists().subscriptions() - - val future = - subscriptionServiceAsync.subscribe( - SubscriptionSubscribeParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun subscribeUser() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionServiceAsync = client.lists().subscriptions() - - val future = - subscriptionServiceAsync.subscribeUser( - SubscriptionSubscribeUserParams.builder() - .listId("list_id") - .userId("user_id") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun unsubscribeUser() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionServiceAsync = client.lists().subscriptions() - - val future = - subscriptionServiceAsync.unsubscribeUser( - SubscriptionUnsubscribeUserParams.builder() - .listId("list_id") - .userId("user_id") - .build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt deleted file mode 100644 index 1286a01d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/CheckServiceAsyncTest.kt +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.notifications - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.notifications.checks.BaseCheck -import com.courier.api.models.notifications.checks.CheckDeleteParams -import com.courier.api.models.notifications.checks.CheckListParams -import com.courier.api.models.notifications.checks.CheckUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class CheckServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val checkServiceAsync = client.notifications().checks() - - val checkFuture = - checkServiceAsync.update( - CheckUpdateParams.builder() - .id("id") - .submissionId("submissionId") - .addCheck( - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - ) - .build() - ) - - val check = checkFuture.get() - check.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val checkServiceAsync = client.notifications().checks() - - val checksFuture = - checkServiceAsync.list( - CheckListParams.builder().id("id").submissionId("submissionId").build() - ) - - val checks = checksFuture.get() - checks.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val checkServiceAsync = client.notifications().checks() - - val future = - checkServiceAsync.delete( - CheckDeleteParams.builder().id("id").submissionId("submissionId").build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt deleted file mode 100644 index b09a22cf..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/notifications/DraftServiceAsyncTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.notifications - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class DraftServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieveContent() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val draftServiceAsync = client.notifications().draft() - - val notificationGetContentFuture = draftServiceAsync.retrieveContent("id") - - val notificationGetContent = notificationGetContentFuture.get() - notificationGetContent.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt deleted file mode 100644 index a69c75b1..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/profiles/ListServiceAsyncTest.kt +++ /dev/null @@ -1,128 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.profiles - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.profiles.lists.ListRetrieveParams -import com.courier.api.models.profiles.lists.ListSubscribeParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ListServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.profiles().lists() - - val listFuture = - listServiceAsync.retrieve( - ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() - ) - - val list = listFuture.get() - list.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.profiles().lists() - - val listFuture = listServiceAsync.delete("user_id") - - val list = listFuture.get() - list.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun subscribe() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listServiceAsync = client.profiles().lists() - - val responseFuture = - listServiceAsync.subscribe( - ListSubscribeParams.builder() - .userId("user_id") - .addList( - ListSubscribeParams.List.builder() - .listId("listId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt deleted file mode 100644 index f650a197..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/TemplateServiceAsyncTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.tenants.templates.TemplateListParams -import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TemplateServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val templateServiceAsync = client.tenants().templates() - - val baseTemplateTenantAssociationFuture = - templateServiceAsync.retrieve( - TemplateRetrieveParams.builder() - .tenantId("tenant_id") - .templateId("template_id") - .build() - ) - - val baseTemplateTenantAssociation = baseTemplateTenantAssociationFuture.get() - baseTemplateTenantAssociation.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val templateServiceAsync = client.tenants().templates() - - val templatesFuture = - templateServiceAsync.list( - TemplateListParams.builder() - .tenantId("tenant_id") - .cursor("cursor") - .limit(0L) - .build() - ) - - val templates = templatesFuture.get() - templates.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt deleted file mode 100644 index 178e844b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/tenants/defaultpreferences/ItemServiceAsyncTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.tenants.defaultpreferences - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams -import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ItemServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val itemServiceAsync = client.tenants().defaultPreferences().items() - - val future = - itemServiceAsync.update( - ItemUpdateParams.builder() - .tenantId("tenant_id") - .topicId("topic_id") - .subscriptionTopicNew( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .hasCustomRouting(true) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val itemServiceAsync = client.tenants().defaultPreferences().items() - - val future = - itemServiceAsync.delete( - ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt deleted file mode 100644 index ae2b6af5..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/PreferenceServiceAsyncTest.kt +++ /dev/null @@ -1,91 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.users.preferences.PreferenceRetrieveParams -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams -import com.courier.api.models.users.preferences.PreferenceStatus -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class PreferenceServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val preferenceServiceAsync = client.users().preferences() - - val preferenceFuture = - preferenceServiceAsync.retrieve( - PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() - ) - - val preference = preferenceFuture.get() - preference.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveTopic() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val preferenceServiceAsync = client.users().preferences() - - val responseFuture = - preferenceServiceAsync.retrieveTopic( - PreferenceRetrieveTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun updateOrCreateTopic() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val preferenceServiceAsync = client.users().preferences() - - val responseFuture = - preferenceServiceAsync.updateOrCreateTopic( - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .addCustomRouting(ChannelClassification.EMAIL) - .hasCustomRouting(true) - .build() - ) - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt deleted file mode 100644 index aeacc695..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TenantServiceAsyncTest.kt +++ /dev/null @@ -1,129 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.users.tenants.TenantAddMultipleParams -import com.courier.api.models.users.tenants.TenantAddSingleParams -import com.courier.api.models.users.tenants.TenantAssociation -import com.courier.api.models.users.tenants.TenantListParams -import com.courier.api.models.users.tenants.TenantRemoveSingleParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TenantServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.users().tenants() - - val tenantsFuture = - tenantServiceAsync.list( - TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() - ) - - val tenants = tenantsFuture.get() - tenants.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun addMultiple() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.users().tenants() - - val future = - tenantServiceAsync.addMultiple( - TenantAddMultipleParams.builder() - .userId("user_id") - .addTenant( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun addSingle() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.users().tenants() - - val future = - tenantServiceAsync.addSingle( - TenantAddSingleParams.builder() - .userId("user_id") - .tenantId("tenant_id") - .profile( - TenantAddSingleParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun removeAll() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.users().tenants() - - val future = tenantServiceAsync.removeAll("user_id") - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun removeSingle() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantServiceAsync = client.users().tenants() - - val future = - tenantServiceAsync.removeSingle( - TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt deleted file mode 100644 index 166514a4..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/users/TokenServiceAsyncTest.kt +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.async.users - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClientAsync -import com.courier.api.core.JsonValue -import com.courier.api.models.users.tokens.TokenAddSingleParams -import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenRetrieveParams -import com.courier.api.models.users.tokens.TokenUpdateParams -import com.courier.api.models.users.tokens.UserToken -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TokenServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val tokenFuture = - tokenServiceAsync.retrieve( - TokenRetrieveParams.builder().userId("user_id").token("token").build() - ) - - val token = tokenFuture.get() - token.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val future = - tokenServiceAsync.update( - TokenUpdateParams.builder() - .userId("user_id") - .token("token") - .addPatch( - TokenUpdateParams.Patch.builder() - .op("op") - .path("path") - .value("value") - .build() - ) - .build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val userTokensFuture = tokenServiceAsync.list("user_id") - - val userTokens = userTokensFuture.get() - userTokens.forEach { it.validate() } - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val future = - tokenServiceAsync.delete( - TokenDeleteParams.builder().userId("user_id").token("token").build() - ) - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun addMultiple() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val future = tokenServiceAsync.addMultiple("user_id") - - val response = future.get() - } - - @Disabled("Prism tests are disabled") - @Test - fun addSingle() { - val client = - CourierOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenServiceAsync = client.users().tokens() - - val future = - tokenServiceAsync.addSingle( - TokenAddSingleParams.builder() - .userId("user_id") - .pathToken("token") - .userToken( - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - ) - .build() - ) - - val response = future.get() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt deleted file mode 100644 index 7495c8a9..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AudienceServiceTest.kt +++ /dev/null @@ -1,110 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.audiences.AudienceListMembersParams -import com.courier.api.models.audiences.AudienceListParams -import com.courier.api.models.audiences.AudienceUpdateParams -import com.courier.api.models.audiences.Filter -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class AudienceServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceService = client.audiences() - - val audience = audienceService.retrieve("audience_id") - - audience.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceService = client.audiences() - - val audience = - audienceService.update( - AudienceUpdateParams.builder() - .audienceId("audience_id") - .description("description") - .filter( - Filter.UnionMember0.builder() - .operator(Filter.UnionMember0.Operator.ENDS_WITH) - .path("path") - .value("value") - .build() - ) - .name("name") - .build() - ) - - audience.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceService = client.audiences() - - val audiences = audienceService.list(AudienceListParams.builder().cursor("cursor").build()) - - audiences.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceService = client.audiences() - - audienceService.delete("audience_id") - } - - @Disabled("Prism tests are disabled") - @Test - fun listMembers() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val audienceService = client.audiences() - - val response = - audienceService.listMembers( - AudienceListMembersParams.builder() - .audienceId("audience_id") - .cursor("cursor") - .build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt deleted file mode 100644 index 999fc16b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuditEventServiceTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.auditevents.AuditEventListParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class AuditEventServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val auditEventService = client.auditEvents() - - val auditEvent = auditEventService.retrieve("audit-event-id") - - auditEvent.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val auditEventService = client.auditEvents() - - val auditEvents = - auditEventService.list(AuditEventListParams.builder().cursor("cursor").build()) - - auditEvents.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt deleted file mode 100644 index b9598b04..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/AuthServiceTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.auth.AuthIssueTokenParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class AuthServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun issueToken() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val authService = client.auth() - - val response = - authService.issueToken( - AuthIssueTokenParams.builder().expiresIn("expires_in").scope("scope").build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt deleted file mode 100644 index a89fb29e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BrandServiceTest.kt +++ /dev/null @@ -1,165 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.brands.BrandColors -import com.courier.api.models.brands.BrandCreateParams -import com.courier.api.models.brands.BrandListParams -import com.courier.api.models.brands.BrandSettings -import com.courier.api.models.brands.BrandSnippet -import com.courier.api.models.brands.BrandSnippets -import com.courier.api.models.brands.BrandUpdateParams -import com.courier.api.models.brands.Email -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class BrandServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun create() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandService = client.brands() - - val brand = - brandService.create( - BrandCreateParams.builder() - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .id("id") - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - - brand.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandService = client.brands() - - val brand = brandService.retrieve("brand_id") - - brand.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandService = client.brands() - - val brand = - brandService.update( - BrandUpdateParams.builder() - .brandId("brand_id") - .name("name") - .settings( - BrandSettings.builder() - .colors( - BrandColors.builder() - .primary("primary") - .secondary("secondary") - .tertiary("tertiary") - .build() - ) - .email( - Email.builder() - .footer(JsonValue.from(mapOf())) - .header(JsonValue.from(mapOf())) - .build() - ) - .inapp(JsonValue.from(mapOf())) - .build() - ) - .snippets( - BrandSnippets.builder() - .addItem( - BrandSnippet.builder() - .format(BrandSnippet.Format.HANDLEBARS) - .name("name") - .value("value") - .build() - ) - .build() - ) - .build() - ) - - brand.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandService = client.brands() - - val brands = brandService.list(BrandListParams.builder().cursor("cursor").build()) - - brands.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val brandService = client.brands() - - brandService.delete("brand_id") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt deleted file mode 100644 index e1dce8ba..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/BulkServiceTest.kt +++ /dev/null @@ -1,377 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.bulk.BulkAddUsersParams -import com.courier.api.models.bulk.BulkCreateJobParams -import com.courier.api.models.bulk.BulkListUsersParams -import com.courier.api.models.bulk.InboundBulkMessage -import com.courier.api.models.bulk.InboundBulkMessageUser -import com.courier.api.models.bulk.UserRecipient -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.Utm -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class BulkServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun addUsers() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkService = client.bulk() - - bulkService.addUsers( - BulkAddUsersParams.builder() - .jobId("job_id") - .addUser( - InboundBulkMessageUser.builder() - .data(JsonValue.from(mapOf())) - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .to( - UserRecipient.builder() - .accountId("account_id") - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - UserRecipient.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .email("email") - .locale("locale") - .phoneNumber("phone_number") - .preferences( - UserRecipient.Preferences.builder() - .notifications( - UserRecipient.Preferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .categories( - UserRecipient.Preferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf( - "channel" to - "direct_message" - ) - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - "source" to "subscription", - ) - ), - ) - .build() - ) - .templateId("templateId") - .build() - ) - .tenantId("tenant_id") - .userId("user_id") - .build() - ) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun createJob() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkService = client.bulk() - - val response = - bulkService.createJob( - BulkCreateJobParams.builder() - .message( - InboundBulkMessage.builder() - .brand("brand") - .data( - InboundBulkMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .event("event") - .locale( - InboundBulkMessage.Locale.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .message( - InboundBulkMessage.Message.InboundBulkTemplateMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to - mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay( - BaseMessage.Delay.builder() - .duration(0L) - .until("until") - .build() - ) - .expiry( - BaseMessage.Expiry.builder() - .expiresIn("string") - .expiresAt("expires_at") - .build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .template("template") - .build() - ) - .override(JsonValue.from(mapOf())) - .build() - ) - .build() - ) - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun listUsers() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkService = client.bulk() - - val response = - bulkService.listUsers( - BulkListUsersParams.builder().jobId("job_id").cursor("cursor").build() - ) - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveJob() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkService = client.bulk() - - val response = bulkService.retrieveJob("job_id") - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun runJob() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val bulkService = client.bulk() - - bulkService.runJob("job_id") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt deleted file mode 100644 index ef1daaa3..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/InboundServiceTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.inbound.InboundTrackEventParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class InboundServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun trackEvent() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val inboundService = client.inbound() - - val response = - inboundService.trackEvent( - InboundTrackEventParams.builder() - .event("New Order Placed") - .messageId("4c62c457-b329-4bea-9bfc-17bba86c393f") - .properties( - InboundTrackEventParams.Properties.builder() - .putAdditionalProperty("order_id", JsonValue.from("bar")) - .putAdditionalProperty("total_orders", JsonValue.from("bar")) - .putAdditionalProperty("last_order_id", JsonValue.from("bar")) - .build() - ) - .type(InboundTrackEventParams.Type.TRACK) - .userId("1234") - .build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt deleted file mode 100644 index 7a52b218..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ListServiceTest.kt +++ /dev/null @@ -1,138 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.ListListParams -import com.courier.api.models.lists.ListRestoreParams -import com.courier.api.models.lists.ListUpdateParams -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ListServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.lists() - - val list = listService.retrieve("list_id") - - list.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.lists() - - listService.update( - ListUpdateParams.builder() - .listId("list_id") - .name("name") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.lists() - - val lists = - listService.list(ListListParams.builder().cursor("cursor").pattern("pattern").build()) - - lists.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.lists() - - listService.delete("list_id") - } - - @Disabled("Prism tests are disabled") - @Test - fun restore() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.lists() - - listService.restore( - ListRestoreParams.builder() - .listId("list_id") - .body(JsonValue.from(mapOf())) - .build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt deleted file mode 100644 index 4c6aeb06..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/MessageServiceTest.kt +++ /dev/null @@ -1,111 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.messages.MessageHistoryParams -import com.courier.api.models.messages.MessageListParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class MessageServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageService = client.messages() - - val message = messageService.retrieve("message_id") - - message.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageService = client.messages() - - val messages = - messageService.list( - MessageListParams.builder() - .archived(true) - .cursor("cursor") - .enqueuedAfter("enqueued_after") - .event("event") - .list("list") - .messageId("messageId") - .notification("notification") - .addProvider("string") - .recipient("recipient") - .addStatus("string") - .addTag("string") - .tags("tags") - .tenantId("tenant_id") - .traceId("traceId") - .build() - ) - - messages.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun cancel() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageService = client.messages() - - val messageDetails = messageService.cancel("message_id") - - messageDetails.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun content() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageService = client.messages() - - val response = messageService.content("message_id") - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun history() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val messageService = client.messages() - - val response = - messageService.history( - MessageHistoryParams.builder().messageId("message_id").type("type").build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt deleted file mode 100644 index 4fc3cacd..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/NotificationServiceTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.notifications.NotificationListParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class NotificationServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val notificationService = client.notifications() - - val notifications = - notificationService.list( - NotificationListParams.builder().cursor("cursor").notes(true).build() - ) - - notifications.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveContent() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val notificationService = client.notifications() - - val notificationGetContent = notificationService.retrieveContent("id") - - notificationGetContent.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt deleted file mode 100644 index e3af1883..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/ProfileServiceTest.kt +++ /dev/null @@ -1,115 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.profiles.ProfileCreateParams -import com.courier.api.models.profiles.ProfileReplaceParams -import com.courier.api.models.profiles.ProfileUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ProfileServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun create() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileService = client.profiles() - - val profile = - profileService.create( - ProfileCreateParams.builder() - .userId("user_id") - .profile( - ProfileCreateParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - profile.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileService = client.profiles() - - val profile = profileService.retrieve("user_id") - - profile.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileService = client.profiles() - - profileService.update( - ProfileUpdateParams.builder() - .userId("user_id") - .addPatch( - ProfileUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileService = client.profiles() - - profileService.delete("user_id") - } - - @Disabled("Prism tests are disabled") - @Test - fun replace() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val profileService = client.profiles() - - val response = - profileService.replace( - ProfileReplaceParams.builder() - .userId("user_id") - .profile( - ProfileReplaceParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt deleted file mode 100644 index f93af90b..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/RequestServiceTest.kt +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class RequestServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun archive() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val requestService = client.requests() - - requestService.archive("request_id") - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index d4487726..3c162c5d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -5,13 +5,8 @@ package com.courier.api.services.blocking import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.BaseMessageSendTo -import com.courier.api.models.send.Content -import com.courier.api.models.send.Message import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendMessageParams -import com.courier.api.models.send.Utm +import com.courier.api.models.send.SendSendMessageParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -21,7 +16,7 @@ internal class SendServiceTest { @Disabled("Prism tests are disabled") @Test - fun message() { + fun sendMessage() { val client = CourierOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -30,13 +25,19 @@ internal class SendServiceTest { val sendService = client.send() val response = - sendService.message( - SendMessageParams.builder() + sendService.sendMessage( + SendSendMessageParams.builder() .message( - Message.ContentMessage.builder() + SendSendMessageParams.Message.builder() + .content( + SendSendMessageParams.Message.Content.builder() + .body("Thanks for signing up, {{name}}") + .title("Welcome!") + .build() + ) .brandId("brand_id") .channels( - BaseMessage.Channels.builder() + SendSendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -65,24 +66,29 @@ internal class SendServiceTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessage.Data.builder() + SendSendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) + .delay( + SendSendMessageParams.Message.Delay.builder() + .duration(0L) + .until("until") + .build() + ) .expiry( - BaseMessage.Expiry.builder() + SendSendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - BaseMessage.Metadata.builder() + SendSendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - Utm.builder() + SendSendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -93,12 +99,12 @@ internal class SendServiceTest { .build() ) .preferences( - BaseMessage.Preferences.builder() + SendSendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - BaseMessage.Providers.builder() + SendSendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -123,55 +129,110 @@ internal class SendServiceTest { .build() ) .routing( - BaseMessage.Routing.builder() + SendSendMessageParams.Message.Routing.builder() .addChannel("email") - .method(BaseMessage.Routing.Method.SINGLE) + .method(SendSendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - BaseMessage.Timeout.builder() + SendSendMessageParams.Message.Timeout.builder() .channel( - BaseMessage.Timeout.Channel.builder() + SendSendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) + .criteria( + SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION + ) .escalation(0L) .message(0L) .provider( - BaseMessage.Timeout.Provider.builder() + SendSendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - BaseMessageSendTo.To.UnionMember1.builder() + SendSendMessageParams.Message.To.UnionMember0.builder() + .accountId("account_id") + .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - BaseMessageSendTo.To.UnionMember1.Data.builder() + SendSendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) - .addFilter( - BaseMessageSendTo.To.UnionMember1.Filter.builder() - .operator( - BaseMessageSendTo.To.UnionMember1.Filter.Operator - .MEMBER_OF + .email("email@example.com") + .locale("locale") + .phoneNumber("phone_number") + .preferences( + SendSendMessageParams.Message.To.UnionMember0.Preferences + .builder() + .notifications( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Notifications + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .path( - BaseMessageSendTo.To.UnionMember1.Filter.Path - .ACCOUNT_ID + .categories( + SendSendMessageParams.Message.To.UnionMember0 + .Preferences + .Categories + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf( + "status" to "OPTED_IN", + "channel_preferences" to + listOf( + mapOf( + "channel" to + "direct_message" + ) + ), + "rules" to + listOf( + mapOf( + "until" to "until", + "start" to "start", + ) + ), + "source" to "subscription", + ) + ), + ) + .build() ) - .value("value") + .templateId("templateId") .build() ) - .listId("list_id") - .build() - ) - .content( - Content.ElementalContentSugar.builder() - .body("Thanks for signing up, {{name}}") - .title("Welcome!") + .tenantId("tenant_id") + .userId("user_id") .build() ) .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt deleted file mode 100644 index 369706d9..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TenantServiceTest.kt +++ /dev/null @@ -1,137 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.tenants.DefaultPreferences -import com.courier.api.models.tenants.TenantListParams -import com.courier.api.models.tenants.TenantListUsersParams -import com.courier.api.models.tenants.TenantUpdateParams -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TenantServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.tenants() - - val tenant = tenantService.retrieve("tenant_id") - - tenant.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.tenants() - - val tenant = - tenantService.update( - TenantUpdateParams.builder() - .tenantId("tenant_id") - .name("name") - .brandId("brand_id") - .defaultPreferences( - DefaultPreferences.builder() - .addItem( - DefaultPreferences.Item.builder() - .status(SubscriptionTopicNew.Status.OPTED_OUT) - .addCustomRouting(ChannelClassification.DIRECT_MESSAGE) - .hasCustomRouting(true) - .id("id") - .build() - ) - .build() - ) - .parentTenantId("parent_tenant_id") - .properties( - TenantUpdateParams.Properties.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .userProfile( - TenantUpdateParams.UserProfile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - - tenant.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.tenants() - - val tenants = - tenantService.list( - TenantListParams.builder() - .cursor("cursor") - .limit(0L) - .parentTenantId("parent_tenant_id") - .build() - ) - - tenants.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.tenants() - - tenantService.delete("tenant_id") - } - - @Disabled("Prism tests are disabled") - @Test - fun listUsers() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.tenants() - - val response = - tenantService.listUsers( - TenantListUsersParams.builder() - .tenantId("tenant_id") - .cursor("cursor") - .limit(0L) - .build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt deleted file mode 100644 index a66eee8a..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/TranslationServiceTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.translations.TranslationRetrieveParams -import com.courier.api.models.translations.TranslationUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TranslationServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val translationService = client.translations() - - translationService.retrieve( - TranslationRetrieveParams.builder().domain("domain").locale("locale").build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val translationService = client.translations() - - translationService.update( - TranslationUpdateParams.builder().domain("domain").locale("locale").body("body").build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt deleted file mode 100644 index 4a3aaa0c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/automations/InvokeServiceTest.kt +++ /dev/null @@ -1,97 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.automations - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.automations.invoke.AutomationInvokeParams -import com.courier.api.models.automations.invoke.InvokeInvokeAdHocParams -import com.courier.api.models.automations.invoke.InvokeInvokeByTemplateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class InvokeServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun invokeAdHoc() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val invokeService = client.automations().invoke() - - val automationInvokeResponse = - invokeService.invokeAdHoc( - InvokeInvokeAdHocParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .automation( - InvokeInvokeAdHocParams.Automation.builder() - .addStep( - InvokeInvokeAdHocParams.Automation.Step.AutomationAddToDigestStep - .builder() - .if_("if") - .ref("ref") - .action( - InvokeInvokeAdHocParams.Automation.Step - .AutomationAddToDigestStep - .Action - .ADD_TO_DIGEST - ) - .subscriptionTopicId("RAJE97CMT04KDJJ88ZDS2TP1690S") - .build() - ) - .cancelationToken("cancelation_token") - .build() - ) - .build() - ) - - automationInvokeResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun invokeByTemplate() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val invokeService = client.automations().invoke() - - val automationInvokeResponse = - invokeService.invokeByTemplate( - InvokeInvokeByTemplateParams.builder() - .templateId("templateId") - .automationInvokeParams( - AutomationInvokeParams.builder() - .brand("brand") - .data( - AutomationInvokeParams.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .profile(JsonValue.from(mapOf())) - .recipient("recipient") - .template("template") - .build() - ) - .build() - ) - - automationInvokeResponse.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt deleted file mode 100644 index b83e172c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/lists/SubscriptionServiceTest.kt +++ /dev/null @@ -1,256 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.lists - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.PutSubscriptionsRecipient -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.lists.subscriptions.SubscriptionAddParams -import com.courier.api.models.lists.subscriptions.SubscriptionListParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeParams -import com.courier.api.models.lists.subscriptions.SubscriptionSubscribeUserParams -import com.courier.api.models.lists.subscriptions.SubscriptionUnsubscribeUserParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class SubscriptionServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionService = client.lists().subscriptions() - - val subscriptions = - subscriptionService.list( - SubscriptionListParams.builder().listId("list_id").cursor("cursor").build() - ) - - subscriptions.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun add() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionService = client.lists().subscriptions() - - subscriptionService.add( - SubscriptionAddParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun subscribe() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionService = client.lists().subscriptions() - - subscriptionService.subscribe( - SubscriptionSubscribeParams.builder() - .listId("list_id") - .addRecipient( - PutSubscriptionsRecipient.builder() - .recipientId("recipientId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun subscribeUser() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionService = client.lists().subscriptions() - - subscriptionService.subscribeUser( - SubscriptionSubscribeUserParams.builder() - .listId("list_id") - .userId("user_id") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf(mapOf("channel" to "direct_message")), - "rules" to - listOf( - mapOf("until" to "until", "start" to "start") - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun unsubscribeUser() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val subscriptionService = client.lists().subscriptions() - - subscriptionService.unsubscribeUser( - SubscriptionUnsubscribeUserParams.builder().listId("list_id").userId("user_id").build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt deleted file mode 100644 index 5fc62ebd..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/CheckServiceTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.notifications - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.notifications.checks.BaseCheck -import com.courier.api.models.notifications.checks.CheckDeleteParams -import com.courier.api.models.notifications.checks.CheckListParams -import com.courier.api.models.notifications.checks.CheckUpdateParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class CheckServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val checkService = client.notifications().checks() - - val check = - checkService.update( - CheckUpdateParams.builder() - .id("id") - .submissionId("submissionId") - .addCheck( - BaseCheck.builder() - .id("id") - .status(BaseCheck.Status.RESOLVED) - .type(BaseCheck.Type.CUSTOM) - .build() - ) - .build() - ) - - check.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val checkService = client.notifications().checks() - - val checks = - checkService.list( - CheckListParams.builder().id("id").submissionId("submissionId").build() - ) - - checks.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val checkService = client.notifications().checks() - - checkService.delete( - CheckDeleteParams.builder().id("id").submissionId("submissionId").build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt deleted file mode 100644 index a18eff3d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/notifications/DraftServiceTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.notifications - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class DraftServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieveContent() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val draftService = client.notifications().draft() - - val notificationGetContent = draftService.retrieveContent("id") - - notificationGetContent.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt deleted file mode 100644 index c461997e..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/profiles/ListServiceTest.kt +++ /dev/null @@ -1,125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.profiles - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.lists.subscriptions.RecipientPreferences -import com.courier.api.models.profiles.lists.ListRetrieveParams -import com.courier.api.models.profiles.lists.ListSubscribeParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ListServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.profiles().lists() - - val list = - listService.retrieve( - ListRetrieveParams.builder().userId("user_id").cursor("cursor").build() - ) - - list.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.profiles().lists() - - val list = listService.delete("user_id") - - list.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun subscribe() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val listService = client.profiles().lists() - - val response = - listService.subscribe( - ListSubscribeParams.builder() - .userId("user_id") - .addList( - ListSubscribeParams.List.builder() - .listId("listId") - .preferences( - RecipientPreferences.builder() - .categories( - RecipientPreferences.Categories.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .notifications( - RecipientPreferences.Notifications.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "status" to "OPTED_IN", - "channel_preferences" to - listOf( - mapOf("channel" to "direct_message") - ), - "rules" to - listOf( - mapOf( - "until" to "until", - "start" to "start", - ) - ), - ) - ), - ) - .build() - ) - .build() - ) - .build() - ) - .build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt deleted file mode 100644 index 2476c72d..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/TemplateServiceTest.kt +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.tenants.templates.TemplateListParams -import com.courier.api.models.tenants.templates.TemplateRetrieveParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TemplateServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val templateService = client.tenants().templates() - - val baseTemplateTenantAssociation = - templateService.retrieve( - TemplateRetrieveParams.builder() - .tenantId("tenant_id") - .templateId("template_id") - .build() - ) - - baseTemplateTenantAssociation.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val templateService = client.tenants().templates() - - val templates = - templateService.list( - TemplateListParams.builder() - .tenantId("tenant_id") - .cursor("cursor") - .limit(0L) - .build() - ) - - templates.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt deleted file mode 100644 index 61393e18..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/tenants/defaultpreferences/ItemServiceTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.tenants.defaultpreferences - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.tenants.defaultpreferences.items.ItemDeleteParams -import com.courier.api.models.tenants.defaultpreferences.items.ItemUpdateParams -import com.courier.api.models.tenants.defaultpreferences.items.SubscriptionTopicNew -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class ItemServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val itemService = client.tenants().defaultPreferences().items() - - itemService.update( - ItemUpdateParams.builder() - .tenantId("tenant_id") - .topicId("topic_id") - .subscriptionTopicNew( - SubscriptionTopicNew.builder() - .status(SubscriptionTopicNew.Status.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .hasCustomRouting(true) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val itemService = client.tenants().defaultPreferences().items() - - itemService.delete( - ItemDeleteParams.builder().tenantId("tenant_id").topicId("topic_id").build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt deleted file mode 100644 index 6b210735..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/PreferenceServiceTest.kt +++ /dev/null @@ -1,88 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.models.tenants.defaultpreferences.items.ChannelClassification -import com.courier.api.models.users.preferences.PreferenceRetrieveParams -import com.courier.api.models.users.preferences.PreferenceRetrieveTopicParams -import com.courier.api.models.users.preferences.PreferenceStatus -import com.courier.api.models.users.preferences.PreferenceUpdateOrCreateTopicParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class PreferenceServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val preferenceService = client.users().preferences() - - val preference = - preferenceService.retrieve( - PreferenceRetrieveParams.builder().userId("user_id").tenantId("tenant_id").build() - ) - - preference.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun retrieveTopic() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val preferenceService = client.users().preferences() - - val response = - preferenceService.retrieveTopic( - PreferenceRetrieveTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .build() - ) - - response.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun updateOrCreateTopic() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val preferenceService = client.users().preferences() - - val response = - preferenceService.updateOrCreateTopic( - PreferenceUpdateOrCreateTopicParams.builder() - .userId("user_id") - .topicId("topic_id") - .tenantId("tenant_id") - .topic( - PreferenceUpdateOrCreateTopicParams.Topic.builder() - .status(PreferenceStatus.OPTED_IN) - .addCustomRouting(ChannelClassification.INBOX) - .addCustomRouting(ChannelClassification.EMAIL) - .hasCustomRouting(true) - .build() - ) - .build() - ) - - response.validate() - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt deleted file mode 100644 index 508c58be..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TenantServiceTest.kt +++ /dev/null @@ -1,117 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.users.tenants.TenantAddMultipleParams -import com.courier.api.models.users.tenants.TenantAddSingleParams -import com.courier.api.models.users.tenants.TenantAssociation -import com.courier.api.models.users.tenants.TenantListParams -import com.courier.api.models.users.tenants.TenantRemoveSingleParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TenantServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.users().tenants() - - val tenants = - tenantService.list( - TenantListParams.builder().userId("user_id").cursor("cursor").limit(0L).build() - ) - - tenants.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun addMultiple() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.users().tenants() - - tenantService.addMultiple( - TenantAddMultipleParams.builder() - .userId("user_id") - .addTenant( - TenantAssociation.builder() - .tenantId("tenant_id") - .profile( - TenantAssociation.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .type(TenantAssociation.Type.USER) - .userId("user_id") - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun addSingle() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.users().tenants() - - tenantService.addSingle( - TenantAddSingleParams.builder() - .userId("user_id") - .tenantId("tenant_id") - .profile( - TenantAddSingleParams.Profile.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun removeAll() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.users().tenants() - - tenantService.removeAll("user_id") - } - - @Disabled("Prism tests are disabled") - @Test - fun removeSingle() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tenantService = client.users().tenants() - - tenantService.removeSingle( - TenantRemoveSingleParams.builder().userId("user_id").tenantId("tenant_id").build() - ) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt deleted file mode 100644 index 255c522c..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/users/TokenServiceTest.kt +++ /dev/null @@ -1,143 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.services.blocking.users - -import com.courier.api.TestServerExtension -import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue -import com.courier.api.models.users.tokens.TokenAddSingleParams -import com.courier.api.models.users.tokens.TokenDeleteParams -import com.courier.api.models.users.tokens.TokenRetrieveParams -import com.courier.api.models.users.tokens.TokenUpdateParams -import com.courier.api.models.users.tokens.UserToken -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class TokenServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun retrieve() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - val token = - tokenService.retrieve( - TokenRetrieveParams.builder().userId("user_id").token("token").build() - ) - - token.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun update() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - tokenService.update( - TokenUpdateParams.builder() - .userId("user_id") - .token("token") - .addPatch( - TokenUpdateParams.Patch.builder().op("op").path("path").value("value").build() - ) - .build() - ) - } - - @Disabled("Prism tests are disabled") - @Test - fun list() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - val userTokens = tokenService.list("user_id") - - userTokens.forEach { it.validate() } - } - - @Disabled("Prism tests are disabled") - @Test - fun delete() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - tokenService.delete(TokenDeleteParams.builder().userId("user_id").token("token").build()) - } - - @Disabled("Prism tests are disabled") - @Test - fun addMultiple() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - tokenService.addMultiple("user_id") - } - - @Disabled("Prism tests are disabled") - @Test - fun addSingle() { - val client = - CourierOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val tokenService = client.users().tokens() - - tokenService.addSingle( - TokenAddSingleParams.builder() - .userId("user_id") - .pathToken("token") - .userToken( - UserToken.builder() - .providerKey(UserToken.ProviderKey.FIREBASE_FCM) - .token("token") - .device( - UserToken.Device.builder() - .adId("ad_id") - .appId("app_id") - .deviceId("device_id") - .manufacturer("manufacturer") - .model("model") - .platform("platform") - .build() - ) - .expiryDate("string") - .properties(JsonValue.from(mapOf())) - .tracking( - UserToken.Tracking.builder() - .ip("ip") - .lat("lat") - .long_("long") - .osVersion("os_version") - .build() - ) - .build() - ) - .build() - ) - } -} diff --git a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt index 34bdb5b3..9c4f39a2 100644 --- a/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt +++ b/courier-java-proguard-test/src/test/kotlin/com/courier/api/proguard/ProGuardCompatibilityTest.kt @@ -3,15 +3,9 @@ package com.courier.api.proguard import com.courier.api.client.okhttp.CourierOkHttpClient -import com.courier.api.core.JsonValue import com.courier.api.core.jsonMapper -import com.courier.api.models.automations.invoke.MergeAlgorithm -import com.courier.api.models.send.BaseMessage -import com.courier.api.models.send.Content import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.Utm -import com.courier.api.models.tenants.templates.ElementalContent -import com.courier.api.models.tenants.templates.ElementalNode +import com.courier.api.models.send.MessageRoutingChannel import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -55,184 +49,33 @@ internal class ProGuardCompatibilityTest { assertThat(client).isNotNull() assertThat(client.send()).isNotNull() - assertThat(client.audiences()).isNotNull() - assertThat(client.auditEvents()).isNotNull() - assertThat(client.auth()).isNotNull() - assertThat(client.automations()).isNotNull() - assertThat(client.brands()).isNotNull() - assertThat(client.bulk()).isNotNull() - assertThat(client.inbound()).isNotNull() - assertThat(client.lists()).isNotNull() - assertThat(client.messages()).isNotNull() - assertThat(client.requests()).isNotNull() - assertThat(client.notifications()).isNotNull() - assertThat(client.profiles()).isNotNull() - assertThat(client.tenants()).isNotNull() - assertThat(client.translations()).isNotNull() - assertThat(client.users()).isNotNull() } @Test - fun baseMessageRoundtrip() { + fun messageContextRoundtrip() { val jsonMapper = jsonMapper() - val baseMessage = - BaseMessage.builder() - .brandId("brand_id") - .channels( - BaseMessage.Channels.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "brand_id" to "brand_id", - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "providers" to listOf("string"), - "routing_method" to "all", - "timeouts" to mapOf("channel" to 0, "provider" to 0), - ) - ), - ) - .build() - ) - .context(MessageContext.builder().tenantId("tenant_id").build()) - .data( - BaseMessage.Data.builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .delay(BaseMessage.Delay.builder().duration(0L).until("until").build()) - .expiry( - BaseMessage.Expiry.builder().expiresIn("string").expiresAt("expires_at").build() - ) - .metadata( - BaseMessage.Metadata.builder() - .event("event") - .addTag("string") - .traceId("trace_id") - .utm( - Utm.builder() - .campaign("campaign") - .content("content") - .medium("medium") - .source("source") - .term("term") - .build() - ) - .build() - ) - .preferences( - BaseMessage.Preferences.builder() - .subscriptionTopicId("subscription_topic_id") - .build() - ) - .providers( - BaseMessage.Providers.builder() - .putAdditionalProperty( - "foo", - JsonValue.from( - mapOf( - "if" to "if", - "metadata" to - mapOf( - "utm" to - mapOf( - "campaign" to "campaign", - "content" to "content", - "medium" to "medium", - "source" to "source", - "term" to "term", - ) - ), - "override" to mapOf("foo" to "bar"), - "timeouts" to 0, - ) - ), - ) - .build() - ) - .routing( - BaseMessage.Routing.builder() - .addChannel("string") - .method(BaseMessage.Routing.Method.ALL) - .build() - ) - .timeout( - BaseMessage.Timeout.builder() - .channel( - BaseMessage.Timeout.Channel.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .criteria(BaseMessage.Timeout.Criteria.NO_ESCALATION) - .escalation(0L) - .message(0L) - .provider( - BaseMessage.Timeout.Provider.builder() - .putAdditionalProperty("foo", JsonValue.from(0)) - .build() - ) - .build() - ) - .build() - - val roundtrippedBaseMessage = - jsonMapper.readValue( - jsonMapper.writeValueAsString(baseMessage), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBaseMessage).isEqualTo(baseMessage) - } + val messageContext = MessageContext.builder().tenantId("tenant_id").build() - @Test - fun contentRoundtrip() { - val jsonMapper = jsonMapper() - val content = - Content.ofElemental( - ElementalContent.builder() - .addElement( - ElementalNode.UnionMember0.builder() - .addChannel("string") - .if_("if") - .loop("loop") - .ref("ref") - .type(ElementalNode.UnionMember0.Type.TEXT) - .build() - ) - .version("version") - .brand(JsonValue.from(mapOf())) - .build() + val roundtrippedMessageContext = + jsonMapper.readValue( + jsonMapper.writeValueAsString(messageContext), + jacksonTypeRef(), ) - val roundtrippedContent = - jsonMapper.readValue(jsonMapper.writeValueAsString(content), jacksonTypeRef()) - - assertThat(roundtrippedContent).isEqualTo(content) + assertThat(roundtrippedMessageContext).isEqualTo(messageContext) } @Test - fun mergeAlgorithmRoundtrip() { + fun messageRoutingChannelRoundtrip() { val jsonMapper = jsonMapper() - val mergeAlgorithm = MergeAlgorithm.REPLACE + val messageRoutingChannel = MessageRoutingChannel.ofString("string") - val roundtrippedMergeAlgorithm = + val roundtrippedMessageRoutingChannel = jsonMapper.readValue( - jsonMapper.writeValueAsString(mergeAlgorithm), - jacksonTypeRef(), + jsonMapper.writeValueAsString(messageRoutingChannel), + jacksonTypeRef(), ) - assertThat(roundtrippedMergeAlgorithm).isEqualTo(mergeAlgorithm) + assertThat(roundtrippedMessageRoutingChannel).isEqualTo(messageRoutingChannel) } } From 998a0c13140b88e4fba9fbd2374e07b3ec6a4849 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 19:25:37 +0000 Subject: [PATCH 21/33] feat(api): manual updates --- .stats.yml | 2 +- README.md | 90 +- ...dMessageParams.kt => SendMessageParams.kt} | 24 +- ...sageResponse.kt => SendMessageResponse.kt} | 24 +- .../api/services/async/SendServiceAsync.kt | 36 +- .../services/async/SendServiceAsyncImpl.kt | 24 +- .../api/services/blocking/SendService.kt | 30 +- .../api/services/blocking/SendServiceImpl.kt | 24 +- ...ParamsTest.kt => SendMessageParamsTest.kt} | 147 ++- .../models/send/SendMessageResponseTest.kt | 34 + .../send/SendSendMessageResponseTest.kt | 39 - .../courier/api/services/ErrorHandlingTest.kt | 869 +++++++++--------- .../courier/api/services/ServiceParamsTest.kt | 55 +- .../services/async/SendServiceAsyncTest.kt | 50 +- .../api/services/blocking/SendServiceTest.kt | 50 +- 15 files changed, 716 insertions(+), 782 deletions(-) rename courier-java-core/src/main/kotlin/com/courier/api/models/send/{SendSendMessageParams.kt => SendMessageParams.kt} (99%) rename courier-java-core/src/main/kotlin/com/courier/api/models/send/{SendSendMessageResponse.kt => SendMessageResponse.kt} (88%) rename courier-java-core/src/test/kotlin/com/courier/api/models/send/{SendSendMessageParamsTest.kt => SendMessageParamsTest.kt} (85%) create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt delete mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 8f5c8e4b..1390599a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 1 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-851bd80e56022cef0ab7c12f24f6ff89aab45140bcc7274810661a344a4541b1.yml openapi_spec_hash: 302486c729027393a465d01fe9d006eb -config_hash: 16d43e6b36e03e2a6139adae633325a5 +config_hash: beed1fd2e7d46cccf41ebdb7fcbcbdbe diff --git a/README.md b/README.md index 69c1d4b6..af914878 100644 --- a/README.md +++ b/README.md @@ -48,22 +48,22 @@ This library requires Java 8 or later. ```java import com.courier.api.client.CourierClient; import com.courier.api.client.okhttp.CourierOkHttpClient; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClient client = CourierOkHttpClient.fromEnv(); -SendSendMessageParams params = SendSendMessageParams.builder() - .message(SendSendMessageParams.Message.builder() - .content(SendSendMessageParams.Message.Content.builder() +SendMessageParams params = SendMessageParams.builder() + .message(SendMessageParams.Message.builder() + .content(SendMessageParams.Message.Content.builder() .body("body") .title("title") .build()) .build()) .build(); -SendSendMessageResponse response = client.send().sendMessage(params); +SendMessageResponse response = client.send().message(params); ``` ## Client configuration @@ -136,7 +136,7 @@ The `withOptions()` method does not affect the original client or service. To send a request to the Courier API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. -For example, `client.send().sendMessage(...)` should be called with an instance of `SendSendMessageParams`, and it will return an instance of `SendSendMessageResponse`. +For example, `client.send().message(...)` should be called with an instance of `SendMessageParams`, and it will return an instance of `SendMessageResponse`. ## Immutability @@ -153,23 +153,23 @@ The default client is synchronous. To switch to asynchronous execution, call the ```java import com.courier.api.client.CourierClient; import com.courier.api.client.okhttp.CourierOkHttpClient; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; import java.util.concurrent.CompletableFuture; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClient client = CourierOkHttpClient.fromEnv(); -SendSendMessageParams params = SendSendMessageParams.builder() - .message(SendSendMessageParams.Message.builder() - .content(SendSendMessageParams.Message.Content.builder() +SendMessageParams params = SendMessageParams.builder() + .message(SendMessageParams.Message.builder() + .content(SendMessageParams.Message.Content.builder() .body("body") .title("title") .build()) .build()) .build(); -CompletableFuture response = client.async().send().sendMessage(params); +CompletableFuture response = client.async().send().message(params); ``` Or create an asynchronous client from the beginning: @@ -177,23 +177,23 @@ Or create an asynchronous client from the beginning: ```java import com.courier.api.client.CourierClientAsync; import com.courier.api.client.okhttp.CourierOkHttpClientAsync; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; import java.util.concurrent.CompletableFuture; // Configures using the `courier.apiKey` and `courier.baseUrl` system properties // Or configures using the `COURIER_API_KEY` and `COURIER_BASE_URL` environment variables CourierClientAsync client = CourierOkHttpClientAsync.fromEnv(); -SendSendMessageParams params = SendSendMessageParams.builder() - .message(SendSendMessageParams.Message.builder() - .content(SendSendMessageParams.Message.Content.builder() +SendMessageParams params = SendMessageParams.builder() + .message(SendMessageParams.Message.builder() + .content(SendMessageParams.Message.Content.builder() .body("body") .title("title") .build()) .build()) .build(); -CompletableFuture response = client.send().sendMessage(params); +CompletableFuture response = client.send().message(params); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -207,18 +207,18 @@ To access this data, prefix any HTTP method call on a client or service with `wi ```java import com.courier.api.core.http.Headers; import com.courier.api.core.http.HttpResponseFor; -import com.courier.api.models.send.SendSendMessageParams; -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageParams; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageParams params = SendSendMessageParams.builder() - .message(SendSendMessageParams.Message.builder() - .content(SendSendMessageParams.Message.Content.builder() +SendMessageParams params = SendMessageParams.builder() + .message(SendMessageParams.Message.builder() + .content(SendMessageParams.Message.Content.builder() .body("body") .title("title") .build()) .build()) .build(); -HttpResponseFor response = client.send().withRawResponse().sendMessage(params); +HttpResponseFor response = client.send().withRawResponse().message(params); int statusCode = response.statusCode(); Headers headers = response.headers(); @@ -227,9 +227,9 @@ Headers headers = response.headers(); You can still deserialize the response into an instance of a Java class if needed: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse parsedResponse = response.parse(); +SendMessageResponse parsedResponse = response.parse(); ``` ## Error handling @@ -325,9 +325,9 @@ Requests time out after 1 minute by default. To set a custom timeout, configure the method call using the `timeout` method: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse response = client.send().sendMessage( +SendMessageResponse response = client.send().message( params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build() ); ``` @@ -432,9 +432,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -447,10 +447,10 @@ To set undocumented parameters on _nested_ headers, query params, or body classe ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() - .message(SendSendMessageParams.Message.builder() +SendMessageParams params = SendMessageParams.builder() + .message(SendMessageParams.Message.builder() .putAdditionalProperty("secretProperty", JsonValue.from("42")) .build()) .build(); @@ -462,9 +462,9 @@ To set a documented parameter or property to an undocumented or not yet supporte ```java import com.courier.api.core.JsonValue; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(JsonValue.from(42)) .build(); ``` @@ -514,9 +514,9 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](courier- ```java import com.courier.api.core.JsonMissing; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; -SendSendMessageParams params = SendSendMessageParams.builder() +SendMessageParams params = SendMessageParams.builder() .message(JsonMissing.of()) .build(); ``` @@ -529,7 +529,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.courier.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.send().sendMessage(params)._additionalProperties(); +Map additionalProperties = client.send().message(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -557,10 +557,10 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p ```java import com.courier.api.core.JsonField; -import com.courier.api.models.send.SendSendMessageParams; +import com.courier.api.models.send.SendMessageParams; import java.util.Optional; -JsonField message = client.send().sendMessage(params)._message(); +JsonField message = client.send().message(params)._message(); if (message.isMissing()) { // The property is absent from the JSON response @@ -585,17 +585,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Co If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse response = client.send().sendMessage(params).validate(); +SendMessageResponse response = client.send().message(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.courier.api.models.send.SendSendMessageResponse; +import com.courier.api.models.send.SendMessageResponse; -SendSendMessageResponse response = client.send().sendMessage( +SendMessageResponse response = client.send().message( params, RequestOptions.builder().responseValidation(true).build() ); ``` diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt similarity index 99% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt index 57a3d730..e2f3df65 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt @@ -35,7 +35,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Use the send API to send a message to one or more recipients. */ -class SendSendMessageParams +class SendMessageParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -71,7 +71,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SendSendMessageParams]. + * Returns a mutable builder for constructing an instance of [SendMessageParams]. * * The following fields are required: * ```java @@ -81,7 +81,7 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SendSendMessageParams]. */ + /** A builder for [SendMessageParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -89,10 +89,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(sendSendMessageParams: SendSendMessageParams) = apply { - body = sendSendMessageParams.body.toBuilder() - additionalHeaders = sendSendMessageParams.additionalHeaders.toBuilder() - additionalQueryParams = sendSendMessageParams.additionalQueryParams.toBuilder() + internal fun from(sendMessageParams: SendMessageParams) = apply { + body = sendMessageParams.body.toBuilder() + additionalHeaders = sendMessageParams.additionalHeaders.toBuilder() + additionalQueryParams = sendMessageParams.additionalQueryParams.toBuilder() } /** @@ -236,7 +236,7 @@ private constructor( } /** - * Returns an immutable instance of [SendSendMessageParams]. + * Returns an immutable instance of [SendMessageParams]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -247,8 +247,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): SendSendMessageParams = - SendSendMessageParams( + fun build(): SendMessageParams = + SendMessageParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -5271,7 +5271,7 @@ private constructor( return true } - return other is SendSendMessageParams && + return other is SendMessageParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -5280,5 +5280,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "SendSendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "SendMessageParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt similarity index 88% rename from courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt rename to courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt index 095675f4..4bf01b01 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendSendMessageResponse.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageResponse.kt @@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import java.util.Collections import java.util.Objects -class SendSendMessageResponse +class SendMessageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val requestId: JsonField, @@ -59,7 +59,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [SendSendMessageResponse]. + * Returns a mutable builder for constructing an instance of [SendMessageResponse]. * * The following fields are required: * ```java @@ -69,16 +69,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [SendSendMessageResponse]. */ + /** A builder for [SendMessageResponse]. */ class Builder internal constructor() { private var requestId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(sendSendMessageResponse: SendSendMessageResponse) = apply { - requestId = sendSendMessageResponse.requestId - additionalProperties = sendSendMessageResponse.additionalProperties.toMutableMap() + internal fun from(sendMessageResponse: SendMessageResponse) = apply { + requestId = sendMessageResponse.requestId + additionalProperties = sendMessageResponse.additionalProperties.toMutableMap() } /** @@ -118,7 +118,7 @@ private constructor( } /** - * Returns an immutable instance of [SendSendMessageResponse]. + * Returns an immutable instance of [SendMessageResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -129,8 +129,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): SendSendMessageResponse = - SendSendMessageResponse( + fun build(): SendMessageResponse = + SendMessageResponse( checkRequired("requestId", requestId), additionalProperties.toMutableMap(), ) @@ -138,7 +138,7 @@ private constructor( private var validated: Boolean = false - fun validate(): SendSendMessageResponse = apply { + fun validate(): SendMessageResponse = apply { if (validated) { return@apply } @@ -167,7 +167,7 @@ private constructor( return true } - return other is SendSendMessageResponse && + return other is SendMessageResponse && requestId == other.requestId && additionalProperties == other.additionalProperties } @@ -177,5 +177,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "SendSendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" + "SendMessageResponse{requestId=$requestId, additionalProperties=$additionalProperties}" } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt index 6e194a5c..3d9e4a0e 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsync.kt @@ -5,8 +5,8 @@ package com.courier.api.services.async import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -25,14 +25,14 @@ interface SendServiceAsync { fun withOptions(modifier: Consumer): SendServiceAsync /** Use the send API to send a message to one or more recipients. */ - fun sendMessage(params: SendSendMessageParams): CompletableFuture = - sendMessage(params, RequestOptions.none()) + fun message(params: SendMessageParams): CompletableFuture = + message(params, RequestOptions.none()) - /** @see sendMessage */ - fun sendMessage( - params: SendSendMessageParams, + /** @see message */ + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** A view of [SendServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -46,17 +46,17 @@ interface SendServiceAsync { /** * Returns a raw HTTP response for `post /send`, but is otherwise the same as - * [SendServiceAsync.sendMessage]. + * [SendServiceAsync.message]. */ - fun sendMessage( - params: SendSendMessageParams - ): CompletableFuture> = - sendMessage(params, RequestOptions.none()) - - /** @see sendMessage */ - fun sendMessage( - params: SendSendMessageParams, + fun message( + params: SendMessageParams + ): CompletableFuture> = + message(params, RequestOptions.none()) + + /** @see message */ + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt index 67cf12db..9d5042b7 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/async/SendServiceAsyncImpl.kt @@ -15,8 +15,8 @@ import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepareAsync -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -32,12 +32,12 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withOptions(modifier: Consumer): SendServiceAsync = SendServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // post /send - withRawResponse().sendMessage(params, requestOptions).thenApply { it.parse() } + withRawResponse().message(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SendServiceAsync.WithRawResponse { @@ -52,13 +52,13 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien clientOptions.toBuilder().apply(modifier::accept).build() ) - private val sendMessageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val messageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -73,7 +73,7 @@ class SendServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { sendMessageHandler.handle(it) } + .use { messageHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt index ac6f2552..b4fd838f 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendService.kt @@ -5,8 +5,8 @@ package com.courier.api.services.blocking import com.courier.api.core.ClientOptions import com.courier.api.core.RequestOptions import com.courier.api.core.http.HttpResponseFor -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -25,14 +25,14 @@ interface SendService { fun withOptions(modifier: Consumer): SendService /** Use the send API to send a message to one or more recipients. */ - fun sendMessage(params: SendSendMessageParams): SendSendMessageResponse = - sendMessage(params, RequestOptions.none()) + fun message(params: SendMessageParams): SendMessageResponse = + message(params, RequestOptions.none()) - /** @see sendMessage */ - fun sendMessage( - params: SendSendMessageParams, + /** @see message */ + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): SendSendMessageResponse + ): SendMessageResponse /** A view of [SendService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -46,17 +46,17 @@ interface SendService { /** * Returns a raw HTTP response for `post /send`, but is otherwise the same as - * [SendService.sendMessage]. + * [SendService.message]. */ @MustBeClosed - fun sendMessage(params: SendSendMessageParams): HttpResponseFor = - sendMessage(params, RequestOptions.none()) + fun message(params: SendMessageParams): HttpResponseFor = + message(params, RequestOptions.none()) - /** @see sendMessage */ + /** @see message */ @MustBeClosed - fun sendMessage( - params: SendSendMessageParams, + fun message( + params: SendMessageParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor } } diff --git a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt index 74328ce2..00735db5 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/services/blocking/SendServiceImpl.kt @@ -15,8 +15,8 @@ import com.courier.api.core.http.HttpResponseFor import com.courier.api.core.http.json import com.courier.api.core.http.parseable import com.courier.api.core.prepare -import com.courier.api.models.send.SendSendMessageParams -import com.courier.api.models.send.SendSendMessageResponse +import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.SendMessageResponse import java.util.function.Consumer class SendServiceImpl internal constructor(private val clientOptions: ClientOptions) : SendService { @@ -30,12 +30,12 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withOptions(modifier: Consumer): SendService = SendServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): SendSendMessageResponse = + ): SendMessageResponse = // post /send - withRawResponse().sendMessage(params, requestOptions).parse() + withRawResponse().message(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : SendService.WithRawResponse { @@ -50,13 +50,13 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti clientOptions.toBuilder().apply(modifier::accept).build() ) - private val sendMessageHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val messageHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun sendMessage( - params: SendSendMessageParams, + override fun message( + params: SendMessageParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) @@ -69,7 +69,7 @@ class SendServiceImpl internal constructor(private val clientOptions: ClientOpti val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { sendMessageHandler.handle(it) } + .use { messageHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt similarity index 85% rename from courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt rename to courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index 77114069..ff6bee1b 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -6,22 +6,22 @@ import com.courier.api.core.JsonValue import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class SendSendMessageParamsTest { +internal class SendMessageParamsTest { @Test fun create() { - SendSendMessageParams.builder() + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -50,29 +50,29 @@ internal class SendSendMessageParamsTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -83,12 +83,12 @@ internal class SendSendMessageParamsTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -113,34 +113,34 @@ internal class SendSendMessageParamsTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) + .criteria(SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.To.UnionMember0.Data.builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -148,9 +148,9 @@ internal class SendSendMessageParamsTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0.Preferences.builder() + SendMessageParams.Message.To.UnionMember0.Preferences.builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0.Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Notifications .builder() .putAdditionalProperty( @@ -176,7 +176,7 @@ internal class SendSendMessageParamsTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0.Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Categories .builder() .putAdditionalProperty( @@ -216,18 +216,18 @@ internal class SendSendMessageParamsTest { @Test fun body() { val params = - SendSendMessageParams.builder() + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -256,29 +256,29 @@ internal class SendSendMessageParamsTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -289,12 +289,12 @@ internal class SendSendMessageParamsTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -319,36 +319,34 @@ internal class SendSendMessageParamsTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria( - SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION - ) + .criteria(SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.To.UnionMember0.Data.builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -356,11 +354,9 @@ internal class SendSendMessageParamsTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0.Preferences - .builder() + SendMessageParams.Message.To.UnionMember0.Preferences.builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Notifications .builder() .putAdditionalProperty( @@ -389,8 +385,7 @@ internal class SendSendMessageParamsTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Categories .builder() .putAdditionalProperty( @@ -433,16 +428,16 @@ internal class SendSendMessageParamsTest { assertThat(body.message()) .isEqualTo( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -471,29 +466,29 @@ internal class SendSendMessageParamsTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -504,12 +499,12 @@ internal class SendSendMessageParamsTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -534,34 +529,34 @@ internal class SendSendMessageParamsTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria(SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) + .criteria(SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.To.UnionMember0.Data.builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -569,9 +564,9 @@ internal class SendSendMessageParamsTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0.Preferences.builder() + SendMessageParams.Message.To.UnionMember0.Preferences.builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0.Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Notifications .builder() .putAdditionalProperty( @@ -597,7 +592,7 @@ internal class SendSendMessageParamsTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0.Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Categories .builder() .putAdditionalProperty( @@ -636,11 +631,11 @@ internal class SendSendMessageParamsTest { @Test fun bodyWithoutOptionalFields() { val params = - SendSendMessageParams.builder() + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() @@ -653,9 +648,9 @@ internal class SendSendMessageParamsTest { assertThat(body.message()) .isEqualTo( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt new file mode 100644 index 00000000..990f0b0b --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageResponseTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SendMessageResponseTest { + + @Test + fun create() { + val sendMessageResponse = + SendMessageResponse.builder().requestId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() + + assertThat(sendMessageResponse.requestId()).isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val sendMessageResponse = + SendMessageResponse.builder().requestId("1-65f240a0-47a6a120c8374de9bcf9f22c").build() + + val roundtrippedSendMessageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(sendMessageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSendMessageResponse).isEqualTo(sendMessageResponse) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt deleted file mode 100644 index 61cd26f9..00000000 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendSendMessageResponseTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.courier.api.models.send - -import com.courier.api.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class SendSendMessageResponseTest { - - @Test - fun create() { - val sendSendMessageResponse = - SendSendMessageResponse.builder() - .requestId("1-65f240a0-47a6a120c8374de9bcf9f22c") - .build() - - assertThat(sendSendMessageResponse.requestId()) - .isEqualTo("1-65f240a0-47a6a120c8374de9bcf9f22c") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val sendSendMessageResponse = - SendSendMessageResponse.builder() - .requestId("1-65f240a0-47a6a120c8374de9bcf9f22c") - .build() - - val roundtrippedSendSendMessageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(sendSendMessageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedSendSendMessageResponse).isEqualTo(sendSendMessageResponse) - } -} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index ea50fe34..28f42f58 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -17,7 +17,7 @@ import com.courier.api.errors.UnauthorizedException import com.courier.api.errors.UnexpectedStatusCodeException import com.courier.api.errors.UnprocessableEntityException import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -60,7 +60,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage400() { + fun sendMessage400() { val sendService = client.send() stubFor( post(anyUrl()) @@ -71,19 +71,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -113,29 +113,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -146,12 +146,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -176,40 +176,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -217,11 +215,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -251,7 +248,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -299,7 +296,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage400WithRawResponse() { + fun sendMessage400WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -310,19 +307,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -352,29 +349,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -385,12 +382,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -415,40 +412,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -456,11 +451,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -490,7 +484,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -538,7 +532,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage401() { + fun sendMessage401() { val sendService = client.send() stubFor( post(anyUrl()) @@ -549,19 +543,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -591,29 +585,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -624,12 +618,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -654,40 +648,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -695,11 +687,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -729,7 +720,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -777,7 +768,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage401WithRawResponse() { + fun sendMessage401WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -788,19 +779,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -830,29 +821,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -863,12 +854,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -893,40 +884,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -934,11 +923,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -968,7 +956,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -1016,7 +1004,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage403() { + fun sendMessage403() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1027,19 +1015,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1069,29 +1057,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1102,12 +1090,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1132,40 +1120,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1173,11 +1159,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -1207,7 +1192,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -1255,7 +1240,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage403WithRawResponse() { + fun sendMessage403WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1266,19 +1251,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1308,29 +1293,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1341,12 +1326,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1371,40 +1356,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1412,11 +1395,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -1446,7 +1428,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -1494,7 +1476,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage404() { + fun sendMessage404() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1505,19 +1487,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1547,29 +1529,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1580,12 +1562,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1610,40 +1592,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1651,11 +1631,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -1685,7 +1664,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -1733,7 +1712,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage404WithRawResponse() { + fun sendMessage404WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -1744,19 +1723,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1786,29 +1765,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1819,12 +1798,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -1849,40 +1828,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -1890,11 +1867,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -1924,7 +1900,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -1972,7 +1948,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage422() { + fun sendMessage422() { val sendService = client.send() stubFor( post(anyUrl()) @@ -1983,19 +1959,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2025,29 +2001,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2058,12 +2034,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2088,40 +2064,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2129,11 +2103,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -2163,7 +2136,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -2211,7 +2184,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage422WithRawResponse() { + fun sendMessage422WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -2222,19 +2195,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2264,29 +2237,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2297,12 +2270,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2327,40 +2300,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2368,11 +2339,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -2402,7 +2372,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -2450,7 +2420,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage429() { + fun sendMessage429() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2461,19 +2431,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2503,29 +2473,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2536,12 +2506,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2566,40 +2536,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2607,11 +2575,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -2641,7 +2608,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -2689,7 +2656,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage429WithRawResponse() { + fun sendMessage429WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -2700,19 +2667,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2742,29 +2709,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2775,12 +2742,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2805,40 +2772,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -2846,11 +2811,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -2880,7 +2844,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -2928,7 +2892,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage500() { + fun sendMessage500() { val sendService = client.send() stubFor( post(anyUrl()) @@ -2939,19 +2903,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -2981,29 +2945,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3014,12 +2978,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3044,40 +3008,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -3085,11 +3047,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -3119,7 +3080,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -3167,7 +3128,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage500WithRawResponse() { + fun sendMessage500WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -3178,19 +3139,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3220,29 +3181,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3253,12 +3214,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3283,40 +3244,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -3324,11 +3283,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -3358,7 +3316,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -3406,7 +3364,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage999() { + fun sendMessage999() { val sendService = client.send() stubFor( post(anyUrl()) @@ -3417,19 +3375,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3459,29 +3417,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3492,12 +3450,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3522,40 +3480,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -3563,11 +3519,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -3597,7 +3552,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -3645,7 +3600,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessage999WithRawResponse() { + fun sendMessage999WithRawResponse() { val sendService = client.send().withRawResponse() stubFor( post(anyUrl()) @@ -3656,19 +3611,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3698,29 +3653,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3731,12 +3686,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3761,40 +3716,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -3802,11 +3755,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -3836,7 +3788,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() @@ -3884,7 +3836,7 @@ internal class ErrorHandlingTest { } @Test - fun sendSendMessageInvalidJsonBody() { + fun sendMessageInvalidJsonBody() { val sendService = client.send() stubFor( post(anyUrl()) @@ -3893,19 +3845,19 @@ internal class ErrorHandlingTest { val e = assertThrows { - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3935,29 +3887,29 @@ internal class ErrorHandlingTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3968,12 +3920,12 @@ internal class ErrorHandlingTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -3998,40 +3950,38 @@ internal class ErrorHandlingTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria - .NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context( MessageContext.builder().tenantId("tenant_id").build() ) .data( - SendSendMessageParams.Message.To.UnionMember0.Data - .builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -4039,11 +3989,10 @@ internal class ErrorHandlingTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -4073,7 +4022,7 @@ internal class ErrorHandlingTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index 8a6dde81..8702312d 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -6,7 +6,7 @@ import com.courier.api.client.CourierClient import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -39,23 +39,23 @@ internal class ServiceParamsTest { @Disabled("Prism tests are disabled") @Test - fun sendMessage() { + fun message() { val sendService = client.send() stubFor(post(anyUrl()).willReturn(ok("{}"))) - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -84,29 +84,29 @@ internal class ServiceParamsTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -117,12 +117,12 @@ internal class ServiceParamsTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -147,36 +147,34 @@ internal class ServiceParamsTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) - .criteria( - SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION - ) + .criteria(SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.To.UnionMember0.Data.builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -184,11 +182,9 @@ internal class ServiceParamsTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0.Preferences - .builder() + SendMessageParams.Message.To.UnionMember0.Preferences.builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Notifications .builder() .putAdditionalProperty( @@ -217,8 +213,7 @@ internal class ServiceParamsTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 - .Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .Categories .builder() .putAdditionalProperty( diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 53b4c1bd..46df0693 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -6,7 +6,7 @@ import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -16,7 +16,7 @@ internal class SendServiceAsyncTest { @Disabled("Prism tests are disabled") @Test - fun sendMessage() { + fun message() { val client = CourierOkHttpClientAsync.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -25,19 +25,19 @@ internal class SendServiceAsyncTest { val sendServiceAsync = client.send() val responseFuture = - sendServiceAsync.sendMessage( - SendSendMessageParams.builder() + sendServiceAsync.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -66,29 +66,29 @@ internal class SendServiceAsyncTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -99,12 +99,12 @@ internal class SendServiceAsyncTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -129,36 +129,36 @@ internal class SendServiceAsyncTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.To.UnionMember0.Data.builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -166,10 +166,10 @@ internal class SendServiceAsyncTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0.Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -199,7 +199,7 @@ internal class SendServiceAsyncTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index 3c162c5d..412230eb 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -6,7 +6,7 @@ import com.courier.api.TestServerExtension import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.models.send.MessageContext -import com.courier.api.models.send.SendSendMessageParams +import com.courier.api.models.send.SendMessageParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -16,7 +16,7 @@ internal class SendServiceTest { @Disabled("Prism tests are disabled") @Test - fun sendMessage() { + fun message() { val client = CourierOkHttpClient.builder() .baseUrl(TestServerExtension.BASE_URL) @@ -25,19 +25,19 @@ internal class SendServiceTest { val sendService = client.send() val response = - sendService.sendMessage( - SendSendMessageParams.builder() + sendService.message( + SendMessageParams.builder() .message( - SendSendMessageParams.Message.builder() + SendMessageParams.Message.builder() .content( - SendSendMessageParams.Message.Content.builder() + SendMessageParams.Message.Content.builder() .body("Thanks for signing up, {{name}}") .title("Welcome!") .build() ) .brandId("brand_id") .channels( - SendSendMessageParams.Message.Channels.builder() + SendMessageParams.Message.Channels.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -66,29 +66,29 @@ internal class SendServiceTest { ) .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.Data.builder() + SendMessageParams.Message.Data.builder() .putAdditionalProperty("name", JsonValue.from("bar")) .build() ) .delay( - SendSendMessageParams.Message.Delay.builder() + SendMessageParams.Message.Delay.builder() .duration(0L) .until("until") .build() ) .expiry( - SendSendMessageParams.Message.Expiry.builder() + SendMessageParams.Message.Expiry.builder() .expiresIn("string") .expiresAt("expires_at") .build() ) .metadata( - SendSendMessageParams.Message.Metadata.builder() + SendMessageParams.Message.Metadata.builder() .event("event") .addTag("string") .traceId("trace_id") .utm( - SendSendMessageParams.Message.Metadata.Utm.builder() + SendMessageParams.Message.Metadata.Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -99,12 +99,12 @@ internal class SendServiceTest { .build() ) .preferences( - SendSendMessageParams.Message.Preferences.builder() + SendMessageParams.Message.Preferences.builder() .subscriptionTopicId("subscription_topic_id") .build() ) .providers( - SendSendMessageParams.Message.Providers.builder() + SendMessageParams.Message.Providers.builder() .putAdditionalProperty( "foo", JsonValue.from( @@ -129,36 +129,36 @@ internal class SendServiceTest { .build() ) .routing( - SendSendMessageParams.Message.Routing.builder() + SendMessageParams.Message.Routing.builder() .addChannel("email") - .method(SendSendMessageParams.Message.Routing.Method.SINGLE) + .method(SendMessageParams.Message.Routing.Method.SINGLE) .build() ) .timeout( - SendSendMessageParams.Message.Timeout.builder() + SendMessageParams.Message.Timeout.builder() .channel( - SendSendMessageParams.Message.Timeout.Channel.builder() + SendMessageParams.Message.Timeout.Channel.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .criteria( - SendSendMessageParams.Message.Timeout.Criteria.NO_ESCALATION + SendMessageParams.Message.Timeout.Criteria.NO_ESCALATION ) .escalation(0L) .message(0L) .provider( - SendSendMessageParams.Message.Timeout.Provider.builder() + SendMessageParams.Message.Timeout.Provider.builder() .putAdditionalProperty("foo", JsonValue.from(0)) .build() ) .build() ) .to( - SendSendMessageParams.Message.To.UnionMember0.builder() + SendMessageParams.Message.To.UnionMember0.builder() .accountId("account_id") .context(MessageContext.builder().tenantId("tenant_id").build()) .data( - SendSendMessageParams.Message.To.UnionMember0.Data.builder() + SendMessageParams.Message.To.UnionMember0.Data.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) @@ -166,10 +166,10 @@ internal class SendServiceTest { .locale("locale") .phoneNumber("phone_number") .preferences( - SendSendMessageParams.Message.To.UnionMember0.Preferences + SendMessageParams.Message.To.UnionMember0.Preferences .builder() .notifications( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Notifications .builder() @@ -199,7 +199,7 @@ internal class SendServiceTest { .build() ) .categories( - SendSendMessageParams.Message.To.UnionMember0 + SendMessageParams.Message.To.UnionMember0 .Preferences .Categories .builder() From 70aa2874518fd8f48e5cc8927b7abcea60787b7c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 3 Oct 2025 19:28:42 +0000 Subject: [PATCH 22/33] feat(api): manual updates --- .stats.yml | 2 +- .../com/courier/api/models/send/Preference.kt | 1080 +++++++++++++++++ .../api/models/send/SendMessageParams.kt | 307 ----- .../kotlin/com/courier/api/models/send/Utm.kt | 293 +++++ .../courier/api/models/send/PreferenceTest.kt | 62 + .../api/models/send/SendMessageParamsTest.kt | 6 +- .../com/courier/api/models/send/UtmTest.kt | 47 + .../courier/api/services/ErrorHandlingTest.kt | 35 +- .../courier/api/services/ServiceParamsTest.kt | 3 +- .../services/async/SendServiceAsyncTest.kt | 3 +- .../api/services/blocking/SendServiceTest.kt | 3 +- 11 files changed, 1510 insertions(+), 331 deletions(-) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Preference.kt create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/PreferenceTest.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt diff --git a/.stats.yml b/.stats.yml index 1390599a..1338f482 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 1 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-851bd80e56022cef0ab7c12f24f6ff89aab45140bcc7274810661a344a4541b1.yml openapi_spec_hash: 302486c729027393a465d01fe9d006eb -config_hash: beed1fd2e7d46cccf41ebdb7fcbcbdbe +config_hash: b6430581c22bff16b664d42d7235d15d diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Preference.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Preference.kt new file mode 100644 index 00000000..502ada12 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Preference.kt @@ -0,0 +1,1080 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.checkKnown +import com.courier.api.core.checkRequired +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Preference +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val channelPreferences: JsonField>, + private val rules: JsonField>, + private val source: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("channel_preferences") + @ExcludeMissing + channelPreferences: JsonField> = JsonMissing.of(), + @JsonProperty("rules") @ExcludeMissing rules: JsonField> = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + ) : this(status, channelPreferences, rules, source, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun status(): Status = status.getRequired("status") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channelPreferences(): Optional> = + channelPreferences.getOptional("channel_preferences") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun rules(): Optional> = rules.getOptional("rules") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [channelPreferences]. + * + * Unlike [channelPreferences], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("channel_preferences") + @ExcludeMissing + fun _channelPreferences(): JsonField> = channelPreferences + + /** + * Returns the raw JSON value of [rules]. + * + * Unlike [rules], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rules") @ExcludeMissing fun _rules(): JsonField> = rules + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Preference]. + * + * The following fields are required: + * ```java + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Preference]. */ + class Builder internal constructor() { + + private var status: JsonField? = null + private var channelPreferences: JsonField>? = null + private var rules: JsonField>? = null + private var source: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(preference: Preference) = apply { + status = preference.status + channelPreferences = preference.channelPreferences.map { it.toMutableList() } + rules = preference.rules.map { it.toMutableList() } + source = preference.source + additionalProperties = preference.additionalProperties.toMutableMap() + } + + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun channelPreferences(channelPreferences: List?) = + channelPreferences(JsonField.ofNullable(channelPreferences)) + + /** + * Alias for calling [Builder.channelPreferences] with `channelPreferences.orElse(null)`. + */ + fun channelPreferences(channelPreferences: Optional>) = + channelPreferences(channelPreferences.getOrNull()) + + /** + * Sets [Builder.channelPreferences] to an arbitrary JSON value. + * + * You should usually call [Builder.channelPreferences] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun channelPreferences(channelPreferences: JsonField>) = apply { + this.channelPreferences = channelPreferences.map { it.toMutableList() } + } + + /** + * Adds a single [ChannelPreference] to [channelPreferences]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannelPreference(channelPreference: ChannelPreference) = apply { + channelPreferences = + (channelPreferences ?: JsonField.of(mutableListOf())).also { + checkKnown("channelPreferences", it).add(channelPreference) + } + } + + fun rules(rules: List?) = rules(JsonField.ofNullable(rules)) + + /** Alias for calling [Builder.rules] with `rules.orElse(null)`. */ + fun rules(rules: Optional>) = rules(rules.getOrNull()) + + /** + * Sets [Builder.rules] to an arbitrary JSON value. + * + * You should usually call [Builder.rules] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rules(rules: JsonField>) = apply { + this.rules = rules.map { it.toMutableList() } + } + + /** + * Adds a single [Rule] to [rules]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRule(rule: Rule) = apply { + rules = + (rules ?: JsonField.of(mutableListOf())).also { checkKnown("rules", it).add(rule) } + } + + fun source(source: Source?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [Source] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Preference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Preference = + Preference( + checkRequired("status", status), + (channelPreferences ?: JsonMissing.of()).map { it.toImmutable() }, + (rules ?: JsonMissing.of()).map { it.toImmutable() }, + source, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Preference = apply { + if (validated) { + return@apply + } + + status().validate() + channelPreferences().ifPresent { it.forEach { it.validate() } } + rules().ifPresent { it.forEach { it.validate() } } + source().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (status.asKnown().getOrNull()?.validity() ?: 0) + + (channelPreferences.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (rules.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (source.asKnown().getOrNull()?.validity() ?: 0) + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OPTED_IN = of("OPTED_IN") + + @JvmField val OPTED_OUT = of("OPTED_OUT") + + @JvmField val REQUIRED = of("REQUIRED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + OPTED_IN, + OPTED_OUT, + REQUIRED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OPTED_IN, + OPTED_OUT, + REQUIRED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OPTED_IN -> Value.OPTED_IN + OPTED_OUT -> Value.OPTED_OUT + REQUIRED -> Value.REQUIRED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OPTED_IN -> Known.OPTED_IN + OPTED_OUT -> Known.OPTED_OUT + REQUIRED -> Known.REQUIRED + else -> throw CourierInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Status = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class ChannelPreference + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channel: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channel") @ExcludeMissing channel: JsonField = JsonMissing.of() + ) : this(channel, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun channel(): Channel = channel.getRequired("channel") + + /** + * Returns the raw JSON value of [channel]. + * + * Unlike [channel], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channel") @ExcludeMissing fun _channel(): JsonField = channel + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ChannelPreference]. + * + * The following fields are required: + * ```java + * .channel() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChannelPreference]. */ + class Builder internal constructor() { + + private var channel: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(channelPreference: ChannelPreference) = apply { + channel = channelPreference.channel + additionalProperties = channelPreference.additionalProperties.toMutableMap() + } + + fun channel(channel: Channel) = channel(JsonField.of(channel)) + + /** + * Sets [Builder.channel] to an arbitrary JSON value. + * + * You should usually call [Builder.channel] with a well-typed [Channel] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channel(channel: JsonField) = apply { this.channel = channel } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChannelPreference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .channel() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ChannelPreference = + ChannelPreference( + checkRequired("channel", channel), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChannelPreference = apply { + if (validated) { + return@apply + } + + channel().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (channel.asKnown().getOrNull()?.validity() ?: 0) + + class Channel @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DIRECT_MESSAGE = of("direct_message") + + @JvmField val EMAIL = of("email") + + @JvmField val PUSH = of("push") + + @JvmField val SMS = of("sms") + + @JvmField val WEBHOOK = of("webhook") + + @JvmField val INBOX = of("inbox") + + @JvmStatic fun of(value: String) = Channel(JsonField.of(value)) + } + + /** An enum containing [Channel]'s known values. */ + enum class Known { + DIRECT_MESSAGE, + EMAIL, + PUSH, + SMS, + WEBHOOK, + INBOX, + } + + /** + * An enum containing [Channel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Channel] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DIRECT_MESSAGE, + EMAIL, + PUSH, + SMS, + WEBHOOK, + INBOX, + /** + * An enum member indicating that [Channel] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DIRECT_MESSAGE -> Value.DIRECT_MESSAGE + EMAIL -> Value.EMAIL + PUSH -> Value.PUSH + SMS -> Value.SMS + WEBHOOK -> Value.WEBHOOK + INBOX -> Value.INBOX + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DIRECT_MESSAGE -> Known.DIRECT_MESSAGE + EMAIL -> Known.EMAIL + PUSH -> Known.PUSH + SMS -> Known.SMS + WEBHOOK -> Known.WEBHOOK + INBOX -> Known.INBOX + else -> throw CourierInvalidDataException("Unknown Channel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Channel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Channel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChannelPreference && + channel == other.channel && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(channel, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChannelPreference{channel=$channel, additionalProperties=$additionalProperties}" + } + + class Rule + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val until: JsonField, + private val start: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("until") @ExcludeMissing until: JsonField = JsonMissing.of(), + @JsonProperty("start") @ExcludeMissing start: JsonField = JsonMissing.of(), + ) : this(until, start, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun until(): String = until.getRequired("until") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun start(): Optional = start.getOptional("start") + + /** + * Returns the raw JSON value of [until]. + * + * Unlike [until], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("until") @ExcludeMissing fun _until(): JsonField = until + + /** + * Returns the raw JSON value of [start]. + * + * Unlike [start], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start") @ExcludeMissing fun _start(): JsonField = start + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Rule]. + * + * The following fields are required: + * ```java + * .until() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Rule]. */ + class Builder internal constructor() { + + private var until: JsonField? = null + private var start: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(rule: Rule) = apply { + until = rule.until + start = rule.start + additionalProperties = rule.additionalProperties.toMutableMap() + } + + fun until(until: String) = until(JsonField.of(until)) + + /** + * Sets [Builder.until] to an arbitrary JSON value. + * + * You should usually call [Builder.until] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun until(until: JsonField) = apply { this.until = until } + + fun start(start: String?) = start(JsonField.ofNullable(start)) + + /** Alias for calling [Builder.start] with `start.orElse(null)`. */ + fun start(start: Optional) = start(start.getOrNull()) + + /** + * Sets [Builder.start] to an arbitrary JSON value. + * + * You should usually call [Builder.start] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun start(start: JsonField) = apply { this.start = start } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Rule]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .until() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Rule = + Rule(checkRequired("until", until), start, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Rule = apply { + if (validated) { + return@apply + } + + until() + start() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (until.asKnown().isPresent) 1 else 0) + (if (start.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Rule && + until == other.until && + start == other.start && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(until, start, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Rule{until=$until, start=$start, additionalProperties=$additionalProperties}" + } + + class Source @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SUBSCRIPTION = of("subscription") + + @JvmField val LIST = of("list") + + @JvmField val RECIPIENT = of("recipient") + + @JvmStatic fun of(value: String) = Source(JsonField.of(value)) + } + + /** An enum containing [Source]'s known values. */ + enum class Known { + SUBSCRIPTION, + LIST, + RECIPIENT, + } + + /** + * An enum containing [Source]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Source] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SUBSCRIPTION, + LIST, + RECIPIENT, + /** An enum member indicating that [Source] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SUBSCRIPTION -> Value.SUBSCRIPTION + LIST -> Value.LIST + RECIPIENT -> Value.RECIPIENT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SUBSCRIPTION -> Known.SUBSCRIPTION + LIST -> Known.LIST + RECIPIENT -> Known.RECIPIENT + else -> throw CourierInvalidDataException("Unknown Source: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { CourierInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Source = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Source && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Preference && + status == other.status && + channelPreferences == other.channelPreferences && + rules == other.rules && + source == other.source && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(status, channelPreferences, rules, source, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Preference{status=$status, channelPreferences=$channelPreferences, rules=$rules, source=$source, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt index e2f3df65..eb237569 100644 --- a/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/SendMessageParams.kt @@ -2285,313 +2285,6 @@ private constructor( (if (traceId.asKnown().isPresent) 1 else 0) + (utm.asKnown().getOrNull()?.validity() ?: 0) - class Utm - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val campaign: JsonField, - private val content: JsonField, - private val medium: JsonField, - private val source: JsonField, - private val term: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("campaign") - @ExcludeMissing - campaign: JsonField = JsonMissing.of(), - @JsonProperty("content") - @ExcludeMissing - content: JsonField = JsonMissing.of(), - @JsonProperty("medium") - @ExcludeMissing - medium: JsonField = JsonMissing.of(), - @JsonProperty("source") - @ExcludeMissing - source: JsonField = JsonMissing.of(), - @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), - ) : this(campaign, content, medium, source, term, mutableMapOf()) - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun campaign(): Optional = campaign.getOptional("campaign") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun content(): Optional = content.getOptional("content") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun medium(): Optional = medium.getOptional("medium") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun source(): Optional = source.getOptional("source") - - /** - * @throws CourierInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun term(): Optional = term.getOptional("term") - - /** - * Returns the raw JSON value of [campaign]. - * - * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("campaign") - @ExcludeMissing - fun _campaign(): JsonField = campaign - - /** - * Returns the raw JSON value of [content]. - * - * Unlike [content], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content - - /** - * Returns the raw JSON value of [medium]. - * - * Unlike [medium], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium - - /** - * Returns the raw JSON value of [source]. - * - * Unlike [source], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source - - /** - * Returns the raw JSON value of [term]. - * - * Unlike [term], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Utm]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Utm]. */ - class Builder internal constructor() { - - private var campaign: JsonField = JsonMissing.of() - private var content: JsonField = JsonMissing.of() - private var medium: JsonField = JsonMissing.of() - private var source: JsonField = JsonMissing.of() - private var term: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(utm: Utm) = apply { - campaign = utm.campaign - content = utm.content - medium = utm.medium - source = utm.source - term = utm.term - additionalProperties = utm.additionalProperties.toMutableMap() - } - - fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) - - /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ - fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) - - /** - * Sets [Builder.campaign] to an arbitrary JSON value. - * - * You should usually call [Builder.campaign] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun campaign(campaign: JsonField) = apply { this.campaign = campaign } - - fun content(content: String?) = content(JsonField.ofNullable(content)) - - /** Alias for calling [Builder.content] with `content.orElse(null)`. */ - fun content(content: Optional) = content(content.getOrNull()) - - /** - * Sets [Builder.content] to an arbitrary JSON value. - * - * You should usually call [Builder.content] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun content(content: JsonField) = apply { this.content = content } - - fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) - - /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ - fun medium(medium: Optional) = medium(medium.getOrNull()) - - /** - * Sets [Builder.medium] to an arbitrary JSON value. - * - * You should usually call [Builder.medium] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun medium(medium: JsonField) = apply { this.medium = medium } - - fun source(source: String?) = source(JsonField.ofNullable(source)) - - /** Alias for calling [Builder.source] with `source.orElse(null)`. */ - fun source(source: Optional) = source(source.getOrNull()) - - /** - * Sets [Builder.source] to an arbitrary JSON value. - * - * You should usually call [Builder.source] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun source(source: JsonField) = apply { this.source = source } - - fun term(term: String?) = term(JsonField.ofNullable(term)) - - /** Alias for calling [Builder.term] with `term.orElse(null)`. */ - fun term(term: Optional) = term(term.getOrNull()) - - /** - * Sets [Builder.term] to an arbitrary JSON value. - * - * You should usually call [Builder.term] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun term(term: JsonField) = apply { this.term = term } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Utm]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Utm = - Utm( - campaign, - content, - medium, - source, - term, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Utm = apply { - if (validated) { - return@apply - } - - campaign() - content() - medium() - source() - term() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CourierInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (campaign.asKnown().isPresent) 1 else 0) + - (if (content.asKnown().isPresent) 1 else 0) + - (if (medium.asKnown().isPresent) 1 else 0) + - (if (source.asKnown().isPresent) 1 else 0) + - (if (term.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Utm && - campaign == other.campaign && - content == other.content && - medium == other.medium && - source == other.source && - term == other.term && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(campaign, content, medium, source, term, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt new file mode 100644 index 00000000..8504b223 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/Utm.kt @@ -0,0 +1,293 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class Utm +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val campaign: JsonField, + private val content: JsonField, + private val medium: JsonField, + private val source: JsonField, + private val term: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("campaign") @ExcludeMissing campaign: JsonField = JsonMissing.of(), + @JsonProperty("content") @ExcludeMissing content: JsonField = JsonMissing.of(), + @JsonProperty("medium") @ExcludeMissing medium: JsonField = JsonMissing.of(), + @JsonProperty("source") @ExcludeMissing source: JsonField = JsonMissing.of(), + @JsonProperty("term") @ExcludeMissing term: JsonField = JsonMissing.of(), + ) : this(campaign, content, medium, source, term, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun campaign(): Optional = campaign.getOptional("campaign") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun content(): Optional = content.getOptional("content") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun medium(): Optional = medium.getOptional("medium") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun source(): Optional = source.getOptional("source") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun term(): Optional = term.getOptional("term") + + /** + * Returns the raw JSON value of [campaign]. + * + * Unlike [campaign], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("campaign") @ExcludeMissing fun _campaign(): JsonField = campaign + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("content") @ExcludeMissing fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [medium]. + * + * Unlike [medium], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("medium") @ExcludeMissing fun _medium(): JsonField = medium + + /** + * Returns the raw JSON value of [source]. + * + * Unlike [source], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("source") @ExcludeMissing fun _source(): JsonField = source + + /** + * Returns the raw JSON value of [term]. + * + * Unlike [term], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("term") @ExcludeMissing fun _term(): JsonField = term + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Utm]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Utm]. */ + class Builder internal constructor() { + + private var campaign: JsonField = JsonMissing.of() + private var content: JsonField = JsonMissing.of() + private var medium: JsonField = JsonMissing.of() + private var source: JsonField = JsonMissing.of() + private var term: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(utm: Utm) = apply { + campaign = utm.campaign + content = utm.content + medium = utm.medium + source = utm.source + term = utm.term + additionalProperties = utm.additionalProperties.toMutableMap() + } + + fun campaign(campaign: String?) = campaign(JsonField.ofNullable(campaign)) + + /** Alias for calling [Builder.campaign] with `campaign.orElse(null)`. */ + fun campaign(campaign: Optional) = campaign(campaign.getOrNull()) + + /** + * Sets [Builder.campaign] to an arbitrary JSON value. + * + * You should usually call [Builder.campaign] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun campaign(campaign: JsonField) = apply { this.campaign = campaign } + + fun content(content: String?) = content(JsonField.ofNullable(content)) + + /** Alias for calling [Builder.content] with `content.orElse(null)`. */ + fun content(content: Optional) = content(content.getOrNull()) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + fun medium(medium: String?) = medium(JsonField.ofNullable(medium)) + + /** Alias for calling [Builder.medium] with `medium.orElse(null)`. */ + fun medium(medium: Optional) = medium(medium.getOrNull()) + + /** + * Sets [Builder.medium] to an arbitrary JSON value. + * + * You should usually call [Builder.medium] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun medium(medium: JsonField) = apply { this.medium = medium } + + fun source(source: String?) = source(JsonField.ofNullable(source)) + + /** Alias for calling [Builder.source] with `source.orElse(null)`. */ + fun source(source: Optional) = source(source.getOrNull()) + + /** + * Sets [Builder.source] to an arbitrary JSON value. + * + * You should usually call [Builder.source] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun source(source: JsonField) = apply { this.source = source } + + fun term(term: String?) = term(JsonField.ofNullable(term)) + + /** Alias for calling [Builder.term] with `term.orElse(null)`. */ + fun term(term: Optional) = term(term.getOrNull()) + + /** + * Sets [Builder.term] to an arbitrary JSON value. + * + * You should usually call [Builder.term] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun term(term: JsonField) = apply { this.term = term } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Utm]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Utm = + Utm(campaign, content, medium, source, term, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Utm = apply { + if (validated) { + return@apply + } + + campaign() + content() + medium() + source() + term() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (campaign.asKnown().isPresent) 1 else 0) + + (if (content.asKnown().isPresent) 1 else 0) + + (if (medium.asKnown().isPresent) 1 else 0) + + (if (source.asKnown().isPresent) 1 else 0) + + (if (term.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Utm && + campaign == other.campaign && + content == other.content && + medium == other.medium && + source == other.source && + term == other.term && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(campaign, content, medium, source, term, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Utm{campaign=$campaign, content=$content, medium=$medium, source=$source, term=$term, additionalProperties=$additionalProperties}" +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/PreferenceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/PreferenceTest.kt new file mode 100644 index 00000000..137fe336 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/PreferenceTest.kt @@ -0,0 +1,62 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PreferenceTest { + + @Test + fun create() { + val preference = + Preference.builder() + .status(Preference.Status.OPTED_IN) + .addChannelPreference( + Preference.ChannelPreference.builder() + .channel(Preference.ChannelPreference.Channel.DIRECT_MESSAGE) + .build() + ) + .addRule(Preference.Rule.builder().until("until").start("start").build()) + .source(Preference.Source.SUBSCRIPTION) + .build() + + assertThat(preference.status()).isEqualTo(Preference.Status.OPTED_IN) + assertThat(preference.channelPreferences().getOrNull()) + .containsExactly( + Preference.ChannelPreference.builder() + .channel(Preference.ChannelPreference.Channel.DIRECT_MESSAGE) + .build() + ) + assertThat(preference.rules().getOrNull()) + .containsExactly(Preference.Rule.builder().until("until").start("start").build()) + assertThat(preference.source()).contains(Preference.Source.SUBSCRIPTION) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val preference = + Preference.builder() + .status(Preference.Status.OPTED_IN) + .addChannelPreference( + Preference.ChannelPreference.builder() + .channel(Preference.ChannelPreference.Channel.DIRECT_MESSAGE) + .build() + ) + .addRule(Preference.Rule.builder().until("until").start("start").build()) + .source(Preference.Source.SUBSCRIPTION) + .build() + + val roundtrippedPreference = + jsonMapper.readValue( + jsonMapper.writeValueAsString(preference), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPreference).isEqualTo(preference) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt index ff6bee1b..2ba39eb3 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/SendMessageParamsTest.kt @@ -72,7 +72,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -278,7 +278,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -488,7 +488,7 @@ internal class SendMessageParamsTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt new file mode 100644 index 00000000..889e13b8 --- /dev/null +++ b/courier-java-core/src/test/kotlin/com/courier/api/models/send/UtmTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UtmTest { + + @Test + fun create() { + val utm = + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + + assertThat(utm.campaign()).contains("campaign") + assertThat(utm.content()).contains("content") + assertThat(utm.medium()).contains("medium") + assertThat(utm.source()).contains("source") + assertThat(utm.term()).contains("term") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val utm = + Utm.builder() + .campaign("campaign") + .content("content") + .medium("medium") + .source("source") + .term("term") + .build() + + val roundtrippedUtm = + jsonMapper.readValue(jsonMapper.writeValueAsString(utm), jacksonTypeRef()) + + assertThat(roundtrippedUtm).isEqualTo(utm) + } +} diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt index 28f42f58..8a71cafa 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ErrorHandlingTest.kt @@ -18,6 +18,7 @@ import com.courier.api.errors.UnexpectedStatusCodeException import com.courier.api.errors.UnprocessableEntityException import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -135,7 +136,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -371,7 +372,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -607,7 +608,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -843,7 +844,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1079,7 +1080,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1315,7 +1316,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1551,7 +1552,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -1787,7 +1788,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2023,7 +2024,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2259,7 +2260,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2495,7 +2496,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2731,7 +2732,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -2967,7 +2968,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3203,7 +3204,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3439,7 +3440,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3675,7 +3676,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") @@ -3909,7 +3910,7 @@ internal class ErrorHandlingTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt index 8702312d..823c0e34 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/ServiceParamsTest.kt @@ -7,6 +7,7 @@ import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -106,7 +107,7 @@ internal class ServiceParamsTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt index 46df0693..fb147b71 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/async/SendServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.courier.api.client.okhttp.CourierOkHttpClientAsync import com.courier.api.core.JsonValue import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -88,7 +89,7 @@ internal class SendServiceAsyncTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") diff --git a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt index 412230eb..ebc43f16 100644 --- a/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt +++ b/courier-java-core/src/test/kotlin/com/courier/api/services/blocking/SendServiceTest.kt @@ -7,6 +7,7 @@ import com.courier.api.client.okhttp.CourierOkHttpClient import com.courier.api.core.JsonValue import com.courier.api.models.send.MessageContext import com.courier.api.models.send.SendMessageParams +import com.courier.api.models.send.Utm import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -88,7 +89,7 @@ internal class SendServiceTest { .addTag("string") .traceId("trace_id") .utm( - SendMessageParams.Message.Metadata.Utm.builder() + Utm.builder() .campaign("campaign") .content("content") .medium("medium") From 0ec4d9354b7a702a83e9d305ea8a493eda3af820 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 6 Oct 2025 18:17:13 +0000 Subject: [PATCH 23/33] feat(api): manual updates --- .stats.yml | 6 +- README.md | 8 +- .../courier/api/models/send/ElementalNode.kt | 4283 +++++++++++++++++ .../api/models/send/SendMessageParams.kt | 782 ++- .../api/models/send/ElementalNodeTest.kt | 419 ++ .../api/models/send/SendMessageParamsTest.kt | 10 +- .../courier/api/services/ErrorHandlingTest.kt | 51 +- .../courier/api/services/ServiceParamsTest.kt | 2 +- .../services/async/SendServiceAsyncTest.kt | 2 +- .../api/services/blocking/SendServiceTest.kt | 2 +- .../api/proguard/ProGuardCompatibilityTest.kt | 23 +- 11 files changed, 5411 insertions(+), 177 deletions(-) create mode 100644 courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt create mode 100644 courier-java-core/src/test/kotlin/com/courier/api/models/send/ElementalNodeTest.kt diff --git a/.stats.yml b/.stats.yml index 1338f482..c635d666 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 1 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-851bd80e56022cef0ab7c12f24f6ff89aab45140bcc7274810661a344a4541b1.yml -openapi_spec_hash: 302486c729027393a465d01fe9d006eb -config_hash: b6430581c22bff16b664d42d7235d15d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/courier%2Fcourier-0588b50c82b2c2f07b89eade761efb3f23c47f4382d35a858a1406df3e30b600.yml +openapi_spec_hash: 79a5d37f3d1057c87ddc97330ced3c58 +config_hash: 245476b27687e005d4bec9bdc1720b73 diff --git a/README.md b/README.md index af914878..90d53808 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ CourierClient client = CourierOkHttpClient.fromEnv(); SendMessageParams params = SendMessageParams.builder() .message(SendMessageParams.Message.builder() - .content(SendMessageParams.Message.Content.builder() + .content(SendMessageParams.Message.Content.ElementalContentSugar.builder() .body("body") .title("title") .build()) @@ -163,7 +163,7 @@ CourierClient client = CourierOkHttpClient.fromEnv(); SendMessageParams params = SendMessageParams.builder() .message(SendMessageParams.Message.builder() - .content(SendMessageParams.Message.Content.builder() + .content(SendMessageParams.Message.Content.ElementalContentSugar.builder() .body("body") .title("title") .build()) @@ -187,7 +187,7 @@ CourierClientAsync client = CourierOkHttpClientAsync.fromEnv(); SendMessageParams params = SendMessageParams.builder() .message(SendMessageParams.Message.builder() - .content(SendMessageParams.Message.Content.builder() + .content(SendMessageParams.Message.Content.ElementalContentSugar.builder() .body("body") .title("title") .build()) @@ -212,7 +212,7 @@ import com.courier.api.models.send.SendMessageResponse; SendMessageParams params = SendMessageParams.builder() .message(SendMessageParams.Message.builder() - .content(SendMessageParams.Message.Content.builder() + .content(SendMessageParams.Message.Content.ElementalContentSugar.builder() .body("body") .title("title") .build()) diff --git a/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt new file mode 100644 index 00000000..f7f0bc46 --- /dev/null +++ b/courier-java-core/src/main/kotlin/com/courier/api/models/send/ElementalNode.kt @@ -0,0 +1,4283 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.courier.api.models.send + +import com.courier.api.core.BaseDeserializer +import com.courier.api.core.BaseSerializer +import com.courier.api.core.Enum +import com.courier.api.core.ExcludeMissing +import com.courier.api.core.JsonField +import com.courier.api.core.JsonMissing +import com.courier.api.core.JsonValue +import com.courier.api.core.allMaxBy +import com.courier.api.core.checkKnown +import com.courier.api.core.getOrThrow +import com.courier.api.core.toImmutable +import com.courier.api.errors.CourierInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = ElementalNode.Deserializer::class) +@JsonSerialize(using = ElementalNode.Serializer::class) +class ElementalNode +private constructor( + private val unionMember0: UnionMember0? = null, + private val unionMember1: UnionMember1? = null, + private val unionMember2: UnionMember2? = null, + private val unionMember3: UnionMember3? = null, + private val unionMember4: UnionMember4? = null, + private val unionMember5: UnionMember5? = null, + private val unionMember6: UnionMember6? = null, + private val unionMember7: UnionMember7? = null, + private val _json: JsonValue? = null, +) { + + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun unionMember1(): Optional = Optional.ofNullable(unionMember1) + + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun unionMember3(): Optional = Optional.ofNullable(unionMember3) + + fun unionMember4(): Optional = Optional.ofNullable(unionMember4) + + fun unionMember5(): Optional = Optional.ofNullable(unionMember5) + + fun unionMember6(): Optional = Optional.ofNullable(unionMember6) + + fun unionMember7(): Optional = Optional.ofNullable(unionMember7) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isUnionMember1(): Boolean = unionMember1 != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun isUnionMember3(): Boolean = unionMember3 != null + + fun isUnionMember4(): Boolean = unionMember4 != null + + fun isUnionMember5(): Boolean = unionMember5 != null + + fun isUnionMember6(): Boolean = unionMember6 != null + + fun isUnionMember7(): Boolean = unionMember7 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asUnionMember1(): UnionMember1 = unionMember1.getOrThrow("unionMember1") + + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun asUnionMember3(): UnionMember3 = unionMember3.getOrThrow("unionMember3") + + fun asUnionMember4(): UnionMember4 = unionMember4.getOrThrow("unionMember4") + + fun asUnionMember5(): UnionMember5 = unionMember5.getOrThrow("unionMember5") + + fun asUnionMember6(): UnionMember6 = unionMember6.getOrThrow("unionMember6") + + fun asUnionMember7(): UnionMember7 = unionMember7.getOrThrow("unionMember7") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + unionMember1 != null -> visitor.visitUnionMember1(unionMember1) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + unionMember3 != null -> visitor.visitUnionMember3(unionMember3) + unionMember4 != null -> visitor.visitUnionMember4(unionMember4) + unionMember5 != null -> visitor.visitUnionMember5(unionMember5) + unionMember6 != null -> visitor.visitUnionMember6(unionMember6) + unionMember7 != null -> visitor.visitUnionMember7(unionMember7) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): ElementalNode = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitUnionMember1(unionMember1: UnionMember1) { + unionMember1.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + + override fun visitUnionMember3(unionMember3: UnionMember3) { + unionMember3.validate() + } + + override fun visitUnionMember4(unionMember4: UnionMember4) { + unionMember4.validate() + } + + override fun visitUnionMember5(unionMember5: UnionMember5) { + unionMember5.validate() + } + + override fun visitUnionMember6(unionMember6: UnionMember6) { + unionMember6.validate() + } + + override fun visitUnionMember7(unionMember7: UnionMember7) { + unionMember7.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitUnionMember1(unionMember1: UnionMember1) = unionMember1.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + + override fun visitUnionMember3(unionMember3: UnionMember3) = unionMember3.validity() + + override fun visitUnionMember4(unionMember4: UnionMember4) = unionMember4.validity() + + override fun visitUnionMember5(unionMember5: UnionMember5) = unionMember5.validity() + + override fun visitUnionMember6(unionMember6: UnionMember6) = unionMember6.validity() + + override fun visitUnionMember7(unionMember7: UnionMember7) = unionMember7.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ElementalNode && + unionMember0 == other.unionMember0 && + unionMember1 == other.unionMember1 && + unionMember2 == other.unionMember2 && + unionMember3 == other.unionMember3 && + unionMember4 == other.unionMember4 && + unionMember5 == other.unionMember5 && + unionMember6 == other.unionMember6 && + unionMember7 == other.unionMember7 + } + + override fun hashCode(): Int = + Objects.hash( + unionMember0, + unionMember1, + unionMember2, + unionMember3, + unionMember4, + unionMember5, + unionMember6, + unionMember7, + ) + + override fun toString(): String = + when { + unionMember0 != null -> "ElementalNode{unionMember0=$unionMember0}" + unionMember1 != null -> "ElementalNode{unionMember1=$unionMember1}" + unionMember2 != null -> "ElementalNode{unionMember2=$unionMember2}" + unionMember3 != null -> "ElementalNode{unionMember3=$unionMember3}" + unionMember4 != null -> "ElementalNode{unionMember4=$unionMember4}" + unionMember5 != null -> "ElementalNode{unionMember5=$unionMember5}" + unionMember6 != null -> "ElementalNode{unionMember6=$unionMember6}" + unionMember7 != null -> "ElementalNode{unionMember7=$unionMember7}" + _json != null -> "ElementalNode{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ElementalNode") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = ElementalNode(unionMember0 = unionMember0) + + @JvmStatic + fun ofUnionMember1(unionMember1: UnionMember1) = ElementalNode(unionMember1 = unionMember1) + + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = ElementalNode(unionMember2 = unionMember2) + + @JvmStatic + fun ofUnionMember3(unionMember3: UnionMember3) = ElementalNode(unionMember3 = unionMember3) + + @JvmStatic + fun ofUnionMember4(unionMember4: UnionMember4) = ElementalNode(unionMember4 = unionMember4) + + @JvmStatic + fun ofUnionMember5(unionMember5: UnionMember5) = ElementalNode(unionMember5 = unionMember5) + + @JvmStatic + fun ofUnionMember6(unionMember6: UnionMember6) = ElementalNode(unionMember6 = unionMember6) + + @JvmStatic + fun ofUnionMember7(unionMember7: UnionMember7) = ElementalNode(unionMember7 = unionMember7) + } + + /** + * An interface that defines how to map each variant of [ElementalNode] to a value of type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitUnionMember1(unionMember1: UnionMember1): T + + fun visitUnionMember2(unionMember2: UnionMember2): T + + fun visitUnionMember3(unionMember3: UnionMember3): T + + fun visitUnionMember4(unionMember4: UnionMember4): T + + fun visitUnionMember5(unionMember5: UnionMember5): T + + fun visitUnionMember6(unionMember6: UnionMember6): T + + fun visitUnionMember7(unionMember7: UnionMember7): T + + /** + * Maps an unknown variant of [ElementalNode] to a value of type [T]. + * + * An instance of [ElementalNode] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws CourierInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw CourierInvalidDataException("Unknown ElementalNode: $json") + } + } + + internal class Deserializer : BaseDeserializer(ElementalNode::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ElementalNode { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember1 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember2 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember3 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember4 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember5 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember6 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ElementalNode(unionMember7 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ElementalNode(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ElementalNode::class) { + + override fun serialize( + value: ElementalNode, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.unionMember1 != null -> generator.writeObject(value.unionMember1) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value.unionMember3 != null -> generator.writeObject(value.unionMember3) + value.unionMember4 != null -> generator.writeObject(value.unionMember4) + value.unionMember5 != null -> generator.writeObject(value.unionMember5) + value.unionMember6 != null -> generator.writeObject(value.unionMember6) + value.unionMember7 != null -> generator.writeObject(value.unionMember7) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ElementalNode") + } + } + } + + class UnionMember0 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember0]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + channels = unionMember0.channels.map { it.toMutableList() } + if_ = unionMember0.if_ + loop = unionMember0.loop + ref = unionMember0.ref + type = unionMember0.type + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember0 = + UnionMember0( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val TEXT = of("text") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TEXT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + TEXT, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + TEXT -> Value.TEXT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + TEXT -> Known.TEXT + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember0 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember1 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember1]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember1]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember1: UnionMember1) = apply { + channels = unionMember1.channels.map { it.toMutableList() } + if_ = unionMember1.if_ + loop = unionMember1.loop + ref = unionMember1.ref + type = unionMember1.type + additionalProperties = unionMember1.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember1]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember1 = + UnionMember1( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember1 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val META = of("meta") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + META + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + META, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + META -> Value.META + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + META -> Known.META + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember1 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember1{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember2 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember2]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + channels = unionMember2.channels.map { it.toMutableList() } + if_ = unionMember2.if_ + loop = unionMember2.loop + ref = unionMember2.ref + type = unionMember2.type + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember2 = + UnionMember2( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHANNEL = of("channel") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CHANNEL + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHANNEL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHANNEL -> Value.CHANNEL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHANNEL -> Known.CHANNEL + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember2 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember3 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val channels: JsonField>, + private val if_: JsonField, + private val loop: JsonField, + private val ref: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("channels") + @ExcludeMissing + channels: JsonField> = JsonMissing.of(), + @JsonProperty("if") @ExcludeMissing if_: JsonField = JsonMissing.of(), + @JsonProperty("loop") @ExcludeMissing loop: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(channels, if_, loop, ref, type, mutableMapOf()) + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun channels(): Optional> = channels.getOptional("channels") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun if_(): Optional = if_.getOptional("if") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun loop(): Optional = loop.getOptional("loop") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * @throws CourierInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [channels]. + * + * Unlike [channels], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("channels") + @ExcludeMissing + fun _channels(): JsonField> = channels + + /** + * Returns the raw JSON value of [if_]. + * + * Unlike [if_], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("if") @ExcludeMissing fun _if_(): JsonField = if_ + + /** + * Returns the raw JSON value of [loop]. + * + * Unlike [loop], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("loop") @ExcludeMissing fun _loop(): JsonField = loop + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [UnionMember3]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember3]. */ + class Builder internal constructor() { + + private var channels: JsonField>? = null + private var if_: JsonField = JsonMissing.of() + private var loop: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember3: UnionMember3) = apply { + channels = unionMember3.channels.map { it.toMutableList() } + if_ = unionMember3.if_ + loop = unionMember3.loop + ref = unionMember3.ref + type = unionMember3.type + additionalProperties = unionMember3.additionalProperties.toMutableMap() + } + + fun channels(channels: List?) = channels(JsonField.ofNullable(channels)) + + /** Alias for calling [Builder.channels] with `channels.orElse(null)`. */ + fun channels(channels: Optional>) = channels(channels.getOrNull()) + + /** + * Sets [Builder.channels] to an arbitrary JSON value. + * + * You should usually call [Builder.channels] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun channels(channels: JsonField>) = apply { + this.channels = channels.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [channels]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addChannel(channel: String) = apply { + channels = + (channels ?: JsonField.of(mutableListOf())).also { + checkKnown("channels", it).add(channel) + } + } + + fun if_(if_: String?) = if_(JsonField.ofNullable(if_)) + + /** Alias for calling [Builder.if_] with `if_.orElse(null)`. */ + fun if_(if_: Optional) = if_(if_.getOrNull()) + + /** + * Sets [Builder.if_] to an arbitrary JSON value. + * + * You should usually call [Builder.if_] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun if_(if_: JsonField) = apply { this.if_ = if_ } + + fun loop(loop: String?) = loop(JsonField.ofNullable(loop)) + + /** Alias for calling [Builder.loop] with `loop.orElse(null)`. */ + fun loop(loop: Optional) = loop(loop.getOrNull()) + + /** + * Sets [Builder.loop] to an arbitrary JSON value. + * + * You should usually call [Builder.loop] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun loop(loop: JsonField) = apply { this.loop = loop } + + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember3]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UnionMember3 = + UnionMember3( + (channels ?: JsonMissing.of()).map { it.toImmutable() }, + if_, + loop, + ref, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember3 = apply { + if (validated) { + return@apply + } + + channels() + if_() + loop() + ref() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (channels.asKnown().getOrNull()?.size ?: 0) + + (if (if_.asKnown().isPresent) 1 else 0) + + (if (loop.asKnown().isPresent) 1 else 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val IMAGE = of("image") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + IMAGE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + IMAGE, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + IMAGE -> Value.IMAGE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CourierInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + IMAGE -> Known.IMAGE + else -> throw CourierInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CourierInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CourierInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CourierInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UnionMember3 && + channels == other.channels && + if_ == other.if_ && + loop == other.loop && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(channels, if_, loop, ref, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember3{channels=$channels, if_=$if_, loop=$loop, ref=$ref, type=$type, additionalProperties=$additionalProperties}" + } + + class UnionMember4 + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val actionId: JsonField, + private val align: JsonField, + private val backgroundColor: JsonField, + private val content: JsonField, + private val href: JsonField, + private val locales: JsonField, + private val style: JsonField